A modular, production-ready data engineering pipeline built with Python. Designed for ML data preparation workflows with built-in validation, deduplication, quality filtering, and monitoring.
data_pipeline/
├── config.py # PipelineConfig (env-driven via Pydantic BaseSettings)
├── schemas.py # Data contracts (Pydantic + Pandera)
├── stages.py # Pipeline stages (Ingest → Validate → Transform → Dedup → Quality → Load)
├── monitoring.py # Structured JSON logging + metrics + alerts
├── runner.py # Pipeline orchestrator with checkpointing
└── main.py # CLI entry point
1 pip install pydantic pydantic-settings pandera tenacity pandas pyarrow datasets huggingface_hub
2 # Optional for near-dedup:
3 pip install datasketch
1 # Run with generated sample data
2 python -m data_pipeline.main --demo --demo-size 200
3
4 # Run with custom data
5 python -m data_pipeline.main --source data/raw/ --output data/processed/
6
7 # Push to HF Hub
8 python -m data_pipeline.main --source data/raw/ --output-format hf_hub --hf-repo myorg/clean-dataset
1 export PIPELINE_SOURCE_PATH = data/raw/
2 export PIPELINE_OUTPUT_PATH = data/processed/
3 export PIPELINE_OUTPUT_FORMAT = parquet
4 export PIPELINE_MIN_TEXT_LENGTH = 50
5 export PIPELINE_MIN_QUALITY_SCORE = 0.5
6 export PIPELINE_DEDUP_ENABLED = true
7 export PIPELINE_LOG_LEVEL = INFO
1 from data_pipeline import PipelineConfig , PipelineRunner
2 import pandas as pd
3
4 # Configure
5 config = PipelineConfig (
6 source_path = "data/raw/" ,
7 output_path = "data/processed/" ,
8 output_format = "parquet" ,
9 min_quality_score = 0.6 ,
10 dedup_enabled = True ,
11 )
12
13 # Run
14 runner = PipelineRunner ( config )
15 output_data , metrics = runner . run ( )
16
17 # Check results
18 print ( f"Status: { metrics . status } " )
19 print ( f"Records: { metrics . total_records_in } → { metrics . total_records_out } " )
20 print ( f"Duration: { metrics . total_duration_seconds : .1f } s" )
1 from data_pipeline . stages import PipelineStage
2 from data_pipeline . config import PipelineConfig
3 import pandas as pd
4
5 class MyCustomStage ( PipelineStage ) :
6 def __init__ ( self , config : PipelineConfig ) :
7 super ( ) . __init__ ( "my_custom_stage" , config )
8
9 def process ( self , data : pd . DataFrame ) - > pd . DataFrame :
10 # Your logic here
11 data [ "new_column" ] = data [ "text" ] . str . len ( )
12 return data
13
14 # Add to pipeline
15 runner = PipelineRunner ( config )
16 runner . stages . insert ( 3 , MyCustomStage ( config ) ) # Insert after transform
17 output , metrics = runner . run ( input_data = df )
1 {
2 "timestamp" : "2024-01-15T10:30:00Z" ,
3 "level" : "INFO" ,
4 "logger" : "pipeline.transform" ,
5 "message" : "Stage complete" ,
6 "metrics" : {
7 "stage_name" : "transform" ,
8 "records_in" : 1000 ,
9 "records_out" : 1000 ,
10 "pass_rate" : 1.0 ,
11 "duration_seconds" : 2.3
12 }
13 }
1 pip install pytest
2 pytest tests/ -v
This model repository was generated by
ML Intern , an agent for machine learning research and development on the Hugging Face Hub.