-
Notifications
You must be signed in to change notification settings - Fork 94
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
stop after cycle point: support offsets #5943
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The `stop after cycle point` can now be specified as an offset from the inital cycle point. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -993,6 +993,7 @@ def command_stop( | |
point = TaskID.get_standardised_point(cycle_point) | ||
if point is not None and self.pool.set_stop_point(point): | ||
self.options.stopcp = str(point) | ||
self.config.stop_point = point | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spotted during testing, the config stop_point isn't updated when it is modified via the CLI, but the config hold_point is. |
||
self.workflow_db_mgr.put_workflow_stop_cycle_point( | ||
self.options.stopcp) | ||
elif clock_time is not None: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. | ||
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Test logic pertaining to the stop after cycle points. | ||
|
||
This may be defined in different ways: | ||
* In the workflow configuration. | ||
* On the command line. | ||
* Or loaded from the database. | ||
|
||
When the workflow hits the "stop after" point, it should be wiped (i.e. set | ||
to None). | ||
""" | ||
|
||
from typing import Optional | ||
|
||
from cylc.flow.cycling.integer import IntegerPoint | ||
from cylc.flow.id import Tokens | ||
from cylc.flow.workflow_status import StopMode | ||
|
||
|
||
async def test_stop_after_cycle_point( | ||
flow, | ||
scheduler, | ||
run, | ||
reflog, | ||
complete, | ||
): | ||
"""Test the stop after cycle point. | ||
|
||
This ensures: | ||
* The stop after point gets loaded from the config. | ||
* The workflow stops when it hits this point. | ||
* The point gets wiped when the workflow hits this point. | ||
* The point is stored/retrieved from the DB as appropriate. | ||
|
||
""" | ||
async def stops_after_cycle(schd) -> Optional[str]: | ||
"""Run the workflow until it stops and return the cycle point.""" | ||
triggers = reflog(schd) | ||
await complete(schd, timeout=2) | ||
assert len(triggers) == 1 # only one task (i.e. cycle) should be run | ||
return Tokens(list(triggers)[0][0], relative=True)['cycle'] | ||
|
||
def get_db_value(schd) -> Optional[str]: | ||
"""Return the cycle point value stored in the DB.""" | ||
with schd.workflow_db_mgr.get_pri_dao() as pri_dao: | ||
return dict(pri_dao.select_workflow_params())['stopcp'] | ||
|
||
config = { | ||
'scheduling': { | ||
'cycling mode': 'integer', | ||
'initial cycle point': '1', | ||
'stop after cycle point': '1', | ||
'graph': { | ||
'P1': 'a[-P1] => a', | ||
}, | ||
}, | ||
} | ||
id_ = flow(config) | ||
schd = scheduler(id_, paused_start=False) | ||
async with run(schd): | ||
# the cycle point should be loaded from the workflow configuration | ||
assert schd.config.stop_point == IntegerPoint('1') | ||
|
||
# this value should *not* be written to the database | ||
assert get_db_value(schd) is None | ||
|
||
# the workflow should stop after cycle 1 | ||
assert await stops_after_cycle(schd) == '1' | ||
|
||
# change the configured cycle point to "2" | ||
config['scheduling']['stop after cycle point'] = '2' | ||
id_ = flow(config, id_=id_) | ||
schd = scheduler(id_, paused_start=False) | ||
async with run(schd): | ||
# the cycle point should be reloaded from the workflow configuration | ||
assert schd.config.stop_point == IntegerPoint('2') | ||
|
||
# this value should not be written to the database | ||
assert get_db_value(schd) is None | ||
|
||
# the workflow should stop after cycle 2 | ||
assert await stops_after_cycle(schd) == '2' | ||
|
||
# override the configured value via the CLI option | ||
schd = scheduler(id_, paused_start=False, **{'stopcp': '3'}) | ||
async with run(schd): | ||
# the CLI should take precedence over the config | ||
assert schd.config.stop_point == IntegerPoint('3') | ||
|
||
# this value *should* be written to the database | ||
assert get_db_value(schd) == '3' | ||
|
||
# the workflow should stop after cycle 3 | ||
assert await stops_after_cycle(schd) == '3' | ||
|
||
# once the workflow hits this point, it should get cleared | ||
assert get_db_value(schd) is None | ||
|
||
schd = scheduler(id_, paused_start=False) | ||
async with run(schd): | ||
# the workflow should fall back to the configured value | ||
assert schd.config.stop_point == IntegerPoint('2') | ||
|
||
# override this value whilst the workflow is running | ||
schd.command_stop( | ||
cycle_point=IntegerPoint('4'), | ||
mode=StopMode.REQUEST_CLEAN, | ||
) | ||
assert schd.config.stop_point == IntegerPoint('4') | ||
|
||
# the new *should* be written to the database | ||
assert get_db_value(schd) == '4' | ||
|
||
schd = scheduler(id_, paused_start=False) | ||
async with run(schd): | ||
# the workflow should stop after cycle 4 | ||
assert await stops_after_cycle(schd) == '4' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new parsec validator type which does the same thing as
V_STRING
.It exists purely for documentation purposes.