Starting the Superset UI
Relevant source files
The following files were used as context for generating this wiki page:
Starting the Superset UI within the Meltano environment is facilitated through a utility extension that wraps the Apache Superset CLI. This extension manages configuration generation, environment preparation, and service invocation, allowing users to launch the Superset development server directly via Meltano commands.
Sources: README.md:1-5, superset_ext/extension.py:24-28, superset_ext/main.py:101-110
Execution Overview
The primary method for launching the Superset User Interface is the ui command defined in the Meltano project configuration. This command utilizes the extension to invoke the underlying superset run command with specific host and port arguments.
Launch Command Flow
The following diagram illustrates how a user request to start the UI travels through the Meltano extension layers to the actual Superset binary.
Configuration and Environment
Before the UI starts, the extension prepares a specialized environment and generates a superset_config.py file. This ensures that Superset uses the metadata database and project paths defined within the Meltano project.
Environment Preparation
The prepared_env function extracts variables prefixed with SUPERSET_ and maps them to standard Superset configuration keys.
| Variable | Default Value / Logic | Description |
|---|---|---|
FLASK_APP | superset | Required by the underlying Flask framework. |
SUPERSET_HOME | $MELTANO_PROJECT_ROOT/.meltano/utilities/superset | Directory for local state and databases. |
SUPERSET_CONFIG_PATH | $MELTANO_PROJECT_ROOT/analyze/superset/superset_config.py | Location of the generated Python config. |
SQLALCHEMY_DATABASE_URI | sqlite:///$SUPERSET_HOME/superset.db | Path to the Superset metadata database. |
Sources: superset_ext/utils.py:61-103, superset_ext/extension.py:34-45
Config File Generation
The UI relies on a generated configuration file. The write_config utility creates a Python script that injects uppercase configuration keys from the environment into the Superset module.
import sys
module = sys.modules[__name__]
config = {'ROW_LIMIT': 42, 'WEBSERVER_PORT': 8088} # Example values
for key, value in config.items():
if key.isupper():
setattr(module, key, value)
Sources: superset_ext/utils.py:127-142
Prerequisites for UI Access
Simply running the UI command is insufficient if the underlying database and permissions are not initialized. The project provides specific initialization steps that must be performed once before the UI can be effectively used.
- Initialize Extension: Creates the config file and runs
superset db upgrade,superset init, andsuperset fab create-permissions. - Create Admin: Establishes the credentials required to log into the UI.
UI Invocation Specifics
The ui command is defined as a shortcut in meltano.yml. It passes through the invoke command of the extension, which specifically targets the superset executable.
- Executable:
superset_invoker(which points tosuperset_ext.pass_through:pass_through_cli). - Default UI Arguments:
invoke run --port 8088 --host 127.0.0.1. - Passthrough Mechanism: Arguments are passed via
sys.argvthrough theSupersetclass invoker, maintaining the environment variables prepared by the EDK.
Sources: README.md:27-28, pyproject.toml:50, superset_ext/pass_through.py:13-18
Summary
Starting the Superset UI via meltano invoke ext_superset:ui triggers a coordinated process of environment mapping and CLI wrapping. By using the superset-ext utility, developers ensure that the Superset webserver is correctly configured to use Meltano-managed paths for its metadata database and configuration scripts, providing a seamless bridge between Meltano data orchestration and Superset visualization.