liveBook · Manning

Apache Airflow

As explained in Designing Deep Learning Systems: A guide for software engineers

Apache Airflow is an open-source platform for authoring, scheduling, and monitoring batch-oriented workflows.

Apache Airflow is an open-source platform for programmatically authoring, scheduling, and monitoring workflows. It was built for increasingly complex ETL and data pipelines, but its extensibility, production quality, and GUI support support broader domains, including deep learning. section 9.3.1

Build an Airflow workflow around a Python-defined directed acyclic graph (DAG):

  • Define the DAG and its tasks, then declare task dependencies. section 9.3.1
  • Implement tasks with operators, using predefined or community-managed operators such as MySqlOperator, SimpleHttpOperator, and Docker operator. section 9.3.1
  • Use PythonOperator for customized Python functions and dynamic workflows when tasks must be created programmatically. section 9.3.1
  • Inspect deployed workflow execution through the web UI or CLI commands that list DAGs, tasks, and task trees. section 9.3.1

Daily data-processing workflow

A representative DAG runs daily, waits for data.csv with FileSensor, transforms the data with PythonOperator, creates a database table with PostgresOperator, and continues with dependent processing tasks. section 9.3 section 9.3.1

Listing 9.1 A sample Airflow workflow definition
# declare the workflow DAG. 
with DAG(dag_id="data_process_dag",
        schedule_interval="@daily",
        default_args=default_args,
        template_searchpath=[f"{os.environ['AIRFLOW_HOME']}"],
        catchup=False) as dag:
 
# define tasks of the workflow, each code section below is a task 
 
   is_new_data_available = FileSensor(       #1
       task_id="is_new_data_available",
       fs_conn_id="data_path",
       filepath="data.csv",
       .. .. ..
   )
 
# define data transformation task
   transform_data = PythonOperator( 
       task_id="transform_data",
       python_callable=transform_data        #2
   )
 
# define table creation task
   create_table = PostgresOperator(          #3
       task_id="create_table",
       sql='''CREATE TABLE IF NOT EXISTS invoices (
               .. .. ..
               );''',
       postgres_conn_id='postgres',
       database='customer_data'
   )
 
   save_into_db = PythonOperator(
       task_id='save_into_db',
       python_callable=store_in_db
   )
 
   notify_data_science_team = SlackWebhookOperator(
       task_id='notify_data_science_team',
       http_conn_id='slack_conn',
       webhook_token=slack_token,
       message="Data Science Notification \n"
       .. .. ..
   )
 
 
# Step two, declare task dependencies in the workflow
  is_new_data_available >> transform_data
  transform_data >> create_table >> save_into_db
  save_into_db >> notify_data_science_team
  save_into_db >> create_report
 
# The actual data transformation logic, which is referenced
# in the “transform_data” task.
def transform_data(*args, **kwargs):
   .. .. ..

Inspect the sample Python DAG definition, including its daily schedule, sensor, transformation task, and table-creation task. section 9.3.1

How Designing Deep Learning Systems: A guide for software engineers covers it

How deep it goes
Explains DAGs, operators, dependencies, dynamic tasks, interfaces, and a representative workflow, but does not detail platform internals.
Examples
Demonstrates a daily pipeline that senses new data, transforms it, creates a database table, and exposes execution through UI and CLI commands.
What you can do after
Operate scheduled workflows by defining Python DAGs, assigning operators, declaring dependencies, deploying code, and inspecting execution status.
How it connects
Connects workflow orchestration with ETL, data pipelines, DAGs, operators, task dependencies, databases, and deep learning workflows.

Also explained in

Compare how 5 books explain Apache Airflow →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing Deep Learning Systems: A guide for software engineers. The section links point to the parts of the book it draws on.