2019-12-03 10:37:18 -08: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
2025-01-17 16:19:39 -08:00
import sys
2019-12-03 10:37:18 -08:00
2021-04-22 17:42:52 +01:00
from celery . schedules import crontab
2023-08-31 08:44:48 -03:00
from flask_caching . backends . filesystemcache import FileSystemCache
2019-12-05 16:47:22 -08:00
2019-12-03 10:37:18 -08:00
logger = logging . getLogger ( )
2023-08-22 11:35:10 -03:00
DATABASE_DIALECT = os . getenv ( " DATABASE_DIALECT " )
DATABASE_USER = os . getenv ( " DATABASE_USER " )
DATABASE_PASSWORD = os . getenv ( " DATABASE_PASSWORD " )
DATABASE_HOST = os . getenv ( " DATABASE_HOST " )
DATABASE_PORT = os . getenv ( " DATABASE_PORT " )
DATABASE_DB = os . getenv ( " DATABASE_DB " )
2019-12-03 10:37:18 -08:00
2023-08-22 11:35:10 -03:00
EXAMPLES_USER = os . getenv ( " EXAMPLES_USER " )
EXAMPLES_PASSWORD = os . getenv ( " EXAMPLES_PASSWORD " )
EXAMPLES_HOST = os . getenv ( " EXAMPLES_HOST " )
EXAMPLES_PORT = os . getenv ( " EXAMPLES_PORT " )
EXAMPLES_DB = os . getenv ( " EXAMPLES_DB " )
2023-08-17 11:50:24 +01:00
2019-12-03 10:37:18 -08:00
# The SQLAlchemy connection string.
2023-08-17 11:50:24 +01:00
SQLALCHEMY_DATABASE_URI = (
f " { DATABASE_DIALECT } :// "
f " { DATABASE_USER } : { DATABASE_PASSWORD } @ "
f " { DATABASE_HOST } : { DATABASE_PORT } / { DATABASE_DB } "
)
2025-08-25 12:37:28 -07:00
# Use environment variable if set, otherwise construct from components
# This MUST take precedence over any other configuration
SQLALCHEMY_EXAMPLES_URI = os . getenv (
" SUPERSET__SQLALCHEMY_EXAMPLES_URI " ,
(
f " { DATABASE_DIALECT } :// "
f " { EXAMPLES_USER } : { EXAMPLES_PASSWORD } @ "
f " { EXAMPLES_HOST } : { EXAMPLES_PORT } / { EXAMPLES_DB } "
) ,
2019-12-03 10:37:18 -08:00
)
2025-08-25 12:37:28 -07:00
2023-08-21 13:45:22 +02:00
REDIS_HOST = os . getenv ( " REDIS_HOST " , " redis " )
REDIS_PORT = os . getenv ( " REDIS_PORT " , " 6379 " )
REDIS_CELERY_DB = os . getenv ( " REDIS_CELERY_DB " , " 0 " )
REDIS_RESULTS_DB = os . getenv ( " REDIS_RESULTS_DB " , " 1 " )
2020-05-14 16:58:30 +01:00
2020-05-07 19:33:41 +03:00
RESULTS_BACKEND = FileSystemCache ( " /app/superset_home/sqllab " )
2019-12-05 16:47:22 -08:00
2022-08-30 09:24:24 -07:00
CACHE_CONFIG = {
2023-04-28 11:46:56 +03:00
" CACHE_TYPE " : " RedisCache " ,
2022-08-30 09:24:24 -07:00
" CACHE_DEFAULT_TIMEOUT " : 300 ,
" CACHE_KEY_PREFIX " : " superset_ " ,
" CACHE_REDIS_HOST " : REDIS_HOST ,
" CACHE_REDIS_PORT " : REDIS_PORT ,
" CACHE_REDIS_DB " : REDIS_RESULTS_DB ,
}
DATA_CACHE_CONFIG = CACHE_CONFIG
2025-04-09 21:43:44 +01:00
THUMBNAIL_CACHE_CONFIG = CACHE_CONFIG
2022-08-30 09:24:24 -07:00
2019-12-03 10:37:18 -08:00
2023-06-01 12:01:10 -07:00
class CeleryConfig :
2023-01-13 19:56:15 +03:00
broker_url = f " redis:// { REDIS_HOST } : { REDIS_PORT } / { REDIS_CELERY_DB } "
2024-08-05 15:46:53 -07:00
imports = (
" superset.sql_lab " ,
" superset.tasks.scheduler " ,
" superset.tasks.thumbnails " ,
" superset.tasks.cache " ,
)
2023-01-13 19:56:15 +03:00
result_backend = f " redis:// { REDIS_HOST } : { REDIS_PORT } / { REDIS_RESULTS_DB } "
worker_prefetch_multiplier = 1
task_acks_late = False
beat_schedule = {
2021-04-22 17:42:52 +01:00
" reports.scheduler " : {
" task " : " reports.scheduler " ,
" schedule " : crontab ( minute = " * " , hour = " * " ) ,
} ,
" reports.prune_log " : {
" task " : " reports.prune_log " ,
" schedule " : crontab ( minute = 10 , hour = 0 ) ,
} ,
}
2019-12-03 10:37:18 -08:00
CELERY_CONFIG = CeleryConfig
2021-04-22 17:42:52 +01:00
2026-02-02 14:54:33 +01:00
FEATURE_FLAGS = { " ALERT_REPORTS " : True , " DATASET_FOLDERS " : True }
2021-04-22 17:42:52 +01:00
ALERT_REPORTS_NOTIFICATION_DRY_RUN = True
2025-04-09 21:43:44 +01:00
WEBDRIVER_BASEURL = f " http://superset_app { os . environ . get ( ' SUPERSET_APP_ROOT ' , ' / ' ) } / " # When using docker compose baseurl should be http://superset_nginx{ENV{BASEPATH}}/ # noqa: E501
2021-04-22 17:42:52 +01:00
# The base URL for the email report hyperlinks.
2025-04-09 21:43:44 +01:00
WEBDRIVER_BASEURL_USER_FRIENDLY = (
f " http://localhost:8888/ { os . environ . get ( ' SUPERSET_APP_ROOT ' , ' / ' ) } / "
)
2020-05-14 16:58:30 +01:00
SQLLAB_CTAS_NO_LIMIT = True
2019-12-03 10:37:18 -08:00
2025-01-09 16:24:53 -08:00
log_level_text = os . getenv ( " SUPERSET_LOG_LEVEL " , " INFO " )
LOG_LEVEL = getattr ( logging , log_level_text . upper ( ) , logging . INFO )
2025-01-17 16:19:39 -08:00
if os . getenv ( " CYPRESS_CONFIG " ) == " true " :
# When running the service as a cypress backend, we need to import the config
# located @ tests/integration_tests/superset_test_config.py
base_dir = os . path . dirname ( __file__ )
module_folder = os . path . abspath (
os . path . join ( base_dir , " ../../tests/integration_tests/ " )
)
sys . path . insert ( 0 , module_folder )
from superset_test_config import * # noqa
sys . path . pop ( 0 )
2019-12-03 10:37:18 -08: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 :
import superset_config_docker
2025-07-28 09:27:07 -07:00
from superset_config_docker import * # noqa: F403
2019-12-03 10:37:18 -08:00
logger . info (
2025-09-15 12:42:49 -07:00
" Loaded your Docker configuration at [ %s ] " , superset_config_docker . __file__
2019-12-03 10:37:18 -08:00
)
except ImportError :
logger . info ( " Using default Docker config... " )