liveBook · Manning

Dependency

As explained in Data Pipelines with Apache Airflow, Second Edition

A software dependency is an external package or component required by software for installation or execution.

A data pipeline may need more than Airflow to run its tasks. An HTTP task can require the Python package requests; a MySQL task can require Python or system-level MySQL components; machine-learning code may need pandas or scikit-learn. These packages and components are software dependencies: requirements of the code that performs the work. section 11.1.2

Do not confuse software dependencies with task dependencies. A task dependency says which task must finish before another can start. In a pipeline that downloads launch data, fetches pictures, and sends a notification, Airflow expresses that ordering with `download_launches >> get_pictures >> notify`. Installing the packages needed by those tasks is a separate concern. section 2.2 section 11.1.2

Where tasks run determines where their software dependencies belong:

  • When operators run tasks directly in Airflow, their dependencies must be installed in both the scheduler and worker environments. Many operators can make those environments difficult to maintain and introduce security risks. section 11.1.2
  • Different DAGs or tasks can require incompatible package versions. A single Python environment cannot install multiple versions of the same package, so such conflicts must be resolved. section 11.1.2
  • With containerized tasks, install each task’s required packages in its Docker image instead. Isolated images avoid conflicts between tasks and keep task dependencies out of the Airflow worker environment, but the images must be built and maintained. section 11.3.2

Choosing a boundary for two tasks

Suppose an HTTP task uses requests while a model-training task uses pandas or scikit-learn. Running them directly through Airflow operators puts their requirements into the shared Airflow environment. Running each as a containerized task lets each image carry its own requirements; related tasks may be able to share an image. section 11.1.2 section 11.3.2

Figure 11.2 Complex and conflicting dependencies between Airflow tasks or DAGs. Running many DAGs in a single environment can lead to conflicts when DAGs depend on different versions of the same (or related) packages. Python in particular doesn’t support installing different versions of the same package in the same environment. This means we have to resolve any conflicts in packages (right) by rewriting the DAGs or their dependencies to use the same package versions.

The dependency-conflict diagram shows why tasks or DAGs needing different package versions are troublesome in a shared environment. section 11.1.2

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Explains shared-environment conflicts and per-task image isolation, including image-maintenance costs; stops short of a package-installation walkthrough.
Examples
Uses requests for HTTP, MySQL components for database access, and pandas or scikit-learn for machine-learning tasks.
What it assumes
Assumes familiarity with Airflow tasks and operators; introduces their Python and system-level requirements through concrete examples.
What you can do after
Operate/configure it by placing task requirements in shared Airflow environments or isolated Docker images while accounting for conflicts and maintenance.
How it connects
Connects software dependencies to Airflow operators, Python environments, Docker containers, task isolation, and package-version conflicts.

Also explained in

Compare how 27 books explain dependency →

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.