dbt Execution Client
Relevant source files
The following files were used as context for generating this wiki page:
The dbt Execution Client is a specialized service component within the flext-dbt-ldif project designed to orchestrate the lifecycle of LDIF (LDAP Data Interchange Format) data transformation. It provides a typed interface for parsing raw LDIF files, validating data quality, and executing dbt (data build tool) transformations to convert hierarchical LDAP data into structured relational models for analytics.
The client operates as a mixin-based service, primarily exposed through the FlextDbtLdifClient.Client class. It serves as the bridge between raw data ingestion and the generation of staging and analytics models, ensuring that data meets quality thresholds before being processed by the dbt engine.
Sources: src/flext_dbt_ldif/services/client.py:12-14, src/flext_dbt_ldif/api.py:27-33
Core Architecture and Components
The client is structured as a nested class within the FlextDbtLdifClient mixin. This architecture allows it to be composed into the main FlextDbtLdif facade alongside other services like model generation and core utility mixins.
Component Breakdown
| Component | Responsibility | Source File |
|---|---|---|
FlextDbtLdifClient.Client | Primary execution logic for parsing, validation, and transformation. | client.py:15 |
FlextDbtLdifSettings | Configuration provider for file paths and quality thresholds. | client.py:19 |
FlextDbtLdifServiceMixin | Orchestrator that utilizes the client within broader workflows. | service.py:18 |
FlextDbtLdif Facade | Public entry point that delegates calls to the underlying client service. | api.py:38 |
Operational Flow Diagram
The following diagram illustrates the standard pipeline execution flow within the Client, moving from raw file input to finalized transformation metadata.
Key Functions and Logic
LDIF Parsing
The parse_ldif_file method handles the ingestion of LDIF data. It utilizes path information from either method arguments or global settings.
- Input: Optional
file_path(Path or string). - Behavior: Validates the existence of a target path and returns a sequence of parsed entries as JSON mappings.
Sources: src/flext_dbt_ldif/services/client.py:27-40
Data Quality Validation
The validate_ldif_data function ensures the integrity of ingested records before expensive dbt operations occur.
- Logic: Checks for empty entry sets and compares the calculated quality score against the
min_quality_thresholddefined in settings. - Result: Returns a
LdifValidationResultcontaining the entry count and avalidation_status.
Sources: src/flext_dbt_ldif/services/client.py:93-111, tests/unit/test_dbt_client.py:47-64
dbt Transformation Execution
The transform_with_dbt method manages the execution of dbt models against the validated entries.
- Default Models: If no specific
model_namesare provided, it defaults to executing both staging and analytics models. - Metadata: Returns a
DbtTransformationResultdetailing the number of records processed and the specific models involved.
Sources: src/flext_dbt_ldif/services/client.py:73-89, tests/unit/test_dbt_client.py:68-80
Pipeline Orchestration
The client provides a run_full_pipeline method that executes the entire sequence (Parse -> Validate -> Transform) in a single transactional block. This is often used by the higher-level FlextDbtLdif facade to process files end-to-end.
Sequence of Operation
Configuration and Implementation
The client relies on the FlextDbtLdifSettings object to determine its behavior. Key settings include:
ldif_file_path: The default location for LDIF files if not specified during the call.min_quality_threshold: The minimum score (typically normalized to 1.0) required to proceed with transformation.
# Implementation Example from Client Class
def __init__(self, settings: FlextDbtLdifSettings | None = None) -> None:
"""Initialize client with explicit or global settings."""
self.settings = (
settings
if settings is not None
else FlextDbtLdifSettings.fetch_global()
)
Sources: src/flext_dbt_ldif/services/client.py:18-25, src/flext_dbt_ldif/services/service.py:27-39
The dbt Execution Client ensures that LDIF data transformations are predictable and maintainable by encapsulating the complexities of file handling and dbt orchestration into a single, testable service unit.
Sources: tests/unit/test_dbt_client.py:1-93, src/flext_dbt_ldif/services/client.py:1-112