Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially revert changes to Prerequisite #64

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Comment on lines -107 to -111
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these unused, some re-added after being removed in cylc#6293


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
Loading