Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ logs

# Mac
.DS_Store

# Data
data
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


with DAG(
dag_id="chapter5_01_start",
dag_id="01_start",
start_date=airflow.utils.dates.days_ago(3),
schedule_interval="@daily",
) as dag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _clean_sales_new(**context):


with DAG(
dag_id="chapter5_02_branch_in_function",
dag_id="02_branch_in_function",
start_date=airflow.utils.dates.days_ago(3),
schedule_interval="@daily",
) as dag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _clean_sales_new(**context):


with DAG(
dag_id="chapter5_03_branch_in_dag",
dag_id="03_branch_in_dag",
start_date=airflow.utils.dates.days_ago(3),
schedule_interval="@daily",
) as dag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _clean_sales_new(**context):


with DAG(
dag_id="chapter5_04_branch_in_dag_explicit_join",
dag_id="04_branch_in_dag_explicit_join",
start_date=airflow.utils.dates.days_ago(3),
schedule_interval="@daily",
) as dag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _is_latest_run(**context):


with DAG(
dag_id="chapter5_05_condition_in_function",
dag_id="05_condition_in_function",
start_date=airflow.utils.dates.days_ago(3),
schedule_interval="@daily",
) as dag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _latest_only(**context):


with DAG(
dag_id="chapter5_06_condition_in_dag",
dag_id="06_condition_in_dag",
start_date=airflow.utils.dates.days_ago(3),
schedule_interval="@daily",
) as dag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def _fetch_sales(**context):


with DAG(
dag_id="chapter5_07_trigger_rules",
dag_id="07_trigger_rules",
start_date=airflow.utils.dates.days_ago(3),
schedule_interval="@daily",
) as dag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _deploy_model(**context):


with DAG(
dag_id="chapter5_08_xcoms",
dag_id="08_xcoms",
start_date=airflow.utils.dates.days_ago(3),
schedule_interval="@daily",
) as dag:
Expand Down
49 changes: 49 additions & 0 deletions chapters/chapter05/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '3.7'
# ====================================== AIRFLOW ENVIRONMENT VARIABLES =======================================
x-environment: &airflow_environment
- AIRFLOW__CORE__EXECUTOR=LocalExecutor
- AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS=False
- AIRFLOW__CORE__LOAD_EXAMPLES=False
- AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql://airflow:airflow@postgres:5432/airflow
- AIRFLOW__CORE__STORE_DAG_CODE=True
- AIRFLOW__CORE__STORE_SERIALIZED_DAGS=True
- AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True
- AIRFLOW__WEBSERVER__RBAC=False
x-airflow-image: &airflow_image apache/airflow:1.10.12-python3.8
# ====================================== /AIRFLOW ENVIRONMENT VARIABLES ======================================
services:
postgres:
image: postgres:12-alpine
environment:
- POSTGRES_USER=airflow
- POSTGRES_PASSWORD=airflow
- POSTGRES_DB=airflow
ports:
- "5432:5432"
init:
image: *airflow_image
depends_on:
- postgres
environment: *airflow_environment
command: upgradedb
webserver:
image: *airflow_image
restart: always
depends_on:
- postgres
ports:
- "8080:8080"
volumes:
- ./logs:/opt/airflow/logs
environment: *airflow_environment
command: webserver
scheduler:
image: *airflow_image
restart: always
depends_on:
- postgres
volumes:
- ./dags:/opt/airflow/dags
- ./logs:/opt/airflow/logs
environment: *airflow_environment
command: scheduler
14 changes: 7 additions & 7 deletions chapters/chapter5/readme.md → chapters/chapter05/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Code accompanying Chapter 5 of the book 'Data pipelines with Apache Airflow'.

This code example contains the following DAGs:

- chapter5_01_start.py - Initial DAG with several tasks.
- chapter5_02_branch_in_function.py - Branching within a function.
- chapter5_03_branch_in_dag.py - Branching within the DAG.
- chapter5_04_branch_in_dag_explicit_join.py - Branching within the DAG with a join.
- chapter5_05_branch_in_function.py - Condition within a function.
- chapter5_06_branch_in_dag.py - Condition within the DAG.
- chapter5_07_trigger_rules.py - DAG illustrating several trigger rules.
- 01_start.py - Initial DAG with several tasks.
- 02_branch_in_function.py - Branching within a function.
- 03_branch_in_dag.py - Branching within the DAG.
- 04_branch_in_dag_explicit_join.py - Branching within the DAG with a join.
- 05_branch_in_function.py - Condition within a function.
- 06_branch_in_dag.py - Condition within the DAG.
- 07_trigger_rules.py - DAG illustrating several trigger rules.

## Usage

Expand Down
14 changes: 0 additions & 14 deletions chapters/chapter5/docker-compose.yml

This file was deleted.