Skip to content

Commit 8b10a4b

Browse files
authored
Stop using start_date in default_args in example_dags (#9982)
1 parent fc03304 commit 8b10a4b

File tree

69 files changed

+95
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+95
-185
lines changed

β€Ž.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ repos:
323323
entry: "(airflow\\.){0,1}utils\\.dates\\.days_ago"
324324
files: \.py$
325325
pass_filenames: true
326+
- id: restrict-start_date-in-default_args-in-example_dags
327+
language: pygrep
328+
name: "'start_date' should not be defined in default_args in example_dags"
329+
entry: "default_args\\s*=\\s*{\\s*(\"|')start_date(\"|')"
330+
files: \.*example_dags.*.py$
331+
pass_filenames: true
326332
- id: check-integrations
327333
name: Check if integration list is aligned
328334
entry: ./scripts/ci/pre_commit/pre_commit_check_integrations.sh

β€Žairflow/example_dags/example_complex.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
from airflow.operators.python import PythonOperator
2727
from airflow.utils.dates import days_ago
2828

29-
default_args = {"start_date": days_ago(1)}
30-
3129
with models.DAG(
3230
dag_id="example_complex",
33-
default_args=default_args,
3431
schedule_interval=None,
32+
start_date=days_ago(1),
3533
tags=['example'],
3634
) as dag:
3735

β€Žairflow/example_dags/example_trigger_target_dag.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
dag = DAG(
3131
dag_id="example_trigger_target_dag",
32-
default_args={"start_date": days_ago(2), "owner": "airflow"},
32+
default_args={"owner": "airflow"},
33+
start_date=days_ago(2),
3334
schedule_interval=None,
3435
tags=['example']
3536
)

β€Žairflow/providers/amazon/aws/example_dags/example_datasync_1.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@
4545
"DESTINATION_LOCATION_URI", "s3://mybucket/prefix")
4646
# [END howto_operator_datasync_1_args_2]
4747

48-
default_args = {"start_date": days_ago(1)}
4948

5049
with models.DAG(
5150
"example_datasync_1_1",
52-
default_args=default_args,
5351
schedule_interval=None, # Override to match your needs
52+
start_date=days_ago(1),
5453
tags=['example'],
5554
) as dag:
5655

@@ -64,7 +63,7 @@
6463

6564
with models.DAG(
6665
"example_datasync_1_2",
67-
default_args=default_args,
66+
start_date=days_ago(1),
6867
schedule_interval=None, # Override to match your needs
6968
) as dag:
7069
# [START howto_operator_datasync_1_2]

β€Žairflow/providers/amazon/aws/example_dags/example_datasync_2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@
7777
getenv("UPDATE_TASK_KWARGS", default_update_task_kwargs)
7878
)
7979

80-
default_args = {"start_date": days_ago(1)}
8180
# [END howto_operator_datasync_2_args]
8281

8382
with models.DAG(
8483
"example_datasync_2",
85-
default_args=default_args,
8684
schedule_interval=None, # Override to match your needs
85+
start_date=days_ago(1),
8786
tags=['example'],
8887
) as dag:
8988

β€Žairflow/providers/amazon/aws/example_dags/example_google_api_to_s3_transfer_advanced.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
YOUTUBE_VIDEO_FIELDS = getenv("YOUTUBE_VIDEO_FIELDS", "items(id,snippet(description,publishedAt,tags,title))")
5252
# [END howto_operator_google_api_to_s3_transfer_advanced_env_variables]
5353

54-
default_args = {"start_date": days_ago(1)}
55-
5654

5755
# pylint: disable=unused-argument
5856
# [START howto_operator_google_api_to_s3_transfer_advanced_task_1_2]
@@ -74,8 +72,8 @@ def _check_and_transform_video_ids(xcom_key, task_ids, task_instance, **kwargs):
7472

7573
with DAG(
7674
dag_id="example_google_api_to_s3_transfer_advanced",
77-
default_args=default_args,
7875
schedule_interval=None,
76+
start_date=days_ago(1),
7977
tags=['example']
8078
) as dag:
8179
# [START howto_operator_google_api_to_s3_transfer_advanced_task_1]

β€Žairflow/providers/amazon/aws/example_dags/example_google_api_to_s3_transfer_basic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@
3232
S3_DESTINATION_KEY = getenv("S3_DESTINATION_KEY", "s3://bucket/key.json")
3333
# [END howto_operator_google_api_to_s3_transfer_basic_env_variables]
3434

35-
default_args = {"start_date": days_ago(1)}
3635

3736
with DAG(
3837
dag_id="example_google_api_to_s3_transfer_basic",
39-
default_args=default_args,
4038
schedule_interval=None,
39+
start_date=days_ago(1),
4140
tags=['example']
4241
) as dag:
4342
# [START howto_operator_google_api_to_s3_transfer_basic_task_1]

β€Žairflow/providers/amazon/aws/example_dags/example_imap_attachment_to_s3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
S3_DESTINATION_KEY = getenv("S3_DESTINATION_KEY", "s3://bucket/key.json")
3434
# [END howto_operator_imap_attachment_to_s3_env_variables]
3535

36-
default_args = {"start_date": days_ago(1)}
37-
3836
with DAG(
3937
dag_id="example_imap_attachment_to_s3",
40-
default_args=default_args,
38+
start_date=days_ago(1),
4139
schedule_interval=None,
4240
tags=['example']
4341
) as dag:

β€Žairflow/providers/amazon/aws/example_dags/example_s3_to_redshift.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
REDSHIFT_TABLE = getenv("REDSHIFT_TABLE", "test_table")
3535
# [END howto_operator_s3_to_redshift_env_variables]
3636

37-
default_args = {"start_date": days_ago(1)}
38-
3937

4038
def _add_sample_data_to_s3():
4139
s3_hook = S3Hook()
@@ -50,7 +48,7 @@ def _remove_sample_data_from_s3():
5048

5149
with DAG(
5250
dag_id="example_s3_to_redshift",
53-
default_args=default_args,
51+
start_date=days_ago(1),
5452
schedule_interval=None,
5553
tags=['example']
5654
) as dag:

β€Žairflow/providers/google/ads/example_dags/example_ads.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@
6464

6565
# [END howto_google_ads_env_variables]
6666

67-
default_args = {"start_date": dates.days_ago(1)}
68-
6967
with models.DAG(
7068
"example_google_ads",
71-
default_args=default_args,
7269
schedule_interval=None, # Override to match your needs
70+
start_date=dates.days_ago(1),
7371
) as dag:
7472
# [START howto_google_ads_to_gcs_operator]
7573
run_operator = GoogleAdsToGcsOperator(

0 commit comments

Comments
 (0)