This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-5-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 963a5a3188d2cfa9d894934643d930de4f78eab6 Author: Tzu-ping Chung <[email protected]> AuthorDate: Wed Nov 30 18:27:00 2022 +0800 Pass in session appropriately to _clear_dag_tis (#28003) This makes the session argument required instead, and pass it from the dagrun_clear view correctly. Some type annotations are added also to the function for future maintainability. (cherry picked from commit f43f50e3f11fa02a2025b4b68b8770d6456ba95d) --- airflow/models/dag.py | 2 +- airflow/www/views.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/airflow/models/dag.py b/airflow/models/dag.py index c761dcadfa..210f455f06 100644 --- a/airflow/models/dag.py +++ b/airflow/models/dag.py @@ -1950,7 +1950,7 @@ class DAG(LoggingMixin): @provide_session def clear( self, - task_ids: Collection[str] | Collection[tuple[str, int]] | None = None, + task_ids: Collection[str | tuple[str, int]] | None = None, start_date: datetime | None = None, end_date: datetime | None = None, only_failed: bool = False, diff --git a/airflow/www/views.py b/airflow/www/views.py index 39f69d4410..a4126535ca 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -33,7 +33,7 @@ from datetime import datetime, timedelta from functools import wraps from json import JSONDecodeError from operator import itemgetter -from typing import Any, Callable +from typing import Any, Callable, Collection from urllib.parse import unquote, urljoin, urlsplit import configupdater @@ -2013,11 +2013,12 @@ class Airflow(AirflowBaseView): dag: DAG, start_date: datetime | None, end_date: datetime | None, - origin: str, - task_ids=None, - recursive=False, - confirmed=False, - only_failed=False, + *, + origin: str | None, + task_ids: Collection[str | tuple[str, int]] | None = None, + recursive: bool = False, + confirmed: bool = False, + only_failed: bool = False, session: Session = NEW_SESSION, ): if confirmed: @@ -2144,7 +2145,7 @@ class Airflow(AirflowBaseView): dag, start_date, end_date, - origin, + origin=origin, task_ids=task_ids, recursive=recursive, confirmed=confirmed, @@ -2164,7 +2165,8 @@ class Airflow(AirflowBaseView): ] ) @action_logging - def dagrun_clear(self): + @provide_session + def dagrun_clear(self, *, session: Session = NEW_SESSION): """Clears the DagRun""" dag_id = request.form.get("dag_id") dag_run_id = request.form.get("dag_run_id") @@ -2182,6 +2184,7 @@ class Airflow(AirflowBaseView): origin=None, recursive=True, confirmed=confirmed, + session=session, ) @expose("/blocked", methods=["POST"])
