2019-12-03 13:37:18 -05:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
#
|
|
|
|
# This file is included in the final Docker image and SHOULD be overridden when
|
|
|
|
# deploying the image to prod. Settings configured here are intended for use in local
|
|
|
|
# development environments. Also note that superset_config_docker.py is imported
|
|
|
|
# as a final step as a means to override "defaults" configured here
|
|
|
|
#
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
2020-05-13 11:49:34 -04:00
|
|
|
from cachelib.file import FileSystemCache
|
2019-12-05 19:47:22 -05:00
|
|
|
|
2019-12-03 13:37:18 -05:00
|
|
|
logger = logging.getLogger()
|
|
|
|
|
|
|
|
|
|
|
|
def get_env_variable(var_name, default=None):
|
|
|
|
"""Get the environment variable or raise exception."""
|
|
|
|
try:
|
|
|
|
return os.environ[var_name]
|
|
|
|
except KeyError:
|
|
|
|
if default is not None:
|
|
|
|
return default
|
|
|
|
else:
|
|
|
|
error_msg = "The environment variable {} was missing, abort...".format(
|
|
|
|
var_name
|
|
|
|
)
|
|
|
|
raise EnvironmentError(error_msg)
|
|
|
|
|
|
|
|
|
2019-12-20 05:57:33 -05:00
|
|
|
DATABASE_DIALECT = get_env_variable("DATABASE_DIALECT")
|
|
|
|
DATABASE_USER = get_env_variable("DATABASE_USER")
|
|
|
|
DATABASE_PASSWORD = get_env_variable("DATABASE_PASSWORD")
|
|
|
|
DATABASE_HOST = get_env_variable("DATABASE_HOST")
|
|
|
|
DATABASE_PORT = get_env_variable("DATABASE_PORT")
|
|
|
|
DATABASE_DB = get_env_variable("DATABASE_DB")
|
2019-12-03 13:37:18 -05:00
|
|
|
|
|
|
|
# The SQLAlchemy connection string.
|
2019-12-20 05:57:33 -05:00
|
|
|
SQLALCHEMY_DATABASE_URI = "%s://%s:%s@%s:%s/%s" % (
|
|
|
|
DATABASE_DIALECT,
|
|
|
|
DATABASE_USER,
|
|
|
|
DATABASE_PASSWORD,
|
|
|
|
DATABASE_HOST,
|
|
|
|
DATABASE_PORT,
|
|
|
|
DATABASE_DB,
|
2019-12-03 13:37:18 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_HOST = get_env_variable("REDIS_HOST")
|
|
|
|
REDIS_PORT = get_env_variable("REDIS_PORT")
|
2020-05-14 11:58:30 -04:00
|
|
|
REDIS_CELERY_DB = get_env_variable("REDIS_CELERY_DB", 0)
|
|
|
|
REDIS_RESULTS_DB = get_env_variable("REDIS_CELERY_DB", 1)
|
|
|
|
|
2019-12-03 13:37:18 -05:00
|
|
|
|
2020-05-07 12:33:41 -04:00
|
|
|
RESULTS_BACKEND = FileSystemCache("/app/superset_home/sqllab")
|
2019-12-05 19:47:22 -05:00
|
|
|
|
2019-12-03 13:37:18 -05:00
|
|
|
|
|
|
|
class CeleryConfig(object):
|
2020-05-14 11:58:30 -04:00
|
|
|
BROKER_URL = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_CELERY_DB}"
|
2019-12-03 13:37:18 -05:00
|
|
|
CELERY_IMPORTS = ("superset.sql_lab",)
|
2020-05-14 11:58:30 -04:00
|
|
|
CELERY_RESULT_BACKEND = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_RESULTS_DB}"
|
2019-12-03 13:37:18 -05:00
|
|
|
CELERY_ANNOTATIONS = {"tasks.add": {"rate_limit": "10/s"}}
|
|
|
|
CELERY_TASK_PROTOCOL = 1
|
|
|
|
|
|
|
|
|
|
|
|
CELERY_CONFIG = CeleryConfig
|
2020-05-14 11:58:30 -04:00
|
|
|
SQLLAB_CTAS_NO_LIMIT = True
|
2019-12-03 13:37:18 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# Optionally import superset_config_docker.py (which will have been included on
|
|
|
|
# the PYTHONPATH) in order to allow for local settings to be overridden
|
|
|
|
#
|
|
|
|
try:
|
|
|
|
from superset_config_docker import * # noqa
|
|
|
|
import superset_config_docker
|
|
|
|
|
|
|
|
logger.info(
|
|
|
|
f"Loaded your Docker configuration at " f"[{superset_config_docker.__file__}]"
|
|
|
|
)
|
|
|
|
except ImportError:
|
|
|
|
logger.info("Using default Docker config...")
|