From b18ef2cb80cf29fd074fd54248710ead96b8c162 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Thu, 10 Feb 2022 22:49:18 +0000 Subject: [PATCH 1/3] Tidy --- cylc/flow/scripts/clean.py | 6 +++--- tests/unit/scripts/test_clean.py | 19 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/cylc/flow/scripts/clean.py b/cylc/flow/scripts/clean.py index df0c68e5836..d9a25abba31 100644 --- a/cylc/flow/scripts/clean.py +++ b/cylc/flow/scripts/clean.py @@ -32,7 +32,7 @@ # Remove the workflow at ~/cylc-run/foo/bar $ cylc clean foo/bar - # Remove multiple workflows + # Remove multiple workflows $ cylc clean one two three # Remove the workflow's log directory @@ -86,7 +86,7 @@ def get_option_parser(): '--rm', metavar='DIR[:DIR:...]', help=("Only clean the specified subdirectories (or files) in the " "run directory, rather than the whole run directory. " - "Accepts quoted globs. Implies --verbose."), + "Accepts quoted globs."), action='append', dest='rm_dirs', default=[] ) @@ -125,7 +125,7 @@ def get_option_parser(): def prompt(workflows): - print('Would remove the following workflows:') + print("Would clean the following workflows:") for workflow in workflows: print(f' {workflow}') diff --git a/tests/unit/scripts/test_clean.py b/tests/unit/scripts/test_clean.py index 313ed6da35a..dc29d7ba1b6 100644 --- a/tests/unit/scripts/test_clean.py +++ b/tests/unit/scripts/test_clean.py @@ -16,11 +16,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from types import SimpleNamespace +from typing import Callable, List import pytest -from cylc.flow.scripts.clean import scan, run +from cylc.flow.scripts.clean import CleanOptions, scan, run async def test_scan(tmp_run_dir): @@ -44,7 +44,7 @@ async def test_scan(tmp_run_dir): @pytest.fixture -def mute(monkeypatch): +def mute(monkeypatch: pytest.MonkeyPatch) -> List[str]: """Stop cylc clean from doing anything and log all init_clean calls.""" items = [] @@ -58,11 +58,10 @@ def _clean(id_, *_): return items -async def test_multi(tmp_run_dir, mute): +async def test_multi(tmp_run_dir: Callable, mute: List[str]): """It supports cleaning multiple workflows.""" # cli opts - opts = SimpleNamespace() - opts.force = False + opts = CleanOptions() # create three dummy workflows tmp_run_dir('bar/pub/beer') @@ -70,22 +69,22 @@ async def test_multi(tmp_run_dir, mute): tmp_run_dir('foo') # an explicit workflow ID goes straight through - mute[:] = [] + mute.clear() await run('foo', opts=opts) assert mute == ['foo'] # a partial hierarchical ID gets expanded to all workflows contained # in the hierarchy (note runs are a special case of hierarchical ID) - mute[:] = [] + mute.clear() await run('bar', opts=opts) assert mute == ['bar/pub/beer'] # test a mixture of explicit and partial IDs - mute[:] = [] + mute.clear() await run('bar', 'baz', 'foo', opts=opts) assert mute == ['bar/pub/beer', 'baz/run1', 'foo'] # test a glob - mute[:] = [] + mute.clear() await run('*', opts=opts) assert mute == ['bar/pub/beer', 'baz/run1', 'foo'] From 5f69afbd26561ef504fcc3978439cb63a9488440 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Thu, 10 Feb 2022 22:49:43 +0000 Subject: [PATCH 2/3] cylc clean: rename --force to --yes --- cylc/flow/scripts/clean.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cylc/flow/scripts/clean.py b/cylc/flow/scripts/clean.py index d9a25abba31..4ea87dc9055 100644 --- a/cylc/flow/scripts/clean.py +++ b/cylc/flow/scripts/clean.py @@ -103,12 +103,12 @@ def get_option_parser(): ) parser.add_option( - '--force', - help=("Allow cleaning of directories that contain workflow run dirs " - "(e.g. 'cylc clean foo' when foo contains run1, run2 etc.). " - "Warning: this might lead to remote installations and " - "symlink dir targets not getting removed."), - action='store_true', dest='force' + '--yes', '-y', + help=( + "Skip interactive prompt if trying to clean multiple " + "run directories at once." + ), + action='store_true', dest='skip_interactive' ) parser.add_option( @@ -137,7 +137,10 @@ def prompt(workflows): if ret.lower() == 'n': sys.exit(1) else: - print('Use --force to remove multiple workflows.', file=sys.stderr) + print( + "Use --yes to remove multiple workflows in non-interactive mode.", + file=sys.stderr + ) sys.exit(1) @@ -173,7 +176,7 @@ async def run(*ids, opts=None): workflows, multi_mode = await scan(workflows, multi_mode) workflows.sort() - if multi_mode and not opts.force: + if multi_mode and not opts.skip_interactive: prompt(workflows) # prompt for approval or exit for workflow in sorted(workflows): From 72b661ae3c748ca458a788344da0f35a0d81bea5 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Thu, 10 Feb 2022 23:18:39 +0000 Subject: [PATCH 3/3] Update changelog --- CHANGES.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2eca097233b..9636471193b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -54,15 +54,24 @@ First Release Candidate for Cylc 8. (See note on cylc-8 backward-incompatible changes, above) +Also note: you will not be able to restart workflows run with previous +Cylc 8 pre-releases due to changes in the workflow database structure +([#4581](https://github.com/cylc/cylc-flow/pull/4581)) + ### Enhancements -[#4581](https://github.com/cylc/cylc-flow/pull/4581) - Job and task history -is now loaded into the window about active tasks. Reflow future tasks now set -to waiting. +[#4581](https://github.com/cylc/cylc-flow/pull/4581) - Improvements allowing +the UI & TUI to remember more info about past tasks and jobs: +- Job and task history is now loaded into the window about active tasks. +- Reflow future tasks now set to waiting. [#3931](https://github.com/cylc/cylc-flow/pull/3931) - Convert Cylc to use the new "Universal Identifier". +[#3931](https://github.com/cylc/cylc-flow/pull/3931), +[#4675](https://github.com/cylc/cylc-flow/pull/4675) - `cylc clean` now +interactively prompts if trying to clean multiple run dirs. + [#4506](https://github.com/cylc/cylc-flow/pull/4506) - Cylc no longer creates a `flow.cylc` symlink to a `suite.rc` file. This only affects you if you have used a prior Cylc 8 pre-release. @@ -72,7 +81,7 @@ now configurable in `global.cylc[install]max depth`, and `cylc install` will fail if the workflow ID would exceed this depth. [#4534](https://github.com/cylc/cylc-flow/pull/4534) - Permit jobs -to be run on platforms with no $HOME directory. +to be run on platforms with no `$HOME` directory. [#4536](https://github.com/cylc/cylc-flow/pull/4536) - `cylc extract-resources` renamed `cylc get-resources` and small changes made: