concept Airflow in category apache airflow

appears as: Airflow, Airflow
Data Pipelines with Apache Airflow

This is an excerpt from Manning's book Data Pipelines with Apache Airflow.

Airflow is best thought of as a spider in a web: it sits in the middle of your data processes and coordinates work happening across the different (distributed) systems. As such, Airflow is not a data processing tool in itself, but orchestrates the different components responsible for processing your data in data pipelines.

In this chapter, we’ll first give you a short introduction to data pipelines in Apache Airflow. Afterwards, we’ll discuss several considerations to keep in mind when evaluating whether Airflow is right for you and demonstrate how to make your first steps with Airflow.

Similar to other workflow managers, Airflow allows you to define pipelines or workflows as Directed Acyclic Graphs (DAGs) of tasks. These graphs are very similar to the examples sketched in the previous section, with tasks being defined as nodes in the graph and dependencies as directed edges between the tasks.

In Airflow, you define your DAGs using Python code in DAG files, which are essentially Python scripts that describe the structure of the corresponding DAG. As such, each DAG file typically describes the set of tasks for a given DAG and the dependencies between the tasks, which are then parsed by Airflow to identify the DAG structure (Figure 1.7). Besides this, DAG files typically contain some additional metadata about the DAG telling Airflow how and when it should be executed etc. We’ll dive into this scheduling more in the next section.

Figure 1.7 Airflow pipelines are defined as DAGs (Directed Acyclic Graphs) using Python code in DAG files. Each DAG file typically defines one DAG, which describes the different tasks and their dependencies. Besides this, the DAG also defines a schedule interval which determines when the DAG is executed by Airflow.

One advantage of defining Airflow DAGs in Python code is that this programmatic approach provides you with a lot of flexibility for building DAGs. For example, as we will see later in this book, you can use Python code to dynamically generate optional tasks depending on certain conditions, or even generate entire DAGs based on external metadata or configuration files. This flexibility allows a great deal of customization in how you build your pipelines - allowing you to fit Airflow to your needs for building arbitrarily complex pipelines.  

Besides this flexibility, another advantage of Airflow’s Python foundation is that tasks can execute any operation that you can implement in Python. Over time, this has led to the development of many Airflow extensions that allow you to execute tasks across a wide variety of systems, including external databases, big data technologies and various cloud services; allowing you to build complex data pipelines bringing together data processes across many different systems.

Listing 12.4 Airflow installation on Kubernetes with Helm chart.
$ curl -OL https://github.com/apache/airflow/archive/master.zip #1
$ unzip master.zip
$ kubectl create namespace airflow #2
$ helm dep update ./airflow-master/chart #3
$ helm install airflow ./airflow-master/chart --namespace airflow #4
 
NAME: airflow
LAST DEPLOYED: Wed Jul 22 20:40:44 2020
NAMESPACE: airflow
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing Airflow!
 
Your release is named airflow.
 
You can now access your dashboard(s) by executing the following command(s) and visiting the corresponding port at localhost in your browser:
 
Airflow dashboard:        kubectl port-forward svc/airflow-webserver 8080:8080 --namespace airflow