From 965cbd153f5e8f2b5e868b397e3c79ce8510979f Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:00:12 +0000 Subject: [PATCH] Partially revert changes to `Prerequisite` --- cylc/flow/prerequisite.py | 25 +++++++------------------ tests/integration/test_task_pool.py | 20 ++++++++------------ 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/cylc/flow/prerequisite.py b/cylc/flow/prerequisite.py index 94221fd790..1edf7aa1da 100644 --- a/cylc/flow/prerequisite.py +++ b/cylc/flow/prerequisite.py @@ -74,7 +74,6 @@ def coerce(tuple_: AnyPrereqMessage) -> 'PrereqMessage': 'satisfied naturally', 'satisfied from database', 'satisfied by skip mode', - 'satisfied by simulation mode', 'force satisfied', False ] @@ -104,12 +103,6 @@ class Prerequisite: SATISFIED_TEMPLATE = 'bool(self._satisfied[("%s", "%s", "%s")])' MESSAGE_TEMPLATE = r'%s/%s %s' - DEP_STATE_SATISFIED: SatisfiedState = 'satisfied naturally' - DEP_STATE_SATISFIED_BY = 'satisfied by {} mode' - DEP_STATE_OVERRIDDEN = 'force satisfied' - DEP_STATE_UNSATISFIED = False - SATISFIED_MODE_RE = re.compile(r'satisfied by .* mode') - def __init__(self, point: 'PointBase'): # The cycle point to which this prerequisite belongs. # cylc.flow.cycling.PointBase @@ -263,8 +256,9 @@ def _eval_satisfied(self) -> bool: return res def satisfy_me( - self, outputs: Iterable['Tokens'], - mode: Optional[RunMode] = RunMode.LIVE + self, + outputs: Iterable['Tokens'], + mode: Optional[RunMode] = None, ) -> 'Set[Tokens]': """Attempt to satisfy me with given outputs. @@ -272,15 +266,10 @@ def satisfy_me( Return outputs that match. """ - satisfied_message: SatisfiedState - - if mode and mode != RunMode.LIVE: - # RunMode.value actually actually restricts the results in - # SatisfiedState, but MyPy does not recognize this. - satisfied_message = self.DEP_STATE_SATISFIED_BY.format( - RunMode(mode).value) # type: ignore - else: - satisfied_message = self.DEP_STATE_SATISFIED + satisfied_message: SatisfiedState = ( + 'satisfied by skip mode' if mode == RunMode.SKIP + else 'satisfied naturally' + ) valid = set() for output in outputs: prereq = PrereqMessage( diff --git a/tests/integration/test_task_pool.py b/tests/integration/test_task_pool.py index 6af4f92813..483b67cad2 100644 --- a/tests/integration/test_task_pool.py +++ b/tests/integration/test_task_pool.py @@ -645,8 +645,7 @@ def list_tasks(schd): ('1', 'z', 'waiting'), ], [ - {('1', 'a', 'succeeded'): - 'satisfied by simulation mode'}, + {('1', 'a', 'succeeded'): 'satisfied naturally'}, {('1', 'b', 'succeeded'): False}, {('1', 'c', 'succeeded'): False}, ], @@ -674,8 +673,7 @@ def list_tasks(schd): ('1', 'z', 'waiting'), ], [ - {('1', 'a', 'succeeded'): - 'satisfied by simulation mode'}, + {('1', 'a', 'succeeded'): 'satisfied naturally'}, {('1', 'b', 'succeeded'): False}, ], id='removed' @@ -770,8 +768,7 @@ async def test_restart_prereqs( ('1', 'z', 'waiting'), ], [ - {('1', 'a', 'succeeded'): - 'satisfied by simulation mode'}, + {('1', 'a', 'succeeded'): 'satisfied naturally'}, {('1', 'b', 'succeeded'): False}, {('1', 'c', 'succeeded'): False}, ], @@ -799,8 +796,7 @@ async def test_restart_prereqs( ('1', 'z', 'waiting'), ], [ - {('1', 'a', 'succeeded'): - 'satisfied by simulation mode'}, + {('1', 'a', 'succeeded'): 'satisfied naturally'}, {('1', 'b', 'succeeded'): False}, ], id='removed' @@ -899,7 +895,7 @@ async def _test_restart_prereqs_sat(): for prereq in task_c.state.prerequisites for key, satisfied in prereq.items() ) == [ - ('1', 'a', 'succeeded', 'satisfied by simulation mode'), + ('1', 'a', 'succeeded', 'satisfied naturally'), ('1', 'b', 'succeeded', 'satisfied from database') ] @@ -916,7 +912,7 @@ async def _test_restart_prereqs_sat(): for prereq in task_c_prereqs for condition in prereq.conditions ) == [ - ('1/a', True, 'satisfied by simulation mode'), + ('1/a', True, 'satisfied naturally'), ('1/b', True, 'satisfied from database'), ] @@ -2255,7 +2251,7 @@ async def list_data_store(): 'c': 'wall_clock(trigger_time=946688400)', } - + async def test_trigger_unqueued(flow, scheduler, start): """Test triggering an unqueued active task. @@ -2320,7 +2316,7 @@ async def test_expire_dequeue_with_retries(flow, scheduler, start, expire_type): if expire_type == 'clock-expire': conf['scheduling']['special tasks'] = {'clock-expire': 'foo(PT0S)'} - method = lambda schd: schd.pool.clock_expire_tasks() + method = lambda schd: schd.pool.clock_expire_tasks() else: method = lambda schd: schd.pool.set_prereqs_and_outputs( ['2000/foo'], prereqs=[], outputs=['expired'], flow=['1']