Production Deployment
Relevant source files
The following files were used as context for generating this wiki page:
Production deployment of the Superset Meltano extension involves configuring the superset-ext utility within a Meltano project to wrap and manage an Apache Superset instance. This extension facilitates environment-driven configuration, database initialization, and administrative user management through the Meltano EDK (Extension Development Kit).
The deployment lifecycle ensures that the Superset environment is correctly mapped from Meltano environment variables to a generated superset_config.py file, enabling consistent behavior across different deployment environments.
Sources: README.md:1-10, superset_ext/extension.py:19-35, pyproject.toml:1-15
Extension Architecture
The extension acts as a wrapper around the standard superset CLI. It uses an Invoker to execute Superset commands while providing a custom management layer for configuration and initialization.
The diagram above shows the relationship between the Meltano CLI, the extension logic, and the underlying Superset binary.
Sources: superset_ext/extension.py:32-40, superset_ext/main.py:22-45, superset_ext/utils.py:61-104
Environment Configuration
Deployment relies on a specific set of environment variables prefixed with SUPERSET_. The extension automatically transforms these into Superset-compatible configuration settings.
Configuration Mapping Logic
The extension trims the SUPERSET_ prefix from environment variables and maps specific Meltano paths to Superset expectations. For example, SUPERSET_CONFIG_PATH is derived from CONFIG_PATH if provided, otherwise defaulting to a path within the project's analyze directory.
| Meltano/Env Key | Superset Configuration Key | Default Production Value |
|---|---|---|
SUPERSET_HOME | HOME | $MELTANO_PROJECT_ROOT/.meltano/utilities/superset |
SUPERSET_CONFIG_PATH | Internal Path | $MELTANO_PROJECT_ROOT/analyze/superset/superset_config.py |
SQLALCHEMY_DATABASE_URI | SQLALCHEMY_DATABASE_URI | sqlite:///{HOME}/superset.db |
SUPERSET_SECRET_KEY | SECRET_KEY | (Must be set via meltano config) |
Sources: superset_ext/utils.py:61-104, README.md:25-30
Initialization Sequence
Before the Superset UI can be served in production, the extension must perform a multi-step initialization process. This is triggered via the initialize command.
This sequence ensures the database schema is up-to-date and all internal Flask-AppBuilder (FAB) permissions are generated.
Sources: superset_ext/extension.py:53-100, superset_ext/utils.py:107-147
Implementation Details: _write_config
The _write_config function (found in superset_ext/extension.py:42-51 and superset_ext/utils.py:107-147) dynamically generates a Python script. It iterates through the filtered environment configuration and uses setattr on the module level for any keys that are uppercase, effectively injecting the Meltano configuration into the Superset runtime.
Deployment Commands
Production workflows involve specific commands defined in the meltano.yml or executed via the superset_extension entry point.
Administrative Setup
Creating an admin user is a critical post-initialization step. The extension wraps the fab create-admin command:
meltano invoke ext_superset:create-admin --username=admin --firstname=admin --lastname=admin --email=admin@admin --password=password
Sources: README.md:58-60, superset_ext/main.py:48-78
UI Execution
The production webserver is typically started using the ui command, which maps to superset_invoker:
commands:
ui:
args: invoke run --port 8088 --host 127.0.0.1
executable: superset_extension
Sources: README.md:21-22, superset_ext/main.py:81-93
Passthrough Mechanism
For advanced production maintenance, the extension provides a passthrough invoker. This allows operators to run any standard Superset CLI command (like version or export) through the Meltano environment without custom extension logic.
# superset_ext/pass_through.py:14-22
def pass_through_cli() -> None:
"""Pass through CLI entry point."""
pass_through_logging_config()
ext = Superset()
ext.pass_through_invoker(
structlog.getLogger("superset_invoker"),
*sys.argv[1:] if len(sys.argv) > 1 else []
)
Sources: superset_ext/pass_through.py:14-22, pyproject.toml:57
Summary
Production deployment of meltano-superset-ext focuses on automating the bridge between Meltano's environment-based configuration and Superset's file-based configuration. By utilizing the initialize and create-admin commands, teams can ensure that the underlying database, permissions, and security keys are correctly provisioned before the webserver starts.