Command Line Interface
Relevant source files
The following files were used as context for generating this wiki page:
The Command Line Interface (CLI) for flext-dbt-oracle-wms serves as the primary entry point for executing data transformation workflows between Oracle WMS and DBT. It acts as an adapter layer that translates user input into calls against the public facade, facilitating discovery, extraction, and full pipeline execution.
The CLI is registered as an executable script via the project's configuration, allowing developers to interact with the Oracle WMS integration directly from the terminal. It leverages a service-based architecture to maintain separation between command handling logic and the underlying business orchestration.
Sources: src/flext_dbt_oracle_wms/cli.py:1-25, pyproject.toml:93-94
Core Architecture
The CLI is implemented using the FlextDbtOracleWmsCliService class. This class follows the adapter pattern, wrapping the FlextDbtOracleWms facade to provide a command-driven interface.
Component Breakdown
- Entry Point: The
mainfunction serves as the system entry point, initializing the service and parsingsys.argv. - Command Dispatcher: The
execute_commandmethod maps string-based commands (e.g., "extract", "pipeline") to internal handler functions. - Service Facade: The
_serviceattribute holds an instance ofFlextDbtOracleWms, which contains the actual logic for interacting with Oracle WMS and DBT.
The following class diagram illustrates the relationship between the CLI service and the core API:
Command Reference
The CLI supports a set of specific commands to manage the data lifecycle. Each command returns a standard shell exit code: 0 for success and 1 for failure.
| Command | Description | Default Arguments |
|---|---|---|
info | Displays basic package information. | N/A |
discover | Identifies available entities within the Oracle WMS environment. | N/A |
extract | Fetches data for a specific entity from Oracle WMS. | entity="inventory" |
pipeline | Executes the full Oracle WMS to DBT transformation workflow. | run_transformations=True |
Sources: src/flext_dbt_oracle_wms/cli.py:46-56, src/flext_dbt_oracle_wms/cli.py:89-98
Command Execution Flow
When a command is invoked, the CLI follows a structured execution path from argument parsing to result handling.
Implementation Details
Data Extraction Logic
The extract command handles optional entity arguments. If no entity is provided, it defaults to "inventory". The service uses a string adapter to validate the input before passing it to the facade.
# src/flext_dbt_oracle_wms/cli.py:69-87
def handle_extract(
self,
args: t.MappingKV[str, t.JsonValue | None] | None = None,
) -> p.Result[str]:
"""Handle extract command."""
entity = self._default_entity
if args is not None:
entity_value = args.get("entity")
try:
validated_entity = (
t.str_adapter().validate_python(entity_value).strip()
)
except c.ValidationError:
validated_entity = ""
if validated_entity:
entity = validated_entity
result = self._service.extract_oracle_wms_data(entity, None)
if result.failure:
return r[str].fail(result.error or "Extract failed")
return r[str].ok("Extraction completed successfully")
Pipeline Execution
The pipeline command triggers the run_oracle_wms_to_dbt_workflow method. In the CLI context, it is configured by default to skip model generation (generate_models=False) and focus on running transformations (run_transformations=True).
Sources: src/flext_dbt_oracle_wms/cli.py:91-98, src/flext_dbt_oracle_wms/_simple_api_workflow.py:32-40
Integration with Domain Clients
The CLI commands eventually resolve to operations performed by the FlextDbtOracleWmsClient. This client manages the integration with both the Oracle WMS domain (via flext-oracle-wms) and the DBT environment (via flext-meltano).
Conclusion
The Command Line Interface provides a robust and standardized way to operate the flext-dbt-oracle-wms package. By abstracting complex workflow orchestration into a simple set of commands (info, discover, extract, pipeline), it allows for both manual operational tasks and automated scheduling within a data engineering ecosystem.