Skip to content

Commit

Permalink
Partially revert changes to Prerequisite
Browse files Browse the repository at this point in the history
  • Loading branch information
MetRonnie committed Oct 31, 2024
1 parent 0c5e639 commit fc3d674
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
25 changes: 7 additions & 18 deletions cylc/flow/prerequisite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -263,24 +256,20 @@ 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.
Updates cache with the result.
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(
Expand Down
20 changes: 8 additions & 12 deletions tests/integration/test_task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
],
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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},
],
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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')
]

Expand All @@ -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'),
]

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

0 comments on commit fc3d674

Please sign in to comment.