Skip to content

Commit

Permalink
Update cylc/flow/scripts/view.py
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver Sanders <[email protected]>
  • Loading branch information
wxtim and oliver-sanders committed Jan 10, 2023
1 parent 10c2711 commit a620f92
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
49 changes: 22 additions & 27 deletions cylc/flow/scripts/validate_reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,28 @@

"""cylc validate-reinstall [OPTIONS] ARGS
Validate and reinstall a single workflow. Then if:
- Workflow running => reload.
- Workflow paused => resume.
- Workflow stopped => play.
Validate, reinstall and apply changes to a workflow.
This command is equivalent to:
$ cylc validate myworkflow --against-source # See note 1
$ cylc reinstall myworkflow
# if myworkflow is running:
$ cylc reload myworkflow
# else:
$ cylc play myworkflow
Validate and reinstall a workflow then either:
Note 1:
* "Reload" the workflow (if it is running),
* or "play" it (if it is stopped).
Cylc validate myworkflow --against-source is equivalent of (without writing
any temporary files though):
# Install from run directory
$ cylc install ~/cylc-run/myworkflow -n temporary
# Install from source directory over the top
$ cylc install /path/to/myworkflow -n temporary
# Validate combined config
$ cylc validate ~/cylc-run/temporary
This command is equivalent to:
$ cylc validate myworkflow --against-source
$ cylc reinstall myworkflow
# if myworkflow is running:
$ cylc reload myworkflow
# else:
$ cylc play myworkflow
Note:
"cylc validate --against-source" checks the code in the workflow source
directory against any options (e.g. template variables) which have been set
in the installed workflow to ensure the change can be safely applied.
"""

import sys
from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand Down Expand Up @@ -75,7 +70,7 @@


CYLC_ROSE_OPTIONS = COP.get_cylc_rose_options()
VRO_OPTIONS = combine_options(
VR_OPTIONS = combine_options(
VALIDATE_OPTIONS,
REINSTALL_CYLC_ROSE_OPTIONS,
PLAY_OPTIONS,
Expand All @@ -91,14 +86,14 @@ def get_option_parser() -> COP:
jset=True,
argdoc=[WORKFLOW_ID_ARG_DOC],
)
for option in VRO_OPTIONS:
for option in VR_OPTIONS:
parser.add_option(*option.args, **option.kwargs)
return parser


@cli_function(get_option_parser)
def main(parser: COP, options: 'Values', workflow_id: str):
vro_cli(parser, options, workflow_id)
sys.exit(vro_cli(parser, options, workflow_id))


def vro_cli(parser: COP, options: 'Values', workflow_id: str):
Expand Down Expand Up @@ -130,7 +125,7 @@ def vro_cli(parser: COP, options: 'Values', workflow_id: str):
log_subcommand('reinstall', workflow_id)
reinstall_ok = cylc_reinstall(options, workflow_id)
if not reinstall_ok:
exit(0)
return 1

# Run reload if workflow is running, else play:
if workflow_running:
Expand All @@ -143,7 +138,7 @@ def vro_cli(parser: COP, options: 'Values', workflow_id: str):
'play',
workflow_id,
options,
compound_script_opts=VRO_OPTIONS,
compound_script_opts=VR_OPTIONS,
script_opts=(
PLAY_OPTIONS + CYLC_ROSE_OPTIONS
+ parser.get_std_options()
Expand Down
1 change: 0 additions & 1 deletion cylc/flow/scripts/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"""

import asyncio

from typing import TYPE_CHECKING

from cylc.flow.id_cli import parse_id_async
Expand Down

0 comments on commit a620f92

Please sign in to comment.