You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/09/04 20:59:44 UTC
[airflow] branch main updated: Bring back SHUTDOWN-related constants (#34063)
This is an automated email from the ASF dual-hosted git repository.
potiuk 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 1ae29769ce Bring back SHUTDOWN-related constants (#34063)
1ae29769ce is described below
commit 1ae29769cea047d01c22089d24772be5e56e3b50
Author: Tzu-ping Chung <ur...@gmail.com>
AuthorDate: Tue Sep 5 04:59:37 2023 +0800
Bring back SHUTDOWN-related constants (#34063)
This should restore code compatibility to 2.6 and prior. Note that the
constants would not appear in documentation since they are deprecated
and not use in Airflow core anyway anymore.
---
airflow/utils/state.py | 25 +++++++++++++++++++++++++
tests/www/views/test_views_cluster_activity.py | 2 ++
2 files changed, 27 insertions(+)
diff --git a/airflow/utils/state.py b/airflow/utils/state.py
index 32219edb73..10355dcaf0 100644
--- a/airflow/utils/state.py
+++ b/airflow/utils/state.py
@@ -58,6 +58,14 @@ class TaskInstanceState(str, Enum):
SKIPPED = "skipped" # Skipped by branching or some other mechanism
DEFERRED = "deferred" # Deferrable operator waiting on a trigger
+ # Not used anymore, kept for compatibility.
+ # TODO: Remove in Airflow 3.0.
+ SHUTDOWN = "shutdown"
+ """The task instance is being shut down.
+
+ :meta private:
+ """
+
def __str__(self) -> str:
return self.value
@@ -100,6 +108,14 @@ class State:
SKIPPED = TaskInstanceState.SKIPPED
DEFERRED = TaskInstanceState.DEFERRED
+ # Not used anymore, kept for compatibility.
+ # TODO: Remove in Airflow 3.0.
+ SHUTDOWN = TaskInstanceState.SHUTDOWN
+ """The task instance is being shut down.
+
+ :meta private:
+ """
+
finished_dr_states: frozenset[DagRunState] = frozenset([DagRunState.SUCCESS, DagRunState.FAILED])
unfinished_dr_states: frozenset[DagRunState] = frozenset([DagRunState.QUEUED, DagRunState.RUNNING])
@@ -190,6 +206,15 @@ class State:
A list of states indicating that a task or dag is a success state.
"""
+ # Kept for compatibility. DO NOT USE.
+ # TODO: Remove in Airflow 3.0.
+ terminating_states = frozenset([TaskInstanceState.SHUTDOWN, TaskInstanceState.RESTARTING])
+ """
+ A list of states indicating that a task has been terminated.
+
+ :meta private:
+ """
+
adoptable_states = frozenset(
[TaskInstanceState.QUEUED, TaskInstanceState.RUNNING, TaskInstanceState.RESTARTING]
)
diff --git a/tests/www/views/test_views_cluster_activity.py b/tests/www/views/test_views_cluster_activity.py
index 0c70ea1425..1825a1d680 100644
--- a/tests/www/views/test_views_cluster_activity.py
+++ b/tests/www/views/test_views_cluster_activity.py
@@ -115,6 +115,7 @@ def test_historical_metrics_data(admin_client, session, time_machine):
"restarting": 0,
"running": 0,
"scheduled": 0,
+ "shutdown": 0,
"skipped": 0,
"success": 2,
"up_for_reschedule": 0,
@@ -143,6 +144,7 @@ def test_historical_metrics_data_date_filters(admin_client, session):
"restarting": 0,
"running": 0,
"scheduled": 0,
+ "shutdown": 0,
"skipped": 0,
"success": 0,
"up_for_reschedule": 0,