Building Data Pipelines That Don't Fall Apart
Ask any team that has shipped an AI system and later tried to retrain or update it, and you will hear a familiar story: the first version worked because someone spent three weeks manually wrangling data in notebooks. Nobody wrote down exactly what they did. Six months later, when the model needs retraining, that knowledge is half-remembered, half-lost, and the whole process starts over from scratch.
The fix is not heroics. It is the pipeline design.
Two Pipelines With Two Different Jobs.
CPMAI splits data preparation into two distinct pipelines, and it's worth being precise about what each one is for.
The Training Data Pipeline.
Gathers, cleans, formats, and labels the historical data used to build and periodically retrain your model. It runs in batches, it can afford to be slower and more thorough, and it is where most of your labeling and quality work happens.
The Inference Data Pipeline.
Handles the ongoing, live flow of new production data — the data your model sees after it is deployed, in real time or near-real time. It needs to be fast, reliable, and consistent, because any hiccup here directly affects what your users or downstream systems experience.
The trap is building these two pipelines independently, with different logic for cleaning and transforming data. If training data gets standardised one way and production data gets standardised another, your model ends up evaluated on one thing and used on another — a mismatch known as training-serving skew. Wherever possible, share transformation logic between the two pipelines rather than reimplementing it twice.
Pipeline Architecture Differs by Data Type.
Structured and unstructured data do not just need different cleaning rules — they typically need different storage and processing architecture entirely.Structured Data Pipelines.
Usually follow a familiar ETL/ELT pattern into a data warehouse, with schema enforcement applied on the way in and validation checks that are relatively cheap to run (type checks, range checks, referential integrity).Unstructured Data Pipelines.
More often land in a data lake or object storage first, then pass through a preprocessing stage specific to the data type — OCR for scanned documents, speech-to-text for audio, tokenisation for text, resizing and normalisation for images — before any meaningful quality check is even possible. Many unstructured pipelines also generate embeddings and store them in a vector database, which structured pipelines rarely need.
If your project touches both — which most do — plan for two parallel processing paths that converge at a common feature store or training dataset, rather than forcing unstructured data through tooling built for tables.What Repeatable Actually Means.
A repeatable data pipeline is not just one that runs more than once. It has a few specific properties:Version-controlled, Parameterised Code.
Not a notebook someone runs manually and tweaks each time. If your cleaning logic lives only in a data scientist's head or in ad hoc cell edits, it is not repeatable.Idempotency.
Running the pipeline twice on the same input should produce the same output. This sounds obvious until you have been burned by a pipeline that silently duplicates records on reruns.Config-driven Rules.
Cleaning and transformation rules should live in configuration, not be hard-coded, so a business rule change does not require a code rewrite and redeploy.Automated Tests at Each Stage.
Schema validation, row-count sanity checks, null-rate checks. Treat your data pipeline with the same testing discipline you would apply to application code.Clear Ownership and Documentation.
Someone should be able to pick up the pipeline a year from now and understand what each step does and why.Tooling Worth Knowing About.
You do not need to build all of this from scratch. Common building blocks include:Orchestration.
Airflow, Dagster, Prefect, or your cloud provider's managed equivalent, for scheduling and sequencing pipeline steps.Transformation.
dbt for SQL-based transformations, or standard Python/Spark jobs for more complex logic.Data Quality Checks.
Great Expectations or Deequ, which let you codify “this column should never be null” or “this value should be within this range” as automated testsThe specific tools matter less than the discipline they represent: pipelines as code, not pipelines as institutional memory.
Clear Ownership and Documentation.
Someone should be able to pick up the pipeline a year from now and understand what each step does and why. That standard sounds obvious until you actually try to meet it — most undocumented pipelines fail this test the moment the person who built them changes teams, and by then it's an expensive problem to fix.
What Documentation Should Include.
Someone should be able to pick up the pipeline a year from now and understand what each step does and why.Purpose and Business Context.
Why this pipeline exists and what model or decision it feeds — not just what the code does, but why it matters.Source Inventory.
Every data source the pipeline touches, its owner, its schema, its refresh cadence, and how it's accessed.Step-by-step Transformation Logic.
What each stage does and, critically, why — the reasoning behind a cleaning rule or threshold is often more valuable than the rule itself.Dependency Map.
What feeds into this pipeline, and what downstream systems or models depend on its output.Known Failure Modes and a Runbook.
Someone should be able to pick up the pipeline a year from now and understand what each step does and why.Escalation Contacts.
Who to contact when something breaks and the standard fix doesn't apply.Change Log.
What changed, when, and why — so anyone investigating an issue can see what was different last week.Who Creates It, and How.
The engineer(s).
- who build and maintain the pipeline own the documentation. It's part of “done,” not a follow-up task — a pipeline isn't considered complete until its documentation is.Domain Experts.
- review the business-context sections for accuracy, since engineers can document what the code does but not always why a business rule exists.A Team or Tech Lead.
- signs off before the pipeline goes into production, the same way code gets reviewed — documentation quality is part of the definition of done, not an optional extra.
Treat Documentation as Code.
Store it in the same repository as the pipeline, version it alongside code changes, and update it in the same pull request that changes the logic it describes — not in a separate wiki that quietly drifts out of date.Auto-generate What You Can.
Schema documentation from code or config, and lineage diagrams from your orchestration tool, are more reliable and far less effort than hand-maintained equivalents.Use one consistent template across every pipeline in the organization.
So anyone can find the same information in the same place regardless of which pipeline they're reading.Suggested Ownership & Responsibility Format (RACI).
| Pipeline Component | Owner | Contact | Last Reviewed | Criticality / SLA |
|---|---|---|---|---|
| Training data ingestion | Data Engineering — J. Alvarez | #data-eng-support | 2026-06-01 | High — blocks retraining |
| CRM source connector | Data Engineering — T. Bruice | #data-eng-support | 2026-05-15 | Medium — daily refresh |
| Inference feature pipeline | MLOps — R. Chen | #mlops-oncall | 2026-06-10 | Critical — production-facing |
| Third-party enrichment feed | Vendor Management — S. Davidson | vendor-support@example.com | 2026-04-20 | Medium — weekly refresh |
SOPs Worth Writing.
A small set of standard operating procedures, each following the same simple structure — trigger, steps, roles involved, escalation path, related docs — covers most of what a team needs:Onboarding a New Data Source.
How to profile it, document it, assign an owner, and add it to the pipeline without disrupting existing sourcesResponding to a Pipeline Failure Alert.
First diagnostic steps, who's on call, and when to escalate versus resolve independently.Handling an Upstream Schema Change.
How to confirm the change, assess impact, update validation rules, and communicate the fix.Rotating Pipeline Ownership.
A checklist for handing off a pipeline when someone changes teams or leaves, so ownership never silently lapses.Running a Scheduled Retrain or Pipeline Refresh.
The standard sequence of checks before and after a run, so retraining does not depend on one person's memory of how we usually do this.None of this needs to be elaborate. A one-page SOP that s actually followed beats a comprehensive one that lives in a folder nobody opens.
Design for Change.
Plan for it up front: your data sources will change. APIs get new fields. Upstream systems get migrated. Third-party vendors update their schemas without much warning. A well-designed pipeline treats this as an expected event, not an emergency — with schema validation that catches unexpected changes early, and enough modularity that fixing one broken source does not mean rebuilding the whole pipeline.A few concrete practices make that resilience real, rather than aspirational:
Modularize By Source.
Give each data source its own ingestion and transformation component, with a clearly defined interface to the rest of the pipeline. When one source breaks or changes, you fix or swap that module — you do not touch, retest, or risk the modules handling everything else.Validate Against a Schema Contract at Every Ingestion Point.
Define the expected schema for each source explicitly, and check incoming data against it before it moves further downstream. A record that does not match should fail loudly and immediately, not silently propagate three transformations later where it is far harder to trace back.Build Monitoring in From Day One, Not After the First Incident.
Track schema drift, null-rate shifts, volume anomalies, and latency for every source in real time, and alert the named owner the moment a source starts behaving differently — not the following week when someone notices the model acting strangely.Version Schemas and Pipeline Logic Together.
Keep a record of what the expected schema looked like at each point in time, alongside the pipeline code that assumed it. When an upstream change breaks something, you can roll back cleanly and know exactly what changed and when.Design Graceful Degradation, Not Just Failure.
Decide in advance what the pipeline should do when a source is unavailable or malformed — skip the record, fall back to last-known-good data, or flag it for manual review — so one bad source does not take down the whole pipeline run.Treat Upstream Owners and Vendors as a Dependency to Manage, Not a Black Box.
Know who to contact when a source changes, subscribe to API changelogs or deprecation notices where they exist, and build advance-notice expectations into third-party contracts wherever you can.Resilience matters more once your model is in production.