Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Reconfigure retries & timeouts for typical ingestion DAGs (#361)
Madison Swain-Bowden2b2f9636bbcc
diff --git a/openverse_catalog/dags/common/dag_factory.py b/openverse_catalog/dags/common/dag_factory.pyindex 8879f1613..58e2c687f 100644--- a/openverse_catalog/dags/common/dag_factory.py+++ b/openverse_catalog/dags/common/dag_factory.py@@ -81,8 +81,9 @@ DAG_DEFAULT_ARGS = {"depends_on_past": False,"start_date": datetime(2019, 1, 15),"email_on_retry": False,- "retries": 3,- "retry_delay": timedelta(minutes=15),+ "retries": 2,+ "retry_delay": timedelta(minutes=5),+ "execution_timeout": timedelta(hours=1),"on_failure_callback": slack.on_failure_callback,}DATE_RANGE_ARG_TEMPLATE = "{{{{ macros.ds_add(ds, -{}) }}}}"@@ -149,7 +150,7 @@ def create_provider_api_workflow(schedule_string: str = "@daily",dated: bool = True,day_shift: int = 0,- dagrun_timeout: timedelta = timedelta(hours=12),+ execution_timeout: timedelta = timedelta(hours=12),doc_md: str = "",media_types: Sequence[str] = ("image",),):@@ -168,29 +169,29 @@ def create_provider_api_workflow(Optional Arguments:- default_args: dictionary which is passed to the airflow.dag.DAG- __init__ method.- start_date: datetime.datetime giving the first valid execution- date of the DAG.- max_active_tasks: integer that sets the number of tasks which can- run simultaneously for this DAG, and the number of- dagruns of this DAG which can be run in parallel.- It's important to keep the rate limits of the- Provider API in mind when setting this parameter.- schedule_string: string giving the schedule on which the DAG should- be run. Passed to the airflow.dag.DAG __init__- method.- dated: boolean giving whether the `main_function` takes a- string parameter giving a date (i.e., the date for- which data should be ingested).- day_shift: integer giving the number of days before the- current execution date the `main_function` should- be run (if `dated=True`).- dagrun_timeout: datetime.timedelta giving the total amount of time- a given dagrun may take.- doc_md: string which should be used for the DAG's documentation markdown- media_types: list describing the media type(s) that this provider handles- (e.g. `["audio"]`, `["image", "audio"]`, etc.)+ default_args: dictionary which is passed to the airflow.dag.DAG+ __init__ method.+ start_date: datetime.datetime giving the first valid execution+ date of the DAG.+ max_active_tasks: integer that sets the number of tasks which can+ run simultaneously for this DAG, and the number of+ dagruns of this DAG which can be run in parallel.+ It's important to keep the rate limits of the+ Provider API in mind when setting this parameter.+ schedule_string: string giving the schedule on which the DAG should+ be run. Passed to the airflow.dag.DAG __init__+ method.+ dated: boolean giving whether the `main_function` takes a+ string parameter giving a date (i.e., the date for+ which data should be ingested).+ day_shift: integer giving the number of days before the+ current execution date the `main_function` should+ be run (if `dated=True`).+ execution_timeout: datetime.timedelta giving the amount of time a given data+ pull may take.+ doc_md: string which should be used for the DAG's documentation markdown+ media_types: list describing the media type(s) that this provider handles+ (e.g. `["audio"]`, `["image", "audio"]`, etc.)"""default_args = default_args or DAG_DEFAULT_ARGSmedia_type_name = "mixed" if len(media_types) > 1 else media_types[0]@@ -202,7 +203,6 @@ def create_provider_api_workflow(default_args={**default_args, "start_date": start_date},max_active_tasks=max_active_tasks,max_active_runs=max_active_tasks,- dagrun_timeout=dagrun_timeout,start_date=start_date,schedule_interval=schedule_string,catchup=False,@@ -220,7 +220,10 @@ def create_provider_api_workflow(python_callable=_push_output_paths_wrapper,op_kwargs=pull_kwargs,depends_on_past=False,- execution_timeout=dagrun_timeout if dated else None,+ execution_timeout=execution_timeout,+ # If the data pull fails, we want to load all data that's been retrieved+ # thus far before we attempt again+ retries=0,)for media_type in media_types:diff --git a/openverse_catalog/dags/providers/brooklyn_museum_workflow.py b/openverse_catalog/dags/providers/brooklyn_museum_workflow.pyindex bd48d5d18..c20bac9e4 100644--- a/openverse_catalog/dags/providers/brooklyn_museum_workflow.py+++ b/openverse_catalog/dags/providers/brooklyn_museum_workflow.py@@ -12,7 +12,6 @@ from providers.provider_api_scripts import brooklyn_museumDAG_ID = "brooklyn_museum_workflow"START_DATE = datetime(2020, 1, 1)-DAGRUN_TIMEOUT = timedelta(hours=24)globals()[DAG_ID] = create_provider_api_workflow(DAG_ID,@@ -20,5 +19,5 @@ globals()[DAG_ID] = create_provider_api_workflow(start_date=START_DATE,schedule_string="@monthly",dated=False,- dagrun_timeout=DAGRUN_TIMEOUT,+ execution_timeout=timedelta(hours=24),)diff --git a/openverse_catalog/dags/providers/finnish_museums_workflow.py b/openverse_catalog/dags/providers/finnish_museums_workflow.pyindex 710784965..4f32e402a 100644--- a/openverse_catalog/dags/providers/finnish_museums_workflow.py+++ b/openverse_catalog/dags/providers/finnish_museums_workflow.py@@ -13,7 +13,6 @@ from providers.provider_api_scripts import finnish_museumsDAG_ID = "finnish_museums_workflow"START_DATE = datetime(2020, 9, 1)-DAGRUN_TIMEOUT = timedelta(hours=24)globals()[DAG_ID] = create_provider_api_workflow(DAG_ID,@@ -21,5 +20,5 @@ globals()[DAG_ID] = create_provider_api_workflow(start_date=START_DATE,schedule_string="@monthly",dated=False,- dagrun_timeout=DAGRUN_TIMEOUT,+ execution_timeout=timedelta(hours=24),)diff --git a/openverse_catalog/dags/providers/jamendo_workflow.py b/openverse_catalog/dags/providers/jamendo_workflow.pyindex 896a67394..67c6a4209 100644--- a/openverse_catalog/dags/providers/jamendo_workflow.py+++ b/openverse_catalog/dags/providers/jamendo_workflow.py@@ -7,7 +7,6 @@ from providers.provider_api_scripts import jamendoDAG_ID = "jamendo_workflow"-DAGRUN_TIMEOUT = timedelta(hours=24)globals()[DAG_ID] = create_provider_api_workflow(@@ -17,6 +16,6 @@ globals()[DAG_ID] = create_provider_api_workflow(max_active_tasks=1,schedule_string="@monthly",dated=False,- dagrun_timeout=DAGRUN_TIMEOUT,+ execution_timeout=timedelta(hours=24),media_types=["audio"],)diff --git a/openverse_catalog/dags/providers/museum_victoria_workflow.py b/openverse_catalog/dags/providers/museum_victoria_workflow.pyindex 8dc169654..6e3455df7 100644--- a/openverse_catalog/dags/providers/museum_victoria_workflow.py+++ b/openverse_catalog/dags/providers/museum_victoria_workflow.py@@ -12,7 +12,6 @@ from providers.provider_api_scripts import museum_victoriaDAG_ID = "museum_victoria_workflow"START_DATE = datetime(2020, 1, 1)-DAGRUN_TIMEOUT = timedelta(hours=24)globals()[DAG_ID] = create_provider_api_workflow(DAG_ID,@@ -20,5 +19,5 @@ globals()[DAG_ID] = create_provider_api_workflow(start_date=START_DATE,schedule_string="@monthly",dated=False,- dagrun_timeout=DAGRUN_TIMEOUT,+ execution_timeout=timedelta(hours=24),)diff --git a/openverse_catalog/dags/providers/nypl_workflow.py b/openverse_catalog/dags/providers/nypl_workflow.pyindex d69a90149..2e6efdb83 100644--- a/openverse_catalog/dags/providers/nypl_workflow.py+++ b/openverse_catalog/dags/providers/nypl_workflow.py@@ -12,7 +12,6 @@ from providers.provider_api_scripts import nyplDAG_ID = "nypl_workflow"START_DATE = datetime(2020, 1, 1)-DAGRUN_TIMEOUT = timedelta(hours=24)globals()[DAG_ID] = create_provider_api_workflow(DAG_ID,@@ -20,5 +19,5 @@ globals()[DAG_ID] = create_provider_api_workflow(start_date=START_DATE,schedule_string="@monthly",dated=False,- dagrun_timeout=DAGRUN_TIMEOUT,+ execution_timeout=timedelta(hours=24),)diff --git a/openverse_catalog/dags/providers/science_museum_workflow.py b/openverse_catalog/dags/providers/science_museum_workflow.pyindex f30cd3391..c5c142796 100644--- a/openverse_catalog/dags/providers/science_museum_workflow.py+++ b/openverse_catalog/dags/providers/science_museum_workflow.py@@ -20,7 +20,6 @@ logger = logging.getLogger(__name__)DAG_ID = "science_museum_workflow"START_DATE = datetime(2020, 1, 1)-DAGRUN_TIMEOUT = timedelta(hours=24)globals()[DAG_ID] = create_provider_api_workflow(DAG_ID,@@ -28,5 +27,5 @@ globals()[DAG_ID] = create_provider_api_workflow(start_date=START_DATE,schedule_string="@monthly",dated=False,- dagrun_timeout=DAGRUN_TIMEOUT,+ execution_timeout=timedelta(hours=24),)diff --git a/openverse_catalog/dags/providers/smithsonian_workflow.py b/openverse_catalog/dags/providers/smithsonian_workflow.pyindex 0c4850d96..4527791fd 100644--- a/openverse_catalog/dags/providers/smithsonian_workflow.py+++ b/openverse_catalog/dags/providers/smithsonian_workflow.py@@ -20,7 +20,6 @@ logger = logging.getLogger(__name__)DAG_ID = "smithsonian_workflow"START_DATE = datetime(2020, 1, 1)-DAGRUN_TIMEOUT = timedelta(hours=24)globals()[DAG_ID] = create_provider_api_workflow(DAG_ID,@@ -28,5 +27,5 @@ globals()[DAG_ID] = create_provider_api_workflow(start_date=START_DATE,schedule_string="@weekly",dated=False,- dagrun_timeout=DAGRUN_TIMEOUT,+ execution_timeout=timedelta(hours=24),)diff --git a/openverse_catalog/dags/providers/statens_museum_workflow.py b/openverse_catalog/dags/providers/statens_museum_workflow.pyindex 5c3f6d28a..5f891ce94 100644--- a/openverse_catalog/dags/providers/statens_museum_workflow.py+++ b/openverse_catalog/dags/providers/statens_museum_workflow.py@@ -20,7 +20,6 @@ logger = logging.getLogger(__name__)DAG_ID = "staten_museum_workflow"START_DATE = datetime(2020, 1, 1)-DAGRUN_TIMEOUT = timedelta(hours=24)globals()[DAG_ID] = create_provider_api_workflow(DAG_ID,@@ -28,5 +27,5 @@ globals()[DAG_ID] = create_provider_api_workflow(start_date=START_DATE,schedule_string="@monthly",dated=False,- dagrun_timeout=DAGRUN_TIMEOUT,+ execution_timeout=timedelta(hours=24),)diff --git a/openverse_catalog/dags/providers/walters_workflow.py b/openverse_catalog/dags/providers/walters_workflow.pyindex dc08c5746..9be6284a6 100644--- a/openverse_catalog/dags/providers/walters_workflow.py+++ b/openverse_catalog/dags/providers/walters_workflow.py@@ -25,5 +25,5 @@ globals()[DAG_ID] = create_provider_api_workflow(start_date=datetime(2020, 9, 27),schedule_string="@monthly",dated=False,- dagrun_timeout=timedelta(days=1),+ execution_timeout=timedelta(days=1),)