2016-03-29 00:55:58 -04:00
|
|
|
"""The main config file for Caravel
|
2016-03-18 02:44:58 -04:00
|
|
|
|
2016-06-22 10:55:09 -04:00
|
|
|
All configuration in this file can be overridden by providing a caravel_config
|
|
|
|
in your PYTHONPATH as there is a ``from caravel_config import *``
|
2016-03-16 23:25:41 -04:00
|
|
|
at the end of this file.
|
2016-03-18 02:44:58 -04:00
|
|
|
"""
|
2016-04-07 11:39:08 -04:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import unicode_literals
|
2016-09-15 20:20:18 -04:00
|
|
|
from caravel import app
|
2016-04-07 11:39:08 -04:00
|
|
|
|
2016-09-15 20:20:18 -04:00
|
|
|
import json
|
2016-03-18 02:44:58 -04:00
|
|
|
import os
|
2016-04-08 02:01:40 -04:00
|
|
|
|
2016-03-18 02:44:58 -04:00
|
|
|
from dateutil import tz
|
2016-04-08 02:01:40 -04:00
|
|
|
from flask_appbuilder.security.manager import AUTH_DB
|
2016-03-18 02:44:58 -04:00
|
|
|
|
2016-03-16 23:25:41 -04:00
|
|
|
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
2016-08-17 00:35:31 -04:00
|
|
|
DATA_DIR = os.path.join(os.path.expanduser('~'), '.caravel')
|
|
|
|
if not os.path.exists(DATA_DIR):
|
|
|
|
os.makedirs(DATA_DIR)
|
2016-03-18 02:44:58 -04:00
|
|
|
|
|
|
|
# ---------------------------------------------------------
|
2016-06-09 19:44:13 -04:00
|
|
|
# Caravel specific config
|
2016-03-18 02:44:58 -04:00
|
|
|
# ---------------------------------------------------------
|
2016-09-15 20:20:18 -04:00
|
|
|
PACKAGE_DIR = os.path.join(BASE_DIR, 'static', 'assets')
|
|
|
|
PACKAGE_FILE = os.path.join(PACKAGE_DIR, 'package.json')
|
|
|
|
with open(PACKAGE_FILE) as package_file:
|
|
|
|
VERSION_STRING = json.load(package_file)['version']
|
|
|
|
|
2016-03-18 02:44:58 -04:00
|
|
|
ROW_LIMIT = 50000
|
2016-10-07 13:16:41 -04:00
|
|
|
CARAVEL_WORKERS = 2
|
2016-03-18 02:44:58 -04:00
|
|
|
|
2016-07-28 14:49:43 -04:00
|
|
|
CARAVEL_WEBSERVER_ADDRESS = '0.0.0.0'
|
2016-03-29 00:55:58 -04:00
|
|
|
CARAVEL_WEBSERVER_PORT = 8088
|
|
|
|
CARAVEL_WEBSERVER_TIMEOUT = 60
|
2016-03-18 02:44:58 -04:00
|
|
|
|
|
|
|
CUSTOM_SECURITY_MANAGER = None
|
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
|
|
|
# Your App secret key
|
|
|
|
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h' # noqa
|
|
|
|
|
|
|
|
# The SQLAlchemy connection string.
|
2016-08-17 00:35:31 -04:00
|
|
|
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'caravel.db')
|
2016-03-18 02:44:58 -04:00
|
|
|
# SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
|
|
|
|
# SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp'
|
|
|
|
|
2016-09-23 20:41:24 -04:00
|
|
|
# The limit of queries fetched for query search
|
|
|
|
QUERY_SEARCH_LIMIT = 1000
|
|
|
|
|
2016-03-18 02:44:58 -04:00
|
|
|
# Flask-WTF flag for CSRF
|
|
|
|
CSRF_ENABLED = True
|
|
|
|
|
|
|
|
# Whether to run the web server in debug mode or not
|
2016-04-09 01:09:01 -04:00
|
|
|
DEBUG = False
|
2016-03-18 02:44:58 -04:00
|
|
|
|
|
|
|
# Whether to show the stacktrace on 500 error
|
|
|
|
SHOW_STACKTRACE = True
|
|
|
|
|
2016-09-20 15:24:15 -04:00
|
|
|
# Extract and use X-Forwarded-For/X-Forwarded-Proto headers?
|
|
|
|
ENABLE_PROXY_FIX = False
|
|
|
|
|
2016-03-18 02:44:58 -04:00
|
|
|
# ------------------------------
|
|
|
|
# GLOBALS FOR APP Builder
|
|
|
|
# ------------------------------
|
|
|
|
# Uncomment to setup Your App name
|
2016-03-29 00:55:58 -04:00
|
|
|
APP_NAME = "Caravel"
|
2016-03-18 02:44:58 -04:00
|
|
|
|
|
|
|
# Uncomment to setup Setup an App icon
|
2016-06-09 19:45:03 -04:00
|
|
|
APP_ICON = "/static/assets/images/caravel_logo.png"
|
2016-03-18 02:44:58 -04:00
|
|
|
|
|
|
|
# Druid query timezone
|
|
|
|
# tz.tzutc() : Using utc timezone
|
|
|
|
# tz.tzlocal() : Using local timezone
|
|
|
|
# other tz can be overridden by providing a local_config
|
2016-03-25 14:26:59 -04:00
|
|
|
DRUID_IS_ACTIVE = True
|
2016-03-18 02:44:58 -04:00
|
|
|
DRUID_TZ = tz.tzutc()
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# AUTHENTICATION CONFIG
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# The authentication type
|
|
|
|
# AUTH_OID : Is for OpenID
|
|
|
|
# AUTH_DB : Is for database (username/password()
|
|
|
|
# AUTH_LDAP : Is for LDAP
|
|
|
|
# AUTH_REMOTE_USER : Is for using REMOTE_USER from web server
|
|
|
|
AUTH_TYPE = AUTH_DB
|
|
|
|
|
|
|
|
# Uncomment to setup Full admin role name
|
|
|
|
# AUTH_ROLE_ADMIN = 'Admin'
|
|
|
|
|
|
|
|
# Uncomment to setup Public role name, no authentication needed
|
|
|
|
# AUTH_ROLE_PUBLIC = 'Public'
|
|
|
|
|
|
|
|
# Will allow user self registration
|
|
|
|
# AUTH_USER_REGISTRATION = True
|
|
|
|
|
|
|
|
# The default user self registration role
|
|
|
|
# AUTH_USER_REGISTRATION_ROLE = "Public"
|
|
|
|
|
|
|
|
# When using LDAP Auth, setup the ldap server
|
|
|
|
# AUTH_LDAP_SERVER = "ldap://ldapserver.new"
|
|
|
|
|
|
|
|
# Uncomment to setup OpenID providers example for OpenID authentication
|
|
|
|
# OPENID_PROVIDERS = [
|
|
|
|
# { 'name': 'Yahoo', 'url': 'https://me.yahoo.com' },
|
|
|
|
# { 'name': 'AOL', 'url': 'http://openid.aol.com/<username>' },
|
|
|
|
# { 'name': 'Flickr', 'url': 'http://www.flickr.com/<username>' },
|
|
|
|
# { 'name': 'MyOpenID', 'url': 'https://www.myopenid.com' }]
|
2016-05-17 00:24:43 -04:00
|
|
|
|
|
|
|
# ---------------------------------------------------
|
|
|
|
# Roles config
|
|
|
|
# ---------------------------------------------------
|
|
|
|
# Grant public role the same set of permissions as for the GAMMA role.
|
|
|
|
# This is useful if one wants to enable anonymous users to view
|
|
|
|
# dashboards. Explicit grant on specific datasets is still required.
|
|
|
|
PUBLIC_ROLE_LIKE_GAMMA = False
|
|
|
|
|
2016-03-18 02:44:58 -04:00
|
|
|
# ---------------------------------------------------
|
|
|
|
# Babel config for translations
|
|
|
|
# ---------------------------------------------------
|
|
|
|
# Setup default language
|
|
|
|
BABEL_DEFAULT_LOCALE = 'en'
|
|
|
|
# Your application default translation path
|
2016-05-02 13:50:23 -04:00
|
|
|
BABEL_DEFAULT_FOLDER = 'babel/translations'
|
2016-03-18 02:44:58 -04:00
|
|
|
# The allowed translation for you app
|
|
|
|
LANGUAGES = {
|
|
|
|
'en': {'flag': 'us', 'name': 'English'},
|
2016-05-02 13:50:23 -04:00
|
|
|
# 'fr': {'flag': 'fr', 'name': 'French'},
|
|
|
|
# 'zh': {'flag': 'cn', 'name': 'Chinese'},
|
2016-03-18 02:44:58 -04:00
|
|
|
}
|
|
|
|
# ---------------------------------------------------
|
|
|
|
# Image and file configuration
|
|
|
|
# ---------------------------------------------------
|
|
|
|
# The file upload folder, when using models with files
|
|
|
|
UPLOAD_FOLDER = BASE_DIR + '/app/static/uploads/'
|
|
|
|
|
|
|
|
# The image upload folder, when using models with images
|
|
|
|
IMG_UPLOAD_FOLDER = BASE_DIR + '/app/static/uploads/'
|
|
|
|
|
|
|
|
# The image upload url, when using models with images
|
|
|
|
IMG_UPLOAD_URL = '/static/uploads/'
|
|
|
|
# Setup image size default is (300, 200, True)
|
|
|
|
# IMG_SIZE = (300, 200, True)
|
|
|
|
|
2016-03-16 23:25:41 -04:00
|
|
|
CACHE_DEFAULT_TIMEOUT = None
|
|
|
|
CACHE_CONFIG = {'CACHE_TYPE': 'null'}
|
|
|
|
|
2016-06-02 15:34:36 -04:00
|
|
|
# CORS Options
|
|
|
|
ENABLE_CORS = False
|
|
|
|
CORS_OPTIONS = {}
|
|
|
|
|
2016-04-18 12:00:03 -04:00
|
|
|
|
|
|
|
# ---------------------------------------------------
|
|
|
|
# List of viz_types not allowed in your environment
|
|
|
|
# For example: Blacklist pivot table and treemap:
|
|
|
|
# VIZ_TYPE_BLACKLIST = ['pivot_table', 'treemap']
|
|
|
|
# ---------------------------------------------------
|
|
|
|
|
|
|
|
VIZ_TYPE_BLACKLIST = []
|
|
|
|
|
2016-05-06 15:03:42 -04:00
|
|
|
# ---------------------------------------------------
|
|
|
|
# List of data sources not to be refreshed in druid cluster
|
|
|
|
# ---------------------------------------------------
|
|
|
|
|
|
|
|
DRUID_DATA_SOURCE_BLACKLIST = []
|
|
|
|
|
2016-09-21 12:52:05 -04:00
|
|
|
# --------------------------------------------------
|
|
|
|
# Modules and datasources to be registered
|
|
|
|
# --------------------------------------------------
|
|
|
|
DEFAULT_MODULE_DS_MAP = {'caravel.models': ['DruidDatasource', 'SqlaTable']}
|
|
|
|
ADDITIONAL_MODULE_DS_MAP = {}
|
|
|
|
|
2016-05-01 10:59:08 -04:00
|
|
|
"""
|
|
|
|
1) http://docs.python-guide.org/en/latest/writing/logging/
|
|
|
|
2) https://docs.python.org/2/library/logging.config.html
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Console Log Settings
|
|
|
|
|
|
|
|
LOG_FORMAT = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
|
|
|
|
LOG_LEVEL = 'DEBUG'
|
|
|
|
|
|
|
|
# ---------------------------------------------------
|
|
|
|
# Enable Time Rotate Log Handler
|
|
|
|
# ---------------------------------------------------
|
|
|
|
# LOG_LEVEL = DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
|
|
|
|
|
|
ENABLE_TIME_ROTATE = False
|
|
|
|
TIME_ROTATE_LOG_LEVEL = 'DEBUG'
|
2016-08-17 00:35:31 -04:00
|
|
|
FILENAME = os.path.join(DATA_DIR, 'caravel.log')
|
2016-05-01 10:59:08 -04:00
|
|
|
ROLLOVER = 'midnight'
|
|
|
|
INTERVAL = 1
|
|
|
|
BACKUP_COUNT = 30
|
|
|
|
|
Map visualization (#650)
* simple mapbox viz
use react-map-gl
superclustering of long/lat points
Added hook for map style, huge performance boost from bounding box fix, added count text on clusters
variable gradient size based on metric count
Ability to aggregate over any point property
This needed a change in the supercluster npm module, a PR was placed here:
https://github.com/mapbox/supercluster/pull/12
Aggregator function option in explore, tweaked visual defaults
better radius size management
clustering radius, point metric/unit options
scale cluster labels that don't fit, non-numeric labels for points
Minor fixes, label field affects points, text changes
serve mapbox apikey for slice
global opacity, viewport saves (hacky), bug in point labels
fixing mapbox-gl dependency
mapbox_api_key in config
expose row_limit, fix minor bugs
Add renderWhileDragging flag, groupby. Only show numerical columns for point radius
Implicitly group by lng/lat columns and error when label doesn't match groupby
'Fix' radius in miles problem, still some jankiness
derived fields cannot be typed as of now -> reverting numerical number change
better grouping error checking, expose count(*) for labelling
Custom colour for clusters/points + smart text colouring
Fixed bad positioning and overflow in explore view + small bugs + added thumbnail
* landscaping & eslint & use izip
* landscapin'
* address js code review
2016-06-24 17:16:51 -04:00
|
|
|
# Set this API key to enable Mapbox visualizations
|
|
|
|
MAPBOX_API_KEY = ""
|
|
|
|
|
2016-08-30 00:55:31 -04:00
|
|
|
# Maximum number of rows returned in the SQL editor
|
|
|
|
SQL_MAX_ROW = 1000
|
|
|
|
|
2016-08-13 02:40:24 -04:00
|
|
|
# If defined, shows this text in an alert-warning box in the navbar
|
|
|
|
# one example use case may be "STAGING" to make it clear that this is
|
|
|
|
# not the production version of the site.
|
|
|
|
WARNING_MSG = None
|
|
|
|
|
2016-08-30 00:55:31 -04:00
|
|
|
# Default celery config is to use SQLA as a broker, in a production setting
|
|
|
|
# you'll want to use a proper broker as specified here:
|
|
|
|
# http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html
|
|
|
|
"""
|
|
|
|
# Example:
|
|
|
|
class CeleryConfig(object):
|
|
|
|
BROKER_URL = 'sqla+sqlite:///celerydb.sqlite'
|
|
|
|
CELERY_IMPORTS = ('caravel.tasks', )
|
|
|
|
CELERY_RESULT_BACKEND = 'db+sqlite:///celery_results.sqlite'
|
|
|
|
CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}}
|
|
|
|
CELERY_CONFIG = CeleryConfig
|
|
|
|
"""
|
|
|
|
CELERY_CONFIG = None
|
|
|
|
SQL_CELERY_DB_FILE_PATH = os.path.join(DATA_DIR, 'celerydb.sqlite')
|
|
|
|
SQL_CELERY_RESULTS_DB_FILE_PATH = os.path.join(DATA_DIR, 'celery_results.sqlite')
|
|
|
|
|
2016-09-21 17:41:42 -04:00
|
|
|
# static http headers to be served by your Caravel server.
|
|
|
|
# The following example prevents iFrame from other domains
|
|
|
|
# and "clickjacking" as a result
|
|
|
|
# HTTP_HEADERS = {'X-Frame-Options': 'SAMEORIGIN'}
|
|
|
|
HTTP_HEADERS = {}
|
|
|
|
|
2016-08-30 00:55:31 -04:00
|
|
|
# The db id here results in selecting this one as a default in SQL Lab
|
|
|
|
DEFAULT_DB_ID = None
|
2016-05-01 10:59:08 -04:00
|
|
|
|
2016-09-19 18:28:10 -04:00
|
|
|
# Timeout duration for SQL Lab synchronous queries
|
|
|
|
SQLLAB_TIMEOUT = 30
|
|
|
|
|
2016-03-18 02:44:58 -04:00
|
|
|
try:
|
2016-03-29 00:55:58 -04:00
|
|
|
from caravel_config import * # noqa
|
2016-06-03 12:46:03 -04:00
|
|
|
except ImportError:
|
2016-03-18 02:44:58 -04:00
|
|
|
pass
|
2016-04-25 15:41:30 -04:00
|
|
|
|
|
|
|
if not CACHE_DEFAULT_TIMEOUT:
|
|
|
|
CACHE_DEFAULT_TIMEOUT = CACHE_CONFIG.get('CACHE_DEFAULT_TIMEOUT')
|