Skip to content

Commit

Permalink
cylc reinstall --dry-run (#4964)
Browse files Browse the repository at this point in the history
* reinstall: add --dry-run option

* cli: improve command descriptions

* Shorten/simplify the first line of a couple of command descriptions.
* Add `cylc clean` and `cylc gui` to the list of "selected sub-commands"
  which are listed by default in the `cylc help` page.
* Ensure there is one newline after each description (fixes spacing
  issue with the auto-added ID help).

* cli: put headings in help text in bold

* Makes the CLI --help easier to skim by making section headings
  more obvious.

* reinstall: perform interactive --dry-run by default

* New behaviour:
  * In interactive mode:
    * Perform dry run.
    * Display proposed changes to the user.
    * Prompt for permission to continue.
    * Provide explanatory docs in the --help.
  * In non-interactive mode (unlikely use case for reinstall):
    * Just do it.
* Misc changes:
  * Use the globalcfg configured rsync command for `cylc install`
    (was using hardcoded `rsync`).
  * Improved reinstall docs.

* changelog

* Style fix.

Co-authored-by: Hilary James Oliver <[email protected]>
  • Loading branch information
oliver-sanders and hjoliver authored Jul 20, 2022
1 parent 2243c39 commit 448e792
Show file tree
Hide file tree
Showing 32 changed files with 724 additions and 81 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Fourth Release Candidate for Cylc 8 suitable for acceptance testing.

### Enhancements

[#4964](https://github.com/cylc/cylc-flow/pull/4964) -
`cylc reinstall` now displays the changes it would make when run
interactively and has improved help / documentaiton.

[#4836](https://github.com/cylc/cylc-flow/pull/4836) - The log directory has
been tidied. Workflow logs are now found in `log/scheduler` rather than
`log/workflow`, filenames now include `start`/`restart`. Other minor directory
Expand Down
6 changes: 4 additions & 2 deletions cylc/flow/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1286,8 +1286,10 @@ def default_for(
VDR.V_STRING,
'rsync',
desc='''
Command used for remote file installation. This supports POSIX
compliant rsync implementation e.g. GNU or BSD.
Command used for file installation.
This supports POSIX compliant rsync implementations e.g. GNU or
BSD.
.. versionadded:: 8.0.0
''')
Expand Down
30 changes: 26 additions & 4 deletions cylc/flow/option_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from typing import Any, Dict, Optional, List, Tuple

from cylc.flow import LOG
from cylc.flow.terminal import supports_color
from cylc.flow.terminal import supports_color, DIM
import cylc.flow.flags
from cylc.flow.loggingutil import (
CylcLogFormatter,
Expand Down Expand Up @@ -70,9 +70,29 @@ def format_shell_examples(string):
return cparse(
re.sub(
r'^(\s*(?:\$[^#]+)?)(#.*)$',
r'\1<dim>\2</dim>',
rf'\1<{DIM}>\2</{DIM}>',
string,
flags=re.M
flags=re.M,
)
)


def format_help_headings(string):
"""Put "headings" in bold.
Where "headings" are lines with no indentation which are followed by a
colon e.g:
Examples:
...
"""
return cparse(
re.sub(
r'^(\w.*:)$',
r'<bold>\1</bold>',
string,
flags=re.M,
)
)

Expand Down Expand Up @@ -183,7 +203,9 @@ def _format(self, text):
)
):
# Add color formatting to examples text.
text = format_shell_examples(text)
text = format_shell_examples(
format_help_headings(text)
)
else:
# Strip any hardwired formatting
text = cstrip(text)
Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/scripts/check_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
Use -v/--verbose to see the command invoked to determine the remote version
(all remote cylc command invocations will be of the same form, which may be
site dependent -- see cylc global config documentation."""
site dependent -- see cylc global config documentation.
"""

import sys
from typing import TYPE_CHECKING
Expand Down
6 changes: 4 additions & 2 deletions cylc/flow/scripts/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

"""cylc clean [OPTIONS] ARGS
Remove a stopped workflow from the local scheduler filesystem and remote hosts.
Delete a stopped workflow.
Remove workflow files from the local scheduler filesystem and any remote hosts
the workflow was installed on.
NOTE: this command is intended for workflows installed with `cylc install`. If
this is run for a workflow that was instead written directly in ~/cylc-run and
Expand Down Expand Up @@ -54,7 +57,6 @@
# Only remove the workflow on remote install targets
$ cylc clean foo/bar --remote-only
"""

import asyncio
Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/scripts/cycle_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
$ export CYLC_TASK_CYCLE_POINT=2010-08
$ export MYTEMPLATE=foo-CCYY-MM.nc
$ cylc cycle-point --offset-years=2 --template=MYTEMPLATE
foo-2012-08.nc"""
foo-2012-08.nc
"""

import os
import sys
Expand Down
8 changes: 5 additions & 3 deletions cylc/flow/scripts/cylc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import pkg_resources

from cylc.flow import __version__, iter_entry_points
from cylc.flow.option_parsers import format_shell_examples
from cylc.flow.option_parsers import (
format_help_headings,
format_shell_examples,
)
from cylc.flow.scripts.common import cylc_header


Expand Down Expand Up @@ -173,8 +176,7 @@ def get_version(long=False):

# because this command is not served from behind cli_function like the
# other cylc commands we have to manually patch in colour support
USAGE = format_shell_examples(USAGE)
USAGE = cparse(USAGE)
USAGE = cparse(format_help_headings(format_shell_examples(USAGE)))

# all sub-commands
# {name: entry_point}
Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/scripts/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
after inlining has occurred.
Files in the workflow bin directory and other sub-directories of the
run directory are not currently differenced."""
run directory are not currently differenced.
"""

import sys
from typing import TYPE_CHECKING
Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/scripts/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
$ cylc dump --tasks --sort WORKFLOW_ID | grep running
# Display the state of all tasks in a particular cycle point:
$ cylc dump -t WORKFLOW_ID | grep 2010082406"""
$ cylc dump -t WORKFLOW_ID | grep 2010082406
"""

from graphene.utils.str_converters import to_snake_case
import json
Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/scripts/ext_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
Use the retry options in case the target workflow is down or out of contact.
Note: to manually trigger a task use 'cylc trigger', not this command."""
Note: to manually trigger a task use 'cylc trigger', not this command.
"""

from time import sleep
from typing import TYPE_CHECKING
Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/scripts/get_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
$ cylc get-resources tutorial/runtime-tutorial
# copy all of the tutorials to your "source" directory:
$ cylc get-resources tutorial"""
$ cylc get-resources tutorial
"""

import sys

Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/scripts/get_workflow_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

"""cylc get-workflow-contact [OPTIONS] ARGS
Print contact information of a running workflow."""
Print contact information of a running workflow.
"""

from typing import TYPE_CHECKING

Expand Down
1 change: 0 additions & 1 deletion cylc/flow/scripts/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
The same workflow can be installed with multiple names; this results in
multiple workflow run directories that link to the same workflow definition.
"""

from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion cylc/flow/scripts/jobs_kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
Read job status files to obtain the names of the job runners and the job IDs
in the runners. Invoke the relevant job runner commands to ask the job runners
to terminate the jobs.
"""

from cylc.flow.job_runner_mgr import JobRunnerManager
from cylc.flow.option_parsers import CylcOptionParser as COP
from cylc.flow.terminal import cli_function
Expand Down
2 changes: 1 addition & 1 deletion cylc/flow/scripts/jobs_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
Read job status files to obtain the statuses of the jobs. If necessary, Invoke
the relevant job runner commands to ask the job runners for more statuses.
"""

from cylc.flow.job_runner_mgr import JobRunnerManager
from cylc.flow.option_parsers import CylcOptionParser as COP
from cylc.flow.terminal import cli_function
Expand Down
2 changes: 1 addition & 1 deletion cylc/flow/scripts/jobs_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
Submit task jobs to relevant job runners.
On a remote job host, this command reads the job files from STDIN.
"""

from cylc.flow.option_parsers import CylcOptionParser as COP
from cylc.flow.terminal import cli_function
from cylc.flow.job_runner_mgr import JobRunnerManager
Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/scripts/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
groupings that are collapsible in cylc visualisation tools.
To visualize the full multiple inheritance hierarchy use:
$ cylc graph -n"""
$ cylc graph -n
"""

import os
import sys
Expand Down
Loading

0 comments on commit 448e792

Please sign in to comment.