Skip to content

Commit

Permalink
Rename rules for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
anticorrelator committed Oct 24, 2022
1 parent 0d60365 commit d2c5f97
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/prefect/orion/orchestration/core_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CoreFlowPolicy(BaseOrchestrationPolicy):

def priority():
return [
PreventFlowTransitionsFromTerminalStates,
HandleFlowTerminalStateTransitions,
PreventRedundantTransitions,
WaitForScheduledTime,
RetryFailedFlows,
Expand All @@ -51,7 +51,7 @@ class CoreTaskPolicy(BaseOrchestrationPolicy):
def priority():
return [
CacheRetrieval,
PreventTaskTransitionsFromTerminalStates,
HandleTaskTerminalStateTransitions,
PreventRedundantTransitions,
SecureTaskConcurrencySlots, # retrieve cached states even if slots are full
WaitForScheduledTime,
Expand Down Expand Up @@ -421,7 +421,7 @@ async def after_transition(
context.run.flow_run_run_count = self.flow_run.run_count


class PreventTaskTransitionsFromTerminalStates(BaseOrchestrationRule):
class HandleTaskTerminalStateTransitions(BaseOrchestrationRule):
"""
Prevents transitions from terminal states.
Expand Down Expand Up @@ -475,7 +475,7 @@ async def cleanup(
context.run.run_count = self.original_run_count


class PreventFlowTransitionsFromTerminalStates(BaseOrchestrationRule):
class HandleFlowTerminalStateTransitions(BaseOrchestrationRule):
"""
Prevents transitions from terminal states.
Expand Down
28 changes: 14 additions & 14 deletions tests/orion/orchestration/test_core_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from prefect.orion.orchestration.core_policy import (
CacheInsertion,
CacheRetrieval,
PreventFlowTransitionsFromTerminalStates,
PreventRedundantTransitions,
PreventTaskTransitionsFromTerminalStates,
HandleTaskTerminalStateTransitions,
HandleFlowTerminalStateTransitions,
ReleaseTaskConcurrencySlots,
RenameReruns,
RetryFailedFlows,
Expand Down Expand Up @@ -350,7 +350,7 @@ async def test_cannot_manual_retry_without_awaitingretry_state_name(
session,
initialize_orchestration,
):
manual_retry_policy = [PreventFlowTransitionsFromTerminalStates]
manual_retry_policy = [HandleFlowTerminalStateTransitions]
initial_state_type = states.StateType.FAILED
proposed_state_type = states.StateType.SCHEDULED
intended_transition = (initial_state_type, proposed_state_type)
Expand All @@ -376,7 +376,7 @@ async def test_cannot_manual_retry_without_deployment(
session,
initialize_orchestration,
):
manual_retry_policy = [PreventFlowTransitionsFromTerminalStates]
manual_retry_policy = [HandleFlowTerminalStateTransitions]
initial_state_type = states.StateType.FAILED
proposed_state_type = states.StateType.SCHEDULED
intended_transition = (initial_state_type, proposed_state_type)
Expand All @@ -401,7 +401,7 @@ async def test_manual_retrying_works_even_when_exceeding_max_retries(
session,
initialize_orchestration,
):
manual_retry_policy = [PreventFlowTransitionsFromTerminalStates]
manual_retry_policy = [HandleFlowTerminalStateTransitions]
initial_state_type = states.StateType.FAILED
proposed_state_type = states.StateType.SCHEDULED
intended_transition = (initial_state_type, proposed_state_type)
Expand All @@ -427,7 +427,7 @@ async def test_manual_retrying_bypasses_terminal_state_protection(
session,
initialize_orchestration,
):
manual_retry_policy = [PreventFlowTransitionsFromTerminalStates]
manual_retry_policy = [HandleFlowTerminalStateTransitions]
initial_state_type = states.StateType.FAILED
proposed_state_type = states.StateType.SCHEDULED
intended_transition = (initial_state_type, proposed_state_type)
Expand Down Expand Up @@ -491,7 +491,7 @@ async def test_bypasses_terminal_state_rule_if_flow_is_retrying(
initialize_orchestration,
):
rerun_policy = [
PreventTaskTransitionsFromTerminalStates,
HandleTaskTerminalStateTransitions,
UpdateFlowRunTrackerOnTasks,
]
initial_state_type = states.StateType.FAILED
Expand Down Expand Up @@ -525,7 +525,7 @@ async def test_cannot_bypass_terminal_state_rule_if_exceeding_flow_runs(
initialize_orchestration,
):
rerun_policy = [
PreventTaskTransitionsFromTerminalStates,
HandleTaskTerminalStateTransitions,
UpdateFlowRunTrackerOnTasks,
]
initial_state_type = states.StateType.FAILED
Expand Down Expand Up @@ -560,7 +560,7 @@ async def test_bypasses_terminal_state_rule_if_configured_automatic_retries_is_e
# retries have been consumed

rerun_policy = [
PreventTaskTransitionsFromTerminalStates,
HandleTaskTerminalStateTransitions,
UpdateFlowRunTrackerOnTasks,
]
initial_state_type = states.StateType.FAILED
Expand Down Expand Up @@ -595,7 +595,7 @@ async def test_cleans_up_after_invalid_transition(
fizzling_rule,
):
rerun_policy = [
PreventTaskTransitionsFromTerminalStates,
HandleTaskTerminalStateTransitions,
UpdateFlowRunTrackerOnTasks,
fizzling_rule,
]
Expand Down Expand Up @@ -804,9 +804,9 @@ async def test_transitions_from_terminal_states_are_aborted(
)

if run_type == "task":
protection_rule = PreventTaskTransitionsFromTerminalStates
protection_rule = HandleTaskTerminalStateTransitions
elif run_type == "flow":
protection_rule = PreventFlowTransitionsFromTerminalStates
protection_rule = HandleFlowTerminalStateTransitions

state_protection = protection_rule(ctx, *intended_transition)

Expand All @@ -832,9 +832,9 @@ async def test_all_other_transitions_are_accepted(
)

if run_type == "task":
protection_rule = PreventTaskTransitionsFromTerminalStates
protection_rule = HandleTaskTerminalStateTransitions
elif run_type == "flow":
protection_rule = PreventFlowTransitionsFromTerminalStates
protection_rule = HandleFlowTerminalStateTransitions

state_protection = protection_rule(ctx, *intended_transition)

Expand Down

0 comments on commit d2c5f97

Please sign in to comment.