CLI Entrypoints
Relevant source files
The following files were used as context for generating this wiki page:
The CLI Entrypoints represent the primary interface for interacting with the Meltano Superset extension. Built using the typer library and the Meltano Extension Developer Kit (EDK), these entrypoints allow users to initialize the Superset environment, manage administrative users, and invoke the underlying Superset CLI commands directly through Meltano.
The system defines two distinct script entrypoints: superset_extension, which handles extension-specific management tasks, and superset_invoker, which provides a direct passthrough to the underlying Superset binary.
Sources: pyproject.toml:53-55, superset_ext/main.py:16-25, superset_ext/pass_through.py:12-20
Script Definitions
The project configures its CLI entrypoints using Poetry's script functionality. These scripts map shell commands to specific Python functions within the codebase.
| Script Name | Target Function | Purpose |
|---|---|---|
superset_extension | superset_ext.main:app | Main Typer application providing lifecycle commands (init, create-admin, describe). |
superset_invoker | superset_ext.pass_through:pass_through_cli | Lightweight shim for direct passthrough to the Superset CLI. |
Sources: pyproject.toml:53-55
Primary Extension CLI (superset_extension)
The superset_extension entrypoint is the main management interface. It is implemented as a typer.Typer application that wraps an instance of the Superset extension class.
Initialization Flow
The initialize command sets up the Superset environment. This includes generating the superset_config.py file, running database migrations, and setting up permissions.
The initialization process utilizes an Invoker to execute sub-commands on the underlying superset binary.
Sources: superset_ext/main.py:28-40, superset_ext/extension.py:47-92
Administrative Management
The create-admin command provides a structured way to add admin users to the Superset instance. It supports both interactive prompts and CLI options.
| Option | Default | Description |
|---|---|---|
--username | admin | Username for the admin account. |
--firstname | admin | First name for the admin account. |
--lastname | user | Last name for the admin account. |
--email | admin@superset | Email address for the admin account. |
--password | None | Password (supports hidden input and confirmation prompt). |
Sources: superset_ext/main.py:43-78, superset_ext/extension.py:94-122
Extension Introspection
The describe command leverages the Meltano EDK to output the capabilities of the extension in various formats (e.g., text or JSON). This is used by Meltano to understand what commands the utility supports.
Sources: superset_ext/main.py:100-112, superset_ext/extension.py:141-168
Passthrough CLI (superset_invoker)
The superset_invoker provides a direct communication path to the superset binary. It is designed to be used as the default executable in a meltano.yml configuration.
The passthrough mechanism ensures that any standard Superset CLI command can be executed without explicit wrapper commands in the extension.
Sources: superset_ext/pass_through.py:12-20, superset_ext/extension.py:124-139, README.md:14-16
Logging and Configuration Context
All CLI entrypoints share a common logging and environment preparation logic. The main callback in superset_ext/main.py configures logging based on environment variables like LOG_LEVEL and MELTANO_LOG_JSON.
Before any command is executed, the extension prepares the environment by:
- Loading variables with the
SUPERSET_prefix. - Trimming the prefix for internal use.
- Setting default paths for
SUPERSET_HOMEandSUPERSET_CONFIG_PATHbased on theMELTANO_PROJECT_ROOT.
Sources: superset_ext/main.py:115-139, superset_ext/utils.py:53-91
Summary
The CLI Entrypoints provide a dual-layered interface for the Superset extension. The superset_extension script handles complex lifecycle management (initialization, admin creation), while the superset_invoker ensures full compatibility with the native Superset CLI. Together, they allow the utility to be seamlessly integrated into Meltano projects while maintaining the flexibility of the original tool.