liveBook · Manning

Data ingestion

As explained in Distributed Machine Learning Patterns

Data ingestion is the process of acquiring, importing, and preparing data for downstream computation or analysis.

Data ingestion is the first operational stage of a machine-learning pipeline: it monitors a source, consumes data in batch or streaming form, and preprocesses it for model training. Its design determines whether downstream training can start reliably as datasets grow, change, or exceed the capacity of one machine. section 2.1 section 1.3.1

Start by characterizing the dataset and its operating context: where it came from, how it was collected, whether its source or size changes, and what infrastructure is needed to handle it. Distributed ingestion needs this assessment because large datasets introduce design constraints beyond a local-machine workflow. section 2.1

Choose the ingestion mode from how the dataset changes:

  • Use streaming ingestion for data that grows over time; run long-lived processes that monitor source changes and continuously consume incoming data. section 2.1
  • Use nonstreaming ingestion for a fixed dataset; run offline batch jobs on demand to process it. section 2.1

Scale nonstreaming pipelines with complementary patterns. Batch data into memory-sized units when a framework cannot handle the full dataset at once. Shard an extremely large dataset into smaller pieces across worker machines to accelerate training as workers are added. Cache previously fetched data when several training rounds reuse the same dataset. section 2.0 section 2.10

Fashion-MNIST ingestion workflow

A workflow downloads and preprocesses Fashion-MNIST before distributed training, then stores the dataset on a persistent volume. The ingestion script can load the dataset with tfds.load(name='fashion_mnist'); later training steps read the persisted data. The dataset has 60,000 training examples and 10,000 test examples, each a 28 × 28 grayscale image with one of 10 labels. section 9.1 section 9.4.1

Avoid repeating costly ingestion when the underlying data is still fresh. Step memoization can skip the ingestion step, while a time-based cache records the ingested dataset location and last-update timestamp. If data changes, ingest again; otherwise, route training to the cached dataset. Persisted data also matters during recovery: if training fails after in-memory data is lost, ingestion must run again before retrying training. section 7.5.2 section 6.3.2

Table 2.1 Comparison of streaming and nonstreaming data ingestion in machine learning applications (view table figure)

 

Streaming data ingestion

Nonstreaming data Ingestion

Dataset size

Increases over time

Fixed size

Infrastructure requirements

Long-running processes to monitor the changes in data source

Offline batch jobs to process datasets on demand

Compare the changing-data and fixed-data cases to select a long-running monitoring process or an on-demand offline batch job. section 2.1

Figure 7.16 The workflow has been triggered. We check whether the data has been updated within the last two weeks by accessing the cache. If the data is fresh, we can skip the unnecessary data ingestion step and execute the model training step directly.
07-16

Follow a cache-based decision flow that skips ingestion when the dataset remains fresh and starts training from the stored dataset. section 7.5.2

How Distributed Machine Learning Patterns covers it

How deep it goes
Defines streaming and nonstreaming modes, then develops batching, sharding, caching, workflow skipping, and a TensorFlow implementation.
Examples
Uses Fashion-MNIST, TensorFlow dataset loading, persistent-volume storage, and time-based cache freshness checks.
What it assumes
Assumes familiarity with machine-learning pipelines and introduces ingestion through dataset behavior, processing modes, and operational patterns.
What you can do after
Build it from scratch as a TensorFlow ingestion step that downloads, preprocesses, persists, and conditionally reuses training data.
How it connects
Connects batching, sharding, caching, step memoization, model training, persistent volumes, and workflow failure recovery.

Also explained in

Compare how 6 books explain data ingestion →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Distributed Machine Learning Patterns. The section links point to the parts of the book it draws on.