liveBook · Manning

Factory

As explained in Data Pipelines with Apache Airflow, Second Edition

A factory function is a function that accepts configuration and constructs recurring workflow structures such as tasks or DAGs.

A factory function accepts configuration and constructs recurring Airflow task structures or complete DAGs. It suits related data sources that share fetch, preprocessing, and export steps while differing in paths or scripts. section 12.1.5

Use factories to control repetition at two levels:

  • Expose multiple generated DAGs with unique global names; otherwise later objects overwrite earlier ones and Airflow sees only the last instance. section 12.1.5

Sales and customers ingestion

A single DAG loops over sales and customers, passing each dataset to generate_tasks with separate raw, processed, and output directories and a dataset-specific preprocessing script. A DAG factory can instead create separate DAGs such as 02_dag_factory_sales and 02_dag_factory_customers.

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Explains configuration, task dependencies, DAG returns, and unique naming, but does not detail factory testing or deployment.
Examples
Uses sales and customers datasets, API ingestion, BashOperator tasks, dataset-specific paths, preprocessing scripts, and generated DAG names.
What it assumes
Assumes familiarity with basic Airflow DAG elements and teaches configuration-driven repetition through Python functions and loops.
What you can do after
Build it from scratch by parameterizing repeated tasks or DAGs and exposing each generated DAG under a unique global name.
How it connects
Connects factories with DAGs, task dependencies, dynamic task mapping, task groups, and idempotent deterministic workflows.

Also explained in

Compare how 11 books explain factory →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.