Type Definitions
Relevant source files
The following files were used as context for generating this wiki page:
The Meltano Extension Developer Kit (EDK) utilizes a structured set of type aliases, enumerations, and data models to define the interface between Meltano and its extensions. These definitions ensure type safety and consistency across command execution, metadata reporting, and subprocess management.
The type system is designed to support the "Extension" interface, allowing developers to define capabilities, commands, and execution arguments in a standardized format that the Meltano ecosystem can interpret and execute.
Sources: meltano/edk/types.py, meltano/edk/extension.py:27-31
Core Type Aliases and Enums
The EDK defines fundamental types used for process execution and output formatting. The ExecArg type is the primary alias for any argument passed to a subprocess or extension command.
Execution Types
- ExecArg: A type alias defined as
str | bytes, representing the arguments passed during command invocation.
Sources: meltano/edk/types.py:7
Formatting Enumerations
The DescribeFormat enum specifies the supported output formats for the extension's metadata description.
Sources: meltano/edk/extension.py:27-31
| Enum Value | Description |
|---|---|
text | Human-readable pretty-printed format. |
json | Standard JSON representation. |
yaml | Standard YAML representation. |
| Sources: meltano/edk/extension.py:27-33 |
Data Models for Extension Metadata
The EDK uses Python dataclasses to model the structure of an extension's capabilities. These models are returned by the describe() method to inform Meltano of what the extension can do.
Sources: meltano/edk/models.py:1-42
Command Structures
The hierarchy of command models distinguishes between standard extension lifecycle commands and raw pass-through commands.
The diagram above illustrates the relationship between the base Command class and its specialized implementations for extensions and invokers.
Sources: meltano/edk/models.py:6-42
Model Definitions
| Class | Purpose | Default commands |
|---|---|---|
Command | Base class for all runnable commands. | [] |
ExtensionCommand | Describes standard EDK lifecycle commands. | ["describe", "invoke", "pre_invoke", "post_invoke", "initialize"] |
InvokerCommand | Describes a pass-through CLI wrapper. | [":splat"] |
Describe | The container for all commands provided by the extension. | N/A |
| Sources: meltano/edk/models.py:6-42 |
Subprocess and Logging Types
The EDK manages subprocesses through an Invoker class and configures logging via specialized structures to ensure compatibility with Meltano's logging expectations.
Invoker Configuration
The Invoker class handles the execution logic for external binaries, utilizing ExecArg for argument passing.
Sources: meltano/edk/process.py:34-45
- bin: The path or name of the binary to execute.
- cwd: Optional working directory.
- env: Environment variables dictionary.
Sources: meltano/edk/process.py:46-55
Logging Level Mapping
The EDK maps string-based log levels to standard Python logging integers.
Sources: meltano/edk/logging.py:14-20
LEVELS = {
"debug": logging.DEBUG,
"info": logging.INFO,
"warning": logging.WARNING,
"error": logging.ERROR,
"critical": logging.CRITICAL,
}
Sources: meltano/edk/logging.py:14-20
Implementation Example: ExtensionBase
The ExtensionBase abstract base class uses these types to define the required interface for all extensions.
Sources: meltano/edk/extension.py:36-125
class ExtensionBase(metaclass=ABCMeta):
@abstractmethod
def invoke(self, command_name: str | None, *command_args: ExecArg) -> None:
"""Invoke method using ExecArg types."""
pass
@abstractmethod
def describe(self) -> models.Describe:
"""Returns the Describe data model."""
pass
Sources: meltano/edk/extension.py:63-86
The ExtensionBase also provides a describe_formatted method that converts the models.Describe object into the string format requested via DescribeFormat.
Sources: meltano/edk/extension.py:88-111
Summary
The type definitions in the Meltano EDK establish a formal contract for extension development. By leveraging ExecArg for flexible command-line arguments and the Command model hierarchy for capability discovery, the EDK enables a consistent interface for wrapping any CLI tool as a Meltano extension. This structured approach facilitates automated formatting (JSON/YAML) and standardized subprocess handling with integrated logging.