Core Service Module
Relevant source files
The following files were used as context for generating this wiki page:
- src/flext_dbt_ldif/services/core.py
- src/flext_dbt_ldif/services/service.py
- src/flext_dbt_ldif/services/unified_service.py (Inferred from reference in
service.py) - tests/unit/test_core.py
- tests/unit/test_services.py
- README.md
The Core Service Module provides the foundational orchestration and logic for transforming LDIF (LDAP Data Interchange Format) data into dbt models. It serves as the primary integration layer within the flext-dbt-ldif project, coordinating file parsing, data validation, metadata generation, and the execution of dbt transformations.
The module is structured to handle enterprise-grade data transformation workflows, ensuring that raw LDIF entries are processed through distinct staging and analytics layers. This architectural approach allows for standardized reporting and insight generation from complex directory service data.
Sources: README.md:9-11, src/flext_dbt_ldif/services/service.py:16-18
Architecture and Orchestration
The module employs a service-oriented architecture centered around the FlextDbtLdifServiceMixin.Service class. This class acts as a facade, delegating specific responsibilities to specialized internal components like the FlextDbtLdifClient for external interactions and the UnifiedService for model generation logic.
The diagram illustrates the dependency structure where the main Service orchestrates the Client and UnifiedService components.
Sources: src/flext_dbt_ldif/services/service.py:32-47, src/flext_dbt_ldif/services/core.py:11-13
Component Responsibilities
| Component | Responsibility |
|---|---|
FlextDbtLdifServiceMixin.Service | Main entry point for workflow orchestration and public API surface. |
FlextDbtLdifClient.Client | Handles low-level LDIF file parsing, validation, and calling dbt commands. |
FlextDbtLdifUnifiedService.UnifiedService | High-level generator that produces dbt model metadata for staging and analytics. |
FlextDbtLdifCore.Core | Internal namespace providing basic analytics and static model metadata. |
| Sources: src/flext_dbt_ldif/services/service.py:22-48, src/flext_dbt_ldif/services/core.py:14-16 |
Workflow Execution
The core logic is encapsulated in the run_complete_workflow method, which executes a linear pipeline from raw file input to completed dbt transformation.
Sequence of operations required to process a directory data file into dbt-ready structures.
Sources: src/flext_dbt_ldif/services/service.py:100-145, tests/unit/test_services.py:140-165
Data Processing Steps
- Parsing: The
FlextDbtLdifClientconverts LDIF format into a sequence of JSON mappings. - Validation: Entries are scanned to produce a
quality_scoreandvalidation_status. - Model Generation:
- Staging Models: Static metadata describing
stg_ldif_entries. - Analytics Models: Static metadata describing
analytics_ldif_insights.
- Staging Models: Static metadata describing
- Transformation: Actual dbt execution against the generated models and validated data.
Sources: src/flext_dbt_ldif/services/service.py:75-98, src/flext_dbt_ldif/services/core.py:27-46
Core Data Structures
The module relies on standardized return types (Results) and configuration settings to maintain consistency across the pipeline.
Analytics and Pattern Analysis
The FlextDbtLdifCore.Core.Analytics helper provides metrics regarding the input data, focusing on entry volume and unique Distinguished Name (DN) counts.
def analyze_entry_patterns(
self,
entries: t.SequenceOf[t.StrMapping],
) -> p.Result[t.JsonMapping]:
"""Analyze input entries and return summary payload."""
return r[t.JsonMapping].ok({
"total_entries": len(entries),
"unique_dns": len({entry.get("dn", "") for entry in entries}),
})
Sources: src/flext_dbt_ldif/services/core.py:48-57, tests/unit/test_core.py:53-70
Workflow Result Payload
When a workflow completes, it returns a WorkflowResult containing the following operational data:
ldif_file: Path to the source file.entry_count: Number of entries found in the file.validation_status: Outcome of the data quality check.workflow_status: Progress status (e.g., "completed").models_generated: Count of dbt model files created during the run.transformation_status: Success/Failure of the dbt run.
Sources: src/flext_dbt_ldif/services/service.py:120-145, tests/unit/test_services.py:180-200
Configuration and Environment
The service is initialized using FlextDbtLdifSettings. If no settings are provided, it fetches the global configuration, which includes the ldif_file_path used as the default project directory.
Sources: src/flext_dbt_ldif/services/service.py:34-42
The Core Service Module effectively decouples the complexities of directory data parsing from the standardized dbt transformation logic. By orchestrating a multi-stage workflow—parsing, validating, and generating metadata—it ensures that enterprise LDIF data is consistently represented in the target database schema for downstream analytics.