This is an automated email from the ASF dual-hosted git repository.
uranusjr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 79daf10132 Update signature of TaskReschedule to not use task (#39188)
79daf10132 is described below
commit 79daf1013203d2597ac0486aae6a0d06178ff0c7
Author: Daniel Standish <[email protected]>
AuthorDate: Wed Apr 24 00:10:11 2024 -0700
Update signature of TaskReschedule to not use task (#39188)
---
airflow/models/taskinstance.py | 3 ++-
airflow/models/taskreschedule.py | 8 ++++----
tests/api_experimental/common/test_delete_dag.py | 3 ++-
tests/models/test_dagrun.py | 3 ++-
tests/ti_deps/deps/test_ready_to_reschedule_dep.py | 3 ++-
tests/www/views/test_views_tasks.py | 3 ++-
6 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index cb071e2edc..1b536ff0bf 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -2907,7 +2907,8 @@ class TaskInstance(Base, LoggingMixin):
# Log reschedule request
session.add(
TaskReschedule(
- self.task,
+ self.task_id,
+ self.dag_id,
self.run_id,
self._try_number,
actual_start_date,
diff --git a/airflow/models/taskreschedule.py b/airflow/models/taskreschedule.py
index 65e5ef5ada..55fe9e4b8e 100644
--- a/airflow/models/taskreschedule.py
+++ b/airflow/models/taskreschedule.py
@@ -37,7 +37,6 @@ if TYPE_CHECKING:
from sqlalchemy.orm import Query, Session
from sqlalchemy.sql import Select
- from airflow.models.operator import Operator
from airflow.models.taskinstance import TaskInstance
from airflow.serialization.pydantic.taskinstance import
TaskInstancePydantic
@@ -84,7 +83,8 @@ class TaskReschedule(TaskInstanceDependencies):
def __init__(
self,
- task: Operator,
+ task_id: str,
+ dag_id: str,
run_id: str,
try_number: int,
start_date: datetime.datetime,
@@ -92,8 +92,8 @@ class TaskReschedule(TaskInstanceDependencies):
reschedule_date: datetime.datetime,
map_index: int = -1,
) -> None:
- self.dag_id = task.dag_id
- self.task_id = task.task_id
+ self.dag_id = dag_id
+ self.task_id = task_id
self.run_id = run_id
self.map_index = map_index
self.try_number = try_number
diff --git a/tests/api_experimental/common/test_delete_dag.py
b/tests/api_experimental/common/test_delete_dag.py
index 9fa98a4ffa..961d04dd37 100644
--- a/tests/api_experimental/common/test_delete_dag.py
+++ b/tests/api_experimental/common/test_delete_dag.py
@@ -99,7 +99,8 @@ class TestDeleteDAGSuccessfulDelete:
session.add(TaskFail(ti=ti))
session.add(
TR(
- task=ti.task,
+ task_id=ti.task_id,
+ dag_id=ti.dag_id,
run_id=ti.run_id,
start_date=test_date,
end_date=test_date,
diff --git a/tests/models/test_dagrun.py b/tests/models/test_dagrun.py
index d44d4f4ce5..929cf9ae87 100644
--- a/tests/models/test_dagrun.py
+++ b/tests/models/test_dagrun.py
@@ -2322,7 +2322,8 @@ def
test_clearing_task_and_moving_from_non_mapped_to_mapped(dag_maker, session):
ti = session.query(TaskInstance).filter_by(**filter_kwargs).one()
tr = TaskReschedule(
- task=ti,
+ task_id=ti.task_id,
+ dag_id=ti.dag_id,
run_id=ti.run_id,
try_number=ti.try_number,
start_date=timezone.datetime(2017, 1, 1),
diff --git a/tests/ti_deps/deps/test_ready_to_reschedule_dep.py
b/tests/ti_deps/deps/test_ready_to_reschedule_dep.py
index 421741a036..6a8689e9f2 100644
--- a/tests/ti_deps/deps/test_ready_to_reschedule_dep.py
+++ b/tests/ti_deps/deps/test_ready_to_reschedule_dep.py
@@ -86,7 +86,8 @@ class TestNotInReschedulePeriodDep:
dt = ti.execution_date + timedelta(minutes=minutes_timedelta)
trs.append(
TaskReschedule(
- task=ti.task,
+ task_id=ti.task_id,
+ dag_id=ti.dag_id,
run_id=ti.run_id,
try_number=ti.try_number,
map_index=ti.map_index,
diff --git a/tests/www/views/test_views_tasks.py
b/tests/www/views/test_views_tasks.py
index bc7ce29cec..d3001d1236 100644
--- a/tests/www/views/test_views_tasks.py
+++ b/tests/www/views/test_views_tasks.py
@@ -974,7 +974,8 @@ def test_action_muldelete_task_instance(session,
admin_client, task_search_tuple
# add task reschedules for those tasks to make sure that the delete
cascades to the required tables
trs = [
TaskReschedule(
- task=task,
+ task_id=task.task_id,
+ dag_id=task.dag_id,
run_id=task.run_id,
try_number=1,
start_date=timezone.datetime(2021, 1, 1),