Skip to content
Open
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
2 changes: 1 addition & 1 deletion chapter02/scripts/listing_2_10.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docker run \
-ti \
-p 8080:8080 \
-v ${SCRIPT_DIR}/../dags/download_rocket_launches.py:/opt/airflow/dags/download_rocket_launches.py \
--name airflow
--name airflow \
--entrypoint=/bin/bash \
apache/airflow:2.0.0-python3.8 \
-c '( \
Expand Down
4 changes: 2 additions & 2 deletions chapter03/dags/01_unscheduled.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from datetime import datetime
from pathlib import Path

import pandas as pd
import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="01_unscheduled", start_date=datetime(2019, 1, 1), schedule_interval=None
dag_id="01_unscheduled", start_date=airflow.utils.dates.days_ago(14), schedule_interval=None
)

fetch_events = BashOperator(
Expand Down
7 changes: 4 additions & 3 deletions chapter03/dags/02_daily_schedule.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from datetime import datetime
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd
import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="02_daily_schedule",
schedule_interval="@daily",
start_date=datetime(2019, 1, 1),
end_date=datetime(2019, 1, 5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
)

fetch_events = BashOperator(
Expand Down
7 changes: 4 additions & 3 deletions chapter03/dags/03_with_end_date.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import datetime as dt
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd
import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="03_with_end_date",
schedule_interval="@daily",
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
)

fetch_events = BashOperator(
Expand Down
9 changes: 5 additions & 4 deletions chapter03/dags/04_time_delta.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import datetime as dt
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd
import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="04_time_delta",
schedule_interval=dt.timedelta(days=3),
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
schedule_interval=timedelta(days=3),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
)

fetch_events = BashOperator(
Expand Down
7 changes: 4 additions & 3 deletions chapter03/dags/05_query_with_dates.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import datetime as dt
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd
import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="05_query_with_dates",
schedule_interval="@daily",
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
)

fetch_events = BashOperator(
Expand Down
7 changes: 4 additions & 3 deletions chapter03/dags/06_templated_query.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import datetime as dt
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd

import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="06_templated_query",
schedule_interval="@daily",
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
)

fetch_events = BashOperator(
Expand Down
8 changes: 4 additions & 4 deletions chapter03/dags/07_templated_query_ds.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import datetime as dt
from datetime import timedelta
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd

import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="07_templated_query_ds",
schedule_interval=timedelta(days=3),
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
)

fetch_events = BashOperator(
Expand Down
7 changes: 4 additions & 3 deletions chapter03/dags/08_templated_path.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import datetime as dt
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd

import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="08_templated_path",
schedule_interval="@daily",
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
)

fetch_events = BashOperator(
Expand Down
7 changes: 4 additions & 3 deletions chapter03/dags/09_no_catchup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import datetime as dt
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd

import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="09_no_catchup",
schedule_interval="@daily",
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
catchup=False,
)

Expand Down
7 changes: 4 additions & 3 deletions chapter03/dags/10_non_atomic_send.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import datetime as dt
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd

import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="10_non_atomic_send",
schedule_interval="@daily",
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
catchup=True,
)

Expand Down
7 changes: 4 additions & 3 deletions chapter03/dags/11_atomic_send.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import datetime as dt
from datetime import datetime, timedelta
from pathlib import Path

import pandas as pd

import airflow
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator

dag = DAG(
dag_id="11_atomic_send",
schedule_interval="@daily",
start_date=dt.datetime(year=2019, month=1, day=1),
end_date=dt.datetime(year=2019, month=1, day=5),
start_date=airflow.utils.dates.days_ago(14),
end_date=datetime.now() + timedelta(days=14),
catchup=True,
)

Expand Down
2 changes: 1 addition & 1 deletion chapter03/docker/events-api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _generate_events_for_day(date):


app = Flask(__name__)
app.config["events"] = _generate_events(end_date=date(year=2019, month=1, day=5))
app.config["events"] = _generate_events(end_date=date.today())


@app.route("/events")
Expand Down
3 changes: 1 addition & 2 deletions chapter03/docker/events-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
click==7.1.2
faker==4.14.0
flask==1.1.2
flask==2.2.2
pandas==1.1.3