A modern, enterprise-ready business intelligence web application for data exploration and visualization.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Comprehensive configuration system for Apache Superset covering databases, security, caching, performance tuning, and feature flags.
Base configuration settings for the Superset application.
class SupersetConfig:
"""Base configuration class for Superset."""
# Server Configuration
SECRET_KEY: str = "YOUR_OWN_RANDOM_GENERATED_SECRET_KEY"
SUPERSET_WEBSERVER_PROTOCOL: str = "http"
SUPERSET_WEBSERVER_ADDRESS: str = "0.0.0.0"
SUPERSET_WEBSERVER_PORT: int = 8088
SUPERSET_WEBSERVER_TIMEOUT: int = 60
# Application Metadata
APP_NAME: str = "Superset"
APP_ICON: str = "/static/assets/images/superset-logo-horiz.png"
FAVICONS: List[Dict[str, Any]] = []
# Logging Configuration
LOG_FORMAT: str = "%(asctime)s:%(levelname)s:%(name)s:%(message)s"
LOG_LEVEL: str = "DEBUG"
ENABLE_TIME_ROTATE: bool = True
# Flask Configuration
FLASK_USE_RELOAD: bool = True
FLASK_ADMIN_SWATCH: str = "cosmo"Usage Examples:
# Custom configuration file (superset_config.py)
SECRET_KEY = 'my-secret-key'
SUPERSET_WEBSERVER_PORT = 8080
# Environment variables
import os
SECRET_KEY = os.environ.get('SUPERSET_SECRET_KEY', 'default-secret')Database connection settings and SQLAlchemy configuration.
# Primary Database Configuration
SQLALCHEMY_DATABASE_URI: str = "sqlite:///superset.db"
SQLALCHEMY_TRACK_MODIFICATIONS: bool = False
SQLALCHEMY_ENGINE_OPTIONS: Dict[str, Any] = {
"pool_pre_ping": True,
"pool_recycle": 300,
"pool_size": 10,
"max_overflow": 20
}
# Custom Password Stores
SQLALCHEMY_CUSTOM_PASSWORD_STORE: Optional[Callable[[str], str]] = None
# Database Connections Pool Settings
SQLALCHEMY_POOL_SIZE: int = 5
SQLALCHEMY_POOL_TIMEOUT: int = 30
SQLALCHEMY_POOL_RECYCLE: int = 1800
SQLALCHEMY_MAX_OVERFLOW: int = 10
SQLALCHEMY_ECHO: bool = False
# Query Execution Settings
SUPERSET_WEBSERVER_TIMEOUT: int = 60
SQLLAB_TIMEOUT: int = 300
SQLLAB_ASYNC_TIME_LIMIT_SEC: int = 600
SQL_MAX_ROW: int = 100000Usage Examples:
# PostgreSQL configuration
SQLALCHEMY_DATABASE_URI = 'postgresql://user:password@host:port/database'
# MySQL configuration
SQLALCHEMY_DATABASE_URI = 'mysql://user:password@host:port/database'
# Connection pooling
SQLALCHEMY_ENGINE_OPTIONS = {
'pool_size': 20,
'pool_timeout': 20,
'pool_recycle': 1800,
'max_overflow': 0,
'pool_pre_ping': True,
}Authentication, authorization, and security settings.
# Authentication Configuration
AUTH_TYPE: int = AUTH_DB # Database authentication
AUTH_ROLE_ADMIN: str = "Admin"
AUTH_ROLE_PUBLIC: str = "Public"
AUTH_USER_REGISTRATION: bool = False
AUTH_USER_REGISTRATION_ROLE: str = "Gamma"
# Custom Security Manager
CUSTOM_SECURITY_MANAGER: Optional[Type[SupersetSecurityManager]] = None
# CSRF Protection
WTF_CSRF_ENABLED: bool = True
WTF_CSRF_EXEMPT_LIST: List[str] = []
WTF_CSRF_TIME_LIMIT: int = 3600
# Session Configuration
PERMANENT_SESSION_LIFETIME: timedelta = timedelta(days=31)
SESSION_COOKIE_SECURE: bool = False
SESSION_COOKIE_HTTPONLY: bool = True
SESSION_COOKIE_SAMESITE: Optional[str] = "Lax"
# OAuth Configuration
AUTH_TYPE: int = AUTH_OAUTH
OAUTH_PROVIDERS: List[Dict[str, Any]] = []
# Public Role Permissions
PUBLIC_ROLE_LIKE: Optional[str] = "Gamma"Usage Examples:
# OAuth Google configuration
from flask_appbuilder.security.manager import AUTH_OAUTH
AUTH_TYPE = AUTH_OAUTH
OAUTH_PROVIDERS = [{
'name': 'google',
'token_key': 'access_token',
'icon': 'fa-google',
'remote_app': {
'client_id': 'GOOGLE_CLIENT_ID',
'client_secret': 'GOOGLE_CLIENT_SECRET',
'server_metadata_url': 'https://accounts.google.com/.well-known/openid_configuration',
'client_kwargs': {'scope': 'openid email profile'}
}
}]Multi-tier caching system configuration for performance optimization.
# Cache Backend Configuration
CACHE_CONFIG: Dict[str, Any] = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 300,
'CACHE_KEY_PREFIX': 'superset_',
'CACHE_REDIS_HOST': 'localhost',
'CACHE_REDIS_PORT': 6379,
'CACHE_REDIS_DB': 1,
'CACHE_REDIS_URL': 'redis://localhost:6379/1'
}
# Data Cache Configuration
DATA_CACHE_CONFIG: Dict[str, Any] = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 86400, # 24 hours
'CACHE_KEY_PREFIX': 'superset_data_',
'CACHE_REDIS_URL': 'redis://localhost:6379/2'
}
# Filter State Cache
FILTER_STATE_CACHE_CONFIG: Dict[str, Any] = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 86400,
'CACHE_REDIS_URL': 'redis://localhost:6379/3'
}
# Explore Form Data Cache
EXPLORE_FORM_DATA_CACHE_CONFIG: Dict[str, Any] = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 604800, # 7 days
'CACHE_REDIS_URL': 'redis://localhost:6379/4'
}
# Cache Warmup Settings
CACHE_WARMUP_CHART_DATA: bool = True
CACHE_WARMUP_DASHBOARD_DATA: bool = TrueUsage Examples:
# Memcached configuration
CACHE_CONFIG = {
'CACHE_TYPE': 'memcached',
'CACHE_MEMCACHED_SERVERS': ['127.0.0.1:11211'],
'CACHE_DEFAULT_TIMEOUT': 300
}
# Filesystem cache
CACHE_CONFIG = {
'CACHE_TYPE': 'filesystem',
'CACHE_DIR': '/tmp/superset_cache',
'CACHE_DEFAULT_TIMEOUT': 300
}Dynamic feature toggling system for experimental and optional functionality.
# Default Feature Flags
DEFAULT_FEATURE_FLAGS: Dict[str, bool] = {
'ENABLE_TEMPLATE_PROCESSING': True,
'ALERT_REPORTS': False,
'DASHBOARD_NATIVE_FILTERS': True,
'DASHBOARD_CROSS_FILTERS': False,
'EMBEDDED_SUPERSET': False,
'ESCAPE_MARKDOWN_HTML': False,
'ESTIMATE_QUERY_COST': False,
'GENERIC_CHART_AXES': False,
'LISTVIEWS_DEFAULT_CARD_VIEW': False,
'SQLLAB_BACKEND_PERSISTENCE': True,
'THUMBNAILS': False,
'DYNAMIC_PLUGINS': False,
'DRILL_TO_DETAIL': False,
'DRILL_BY': False
}
# Custom Feature Flags
FEATURE_FLAGS: Dict[str, bool] = {}
# Dynamic Feature Flag Function
GET_FEATURE_FLAGS_FUNC: Optional[Callable[[Dict[str, bool]], Dict[str, bool]]] = NoneUsage Examples:
# Enable specific features
FEATURE_FLAGS = {
'ALERT_REPORTS': True,
'THUMBNAILS': True,
'EMBEDDED_SUPERSET': True
}
# Dynamic feature flags based on user
def get_feature_flags(ff):
"""Customize feature flags based on context."""
from flask import g
if hasattr(g, 'user') and g.user.is_admin:
ff['EXPERIMENTAL_FEATURE'] = True
return ff
GET_FEATURE_FLAGS_FUNC = get_feature_flagsSettings for query execution limits, row limits, and performance tuning.
# Query Execution Limits
ROW_LIMIT: int = 50000
VIZ_ROW_LIMIT: int = 10000
SAMPLES_ROW_LIMIT: int = 1000
SQL_MAX_ROW: int = 100000
# Time Limits
SUPERSET_WEBSERVER_TIMEOUT: int = 60
SQLLAB_TIMEOUT: int = 300
SQLLAB_ASYNC_TIME_LIMIT_SEC: int = 600
# Dashboard Settings
SUPERSET_DASHBOARD_POSITION_DATA_LIMIT: int = 65535
DASHBOARD_AUTO_REFRESH_MODE: str = "fetch"
DASHBOARD_AUTO_REFRESH_INTERVALS: List[Tuple[int, str]] = [
(0, "Don't refresh"),
(10, "10 seconds"),
(30, "30 seconds"),
(60, "1 minute"),
(300, "5 minutes")
]
# Chart Data Settings
SUPERSET_CELERY_FLOWER_TIMEOUT: int = 60
RESULTS_BACKEND_USE_MSGPACK: bool = True
GLOBAL_ASYNC_QUERIES_TRANSPORT: str = "polling"Email server settings and alert system configuration.
# Email Configuration
SMTP_HOST: str = "localhost"
SMTP_STARTTLS: bool = True
SMTP_SSL: bool = False
SMTP_USER: str = "superset"
SMTP_PORT: int = 25
SMTP_PASSWORD: str = "superset"
SMTP_MAIL_FROM: str = "superset@superset.com"
# Alert Manager Configuration
ALERT_REPORTS_NOTIFICATION_DRY_RUN: bool = False
ALERT_REPORTS_WORKING_TIME_OUT_KILL: bool = True
ALERT_REPORTS_WORKING_TIME_OUT_LAG: int = 3600
ALERT_REPORTS_WORKING_SOFT_TIME_OUT_LAG: int = 1800
# Webdriver Configuration for Screenshots
WEBDRIVER_BASEURL: str = "http://superset:8088/"
WEBDRIVER_BASEURL_USER_FRIENDLY: str = "http://localhost:8088/"
WEBDRIVER_TYPE: str = "firefox"
WEBDRIVER_OPTION_ARGS: List[str] = [
"--headless",
"--no-sandbox",
"--disable-gpu"
]import os
# Common environment variable patterns
SECRET_KEY = os.environ.get('SUPERSET_SECRET_KEY')
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379/0')
# Feature flags from environment
FEATURE_FLAGS = {
'THUMBNAILS': os.environ.get('SUPERSET_THUMBNAILS', 'False').lower() == 'true'
}# Load configuration from Python module
SUPERSET_CONFIG_PATH: str = "/path/to/superset_config.py"
# Configuration inheritance
from superset.config import * # Load defaults
SECRET_KEY = 'custom-secret-key' # Override specific settingsInstall with Tessl CLI
npx tessl i tessl/pypi-apache-superset