-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vr: restart the workflow with no changes according to user prompt
* Closes #6261 * If there are no changes to reinstall AND the workflow is stopped, prompt the user to see whether they want to restart it anyway. * This makes `cylc vr` more useful as the "I want to restart my workflow" command. * But it also ensures that they are aware if no changes are present as they might have forgotten to press save or run the command on the wrong workflow or whatever.
- Loading branch information
1 parent
8bb1f44
commit b50f4e2
Showing
6 changed files
with
197 additions
and
40 deletions.
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 @@ | ||
Fix an issue that could cause clock-expired tasks to be erroneously retried if "execution retry delays" were configured. |
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,15 @@ | ||
# 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/>. |
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,56 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# 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/>. | ||
|
||
from types import SimpleNamespace | ||
from uuid import uuid1 | ||
|
||
import pytest | ||
|
||
from cylc.flow.workflow_files import WorkflowFiles | ||
|
||
from ..utils.flow_writer import flow_config_str | ||
|
||
|
||
@pytest.fixture | ||
def one_src(tmp_path, one_conf): | ||
src_dir = tmp_path | ||
(src_dir / 'flow.cylc').write_text(flow_config_str(one_conf)) | ||
(src_dir / 'rose-suite.conf').touch() | ||
return SimpleNamespace(path=src_dir) | ||
|
||
|
||
@pytest.fixture | ||
def one_run(one_src, test_dir, run_dir): | ||
w_run_dir = test_dir / str(uuid1()) | ||
w_run_dir.mkdir() | ||
(w_run_dir / 'flow.cylc').write_text( | ||
(one_src.path / 'flow.cylc').read_text() | ||
) | ||
(w_run_dir / 'rose-suite.conf').write_text( | ||
(one_src.path / 'rose-suite.conf').read_text() | ||
) | ||
install_dir = (w_run_dir / WorkflowFiles.Install.DIRNAME) | ||
install_dir.mkdir(parents=True) | ||
(install_dir / WorkflowFiles.Install.SOURCE).symlink_to( | ||
one_src.path, | ||
target_is_directory=True, | ||
) | ||
return SimpleNamespace( | ||
path=w_run_dir, | ||
id=str(w_run_dir.relative_to(run_dir)), | ||
) |
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,87 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# 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/>. | ||
|
||
from cylc.flow.option_parsers import Options | ||
from cylc.flow.scripts.validate_reinstall import ( | ||
get_option_parser as vr_gop, | ||
vr_cli, | ||
) | ||
|
||
ValidateReinstallOptions = Options(vr_gop()) | ||
|
||
|
||
async def test_prompt_for_running_workflow_with_no_changes( | ||
monkeypatch, | ||
caplog, | ||
capsys, | ||
log_filter, | ||
one_run, | ||
): | ||
"""It should reinstall and restart the workflow with no changes. | ||
See: https://github.com/cylc/cylc-flow/issues/6261 | ||
We hope to get users into the habbit of "cylc vip" to create a new run, | ||
and "cylc vr" to contine an old one (picking up any new changes in the | ||
process). | ||
This works fine, unless there are no changes to reinstall, in which case | ||
the "cylc vr" command exits (nothing to do). | ||
The "nothing to reinstall" situation can be interpretted two ways: | ||
1. Unexpected error, the user expected there to be something to reinstall, | ||
but there wasn't. E.g, they forgot to press save. | ||
2. Unexpected annoyance, I wanted to restart the workflow, just do it. | ||
To handle this we explain that there are no changes to reinstall and | ||
prompt the user to see if they want to press save or restart the workflow. | ||
""" | ||
# answer "y" to all prompts | ||
def _input(prompt): | ||
print(prompt) | ||
return 'y' | ||
|
||
monkeypatch.setattr( | ||
'cylc.flow.scripts.validate_reinstall._input', | ||
_input, | ||
) | ||
|
||
# make it look like we are running this command in a terminal | ||
monkeypatch.setattr( | ||
'cylc.flow.scripts.validate_reinstall.is_terminal', | ||
lambda: True | ||
) | ||
monkeypatch.setattr( | ||
'cylc.flow.scripts.reinstall.is_terminal', | ||
lambda: True | ||
) | ||
|
||
# attempt to restart it with "cylc vr" | ||
ret = await vr_cli( | ||
vr_gop(), ValidateReinstallOptions(), one_run.id | ||
) | ||
|
||
# the workflow should reinstall | ||
assert ret | ||
|
||
# the user should have been warned that there were no changes to reinstall | ||
assert log_filter(caplog, contains='No changes to reinstall') | ||
|
||
# they should have been presented with a prompt | ||
# (to which we have hardcoded the response "y") | ||
assert 'Restart anyway?' in capsys.readouterr()[0] |