liveBook · Manning

Partial application

As explained in Data Pipelines with Apache Airflow, Second Edition

partial() is an Airflow task-mapping method that specifies operator parameters kept constant across mapped task instances.

Partial application configures the parameters that remain constant while Dynamic Task Mapping creates separate task instances for changing values. In Airflow, partial() holds fixed operator arguments, including task_id, while expand() supplies the values to map over. section 12.1.8

Map addition over several values

PythonOperator.partial(task_id="add", python_callable=add_function, op_kwargs={"y": 10}).expand(op_args=[[1], [2], [3]]) keeps y constant and creates three mapped task instances with different x values.

Process ratings returned at runtime

PythonOperator.partial(task_id="print_rating", python_callable=_print_rating).expand(op_args=fetch_ratings.output) maps one printing task over every rating returned by fetch_ratings, allowing independent processing even when the count changes between DAG runs.

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Defines the parameter split and demonstrates PythonOperator syntax, but does not explain implementation internals.
Examples
Uses mapped addition and movie-review processing driven by fetch_ratings output.
What you can do after
Apply it via Airflow Dynamic Task Mapping to generate independently processed tasks from runtime outputs.
How it connects
Connects partial() with Dynamic Task Mapping, expand(), PythonOperator, task instances, and Taskflow API.

Also explained in

Compare how 10 books explain partial application →

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.