Skip to content

Commit

Permalink
Bring back SHUTDOWN-related constants
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
uranusjr committed Sep 4, 2023
1 parent 6c649ae commit 31f65d1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions airflow/utils/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -190,6 +206,15 @@ def color_fg(cls, 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]
)
Expand Down
2 changes: 2 additions & 0 deletions tests/www/views/test_views_cluster_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 31f65d1

Please sign in to comment.