From 63146d5485f41c7c1329520b1cf8b77c9ddaabb6 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Mon, 11 Oct 2021 23:47:58 +0100 Subject: [PATCH] =?UTF-8?q?`~=5FW'FLOW=5FNAME`=20=E2=87=92=20`~=5FW'FLOW?= =?UTF-8?q?=5FID`=20and=20`~=5FW'FLOW=5FNAME`=20re-instated=20as=20Cylc7?= =?UTF-8?q?=20consistent=20(#4455)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * write test for new WORKFLOW_ID=foo/run1 and WORKFLOW_NAME=foo * Renamed CYLC_WORKFLOW_NAME ⇒ CYLC_WORKFLOW_ID Made CYLC_WORKFLOW_ID = CYLC_WORKFLOW_NAME - trailing "runX" * allow test_header init_workflow to set whether to use --no-run-name * fixed test for CYLC_WORKFLOW_ID * CHANGES.md added * Apply suggestions from code review Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> * remove unwanted files; add documentation for change to init_workflow * finished rename of runN_remover * added docstring as per @metronnie suggestion * remove accidental PR pollution * replaced refs in script docstrings to REG to WORKFLOW/ID/NAME * Apply suggestions from code review Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> * Fixed some review comments; fixed cylc play docstring! * fix test reliant on REG Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> --- CHANGES.md | 4 ++ cylc/flow/config.py | 7 ++- cylc/flow/option_parsers.py | 4 +- cylc/flow/pathutil.py | 12 ++++ cylc/flow/scheduler.py | 7 ++- cylc/flow/scheduler_cli.py | 16 +++--- cylc/flow/scripts/broadcast.py | 10 ++-- cylc/flow/scripts/cat_log.py | 2 +- cylc/flow/scripts/clean.py | 2 +- cylc/flow/scripts/client.py | 2 +- cylc/flow/scripts/config.py | 7 ++- cylc/flow/scripts/ext_trigger.py | 2 +- cylc/flow/scripts/get_workflow_contact.py | 2 +- cylc/flow/scripts/hold.py | 2 +- cylc/flow/scripts/install.py | 19 ++++--- cylc/flow/scripts/kill.py | 6 +- cylc/flow/scripts/message.py | 2 +- cylc/flow/scripts/pause.py | 2 +- cylc/flow/scripts/ping.py | 8 ++- cylc/flow/scripts/poll.py | 6 +- cylc/flow/scripts/reinstall.py | 2 +- cylc/flow/scripts/release.py | 2 +- cylc/flow/scripts/reload.py | 4 +- cylc/flow/scripts/remove.py | 2 +- cylc/flow/scripts/report_timings.py | 2 +- cylc/flow/scripts/set_outputs.py | 2 +- cylc/flow/scripts/set_verbosity.py | 2 +- cylc/flow/scripts/show.py | 8 +-- cylc/flow/scripts/stop.py | 2 +- cylc/flow/scripts/subscribe.py | 2 +- cylc/flow/scripts/trigger.py | 7 ++- cylc/flow/scripts/tui.py | 4 +- cylc/flow/scripts/workflow_state.py | 10 ++-- .../clock-expire/00-basic/flow.cylc | 2 +- tests/functional/cylc-install/00-simple.t | 12 ++-- tests/functional/cylc-play/07-provided-vars.t | 57 +++++++++++++++++++ tests/functional/lib/bash/test_header | 10 +++- 37 files changed, 173 insertions(+), 79 deletions(-) create mode 100644 tests/functional/cylc-play/07-provided-vars.t diff --git a/CHANGES.md b/CHANGES.md index 15f018db93b..8e4e45dad80 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -100,6 +100,10 @@ workflow directory are recorded by `log/version`. [#4404](https://github.com/cylc/cylc-flow/pull/4404) - The Cylc Graph section now accepts ``&`` and ``|`` as valid line breaks in the same way as ``=>``. +[#4455](https://github.com/cylc/cylc-flow/pull/4455) - `CYLC_WORKFLOW_NAME` +renamed to `CYLC_WORKFLOW_ID`. `CYLC_WORKFLOW_NAME` re-added as +`CYLC_WORKFLOW_ID` shorn of any trailing `runX`. + ### Fixes diff --git a/cylc/flow/config.py b/cylc/flow/config.py index d1f96eba6d7..e46199f950a 100644 --- a/cylc/flow/config.py +++ b/cylc/flow/config.py @@ -75,6 +75,7 @@ get_workflow_run_log_dir, get_workflow_run_share_dir, get_workflow_run_work_dir, + get_workflow_name_from_id ) from cylc.flow.platforms import FORBIDDEN_WITH_PLATFORM from cylc.flow.print_tree import print_tree @@ -182,7 +183,8 @@ def __init__( if self.mem_log is None: self.mem_log = lambda x: None self.mem_log("config.py:config.py: start init config") - self.workflow = workflow # workflow name + self.workflow = workflow # workflow id + self.workflow_name = get_workflow_name_from_id(self.workflow) self.fpath = str(fpath) # workflow definition self.fdir = os.path.dirname(fpath) self.run_dir = run_dir or get_workflow_run_dir(self.workflow) @@ -1366,7 +1368,8 @@ def process_workflow_env(self): """Workflow context is exported to the local environment.""" for key, value in { **verbosity_to_env(cylc.flow.flags.verbosity), - 'CYLC_WORKFLOW_NAME': self.workflow, + 'CYLC_WORKFLOW_ID': self.workflow, + 'CYLC_WORKFLOW_NAME': self.workflow_name, 'CYLC_WORKFLOW_RUN_DIR': self.run_dir, 'CYLC_WORKFLOW_LOG_DIR': self.log_dir, 'CYLC_WORKFLOW_WORK_DIR': self.work_dir, diff --git a/cylc/flow/option_parsers.py b/cylc/flow/option_parsers.py index 4ad2107e08a..15231f79924 100644 --- a/cylc/flow/option_parsers.py +++ b/cylc/flow/option_parsers.py @@ -177,9 +177,9 @@ def __init__( self.auto_add = auto_add if argdoc is None: if prep: - argdoc = [('WORKFLOW', 'Workflow name or path')] + argdoc = [('WORKFLOW | PATH', 'Workflow name or path')] else: - argdoc = [('REG', 'Workflow name')] + argdoc = [('WORKFLOW', 'Workflow name')] if '--color=never' not in '='.join(sys.argv[2:]): # Before option parsing, for `--help`, make comments grey in usage. diff --git a/cylc/flow/pathutil.py b/cylc/flow/pathutil.py index 1cca62ca66e..9dbfc17460e 100644 --- a/cylc/flow/pathutil.py +++ b/cylc/flow/pathutil.py @@ -409,3 +409,15 @@ def is_relative_to(path1: Union[Path, str], path2: Union[Path, str]) -> bool: except ValueError: return False return True + + +def get_workflow_name_from_id(workflow_id: str) -> str: + """Workflow name is the ID shorn of the runN directory name. + + Examples: + >>> get_workflow_name_from_id('my_workflow/run42') + 'my_workflow' + >>> get_workflow_name_from_id('my_other_workflow') + 'my_other_workflow' + """ + return re.sub(rf'{re.escape(os.sep)}run\d+$', '', workflow_id) diff --git a/cylc/flow/scheduler.py b/cylc/flow/scheduler.py index 238a0cd44a4..26c43fdc6c6 100644 --- a/cylc/flow/scheduler.py +++ b/cylc/flow/scheduler.py @@ -77,7 +77,8 @@ get_workflow_run_share_dir, get_workflow_run_work_dir, get_workflow_test_log_name, - make_workflow_run_tree + make_workflow_run_tree, + get_workflow_name_from_id ) from cylc.flow.platforms import ( get_install_target_from_platform, @@ -246,6 +247,7 @@ class Scheduler: def __init__(self, reg: str, options: Values) -> None: # flow information self.workflow = reg + self.workflow_name = get_workflow_name_from_id(self.workflow) self.owner = get_user() self.host = get_host() self.id = f'{self.owner}{ID_DELIM}{self.workflow}' @@ -1109,7 +1111,8 @@ def load_flow_file(self, is_reload=False): self.task_job_mgr.job_file_writer.set_workflow_env({ **verbosity_to_env(cylc.flow.flags.verbosity), 'CYLC_UTC': str(get_utc_mode()), - 'CYLC_WORKFLOW_NAME': self.workflow, + 'CYLC_WORKFLOW_ID': self.workflow, + 'CYLC_WORKFLOW_NAME': self.workflow_name, 'CYLC_CYCLING_MODE': str( self.config.cfg['scheduling']['cycling mode'] ), diff --git a/cylc/flow/scheduler_cli.py b/cylc/flow/scheduler_cli.py index 359f88c2053..fc1fedadee3 100644 --- a/cylc/flow/scheduler_cli.py +++ b/cylc/flow/scheduler_cli.py @@ -71,16 +71,18 @@ as satisfied. Examples: - # Start (at the initial cycle point), or restart, or resume workflow REG - $ cylc play REG + # Start (at the initial cycle point), restart, or resume workflow WORKFLOW + $ cylc play WORKFLOW # Start a new run from a cycle point after the initial cycle point - $ cylc play --start-cycle-point=3 REG # (integer cycling) - $ cylc play --start-cycle-point=20250101T0000Z REG # (datetime cycling) + # (integer cycling) + $ cylc play --start-cycle-point=3 WORKFLOW + # (datetime cycling): + $ cylc play --start-cycle-point=20250101T0000Z WORKFLOW # Start a new run from specified tasks in the graph - $ cylc play --start-task=foo.3 REG - $ cylc play -t foo.3 -t bar.3 REG + $ cylc play --start-task=foo.3 WORKFLOW + $ cylc play -t foo.3 -t bar.3 WORKFLOW # Start, restart or resume the second installed run of the workflow # "dogs/fido" @@ -91,7 +93,7 @@ """ -FLOW_NAME_ARG_DOC = ("REG", "Workflow name") +FLOW_NAME_ARG_DOC = ("WORKFLOW", "Workflow name or ID") RESUME_MUTATION = ''' mutation ( diff --git a/cylc/flow/scripts/broadcast.py b/cylc/flow/scripts/broadcast.py index 1d577d091da..c8fd1e475dc 100755 --- a/cylc/flow/scripts/broadcast.py +++ b/cylc/flow/scripts/broadcast.py @@ -48,20 +48,20 @@ Examples: # To broadcast a variable to all tasks (quote items with internal spaces): - $ cylc broadcast -s "[environment]VERSE = the quick brown fox" REG + $ cylc broadcast -s "[environment]VERSE = the quick brown fox" WORKFLOW # To do the same with a file: $ cat >'broadcast.cylc' <<'__FLOW__' $ [environment] $ VERSE = the quick brown fox $ __FLOW__ - $ cylc broadcast -F 'broadcast.cylc' REG + $ cylc broadcast -F 'broadcast.cylc' WORKFLOW # To cancel the same broadcast: - $ cylc broadcast --cancel "[environment]VERSE" REG + $ cylc broadcast --cancel "[environment]VERSE" WORKFLOW # If -F FILE was used, the same file can be used to cancel the broadcast: - $ cylc broadcast -G 'broadcast.cylc' REG + $ cylc broadcast -G 'broadcast.cylc' WORKFLOW Use -d/--display to see active broadcasts. Multiple --cancel options or multiple --set and --set-file options can be used on the same command line. @@ -224,7 +224,7 @@ def get_option_parser(): """CLI for "cylc broadcast".""" parser = COP( __doc__, comms=True, - argdoc=[('REG', "Workflow name")] + argdoc=[('WORKFLOW', 'Workflow name or ID')] ) parser.add_option( diff --git a/cylc/flow/scripts/cat_log.py b/cylc/flow/scripts/cat_log.py index 596647c8a4f..5aa9691adea 100755 --- a/cylc/flow/scripts/cat_log.py +++ b/cylc/flow/scripts/cat_log.py @@ -225,7 +225,7 @@ def get_option_parser(): parser = COP( __doc__, argdoc=[ - ("REG", "Workflow name"), + ("WORKFLOW", "Workflow name or ID"), ("[TASK-ID]", """Task ID""") ] ) diff --git a/cylc/flow/scripts/clean.py b/cylc/flow/scripts/clean.py index 6e11fbcf6be..e21d4b3e4c2 100644 --- a/cylc/flow/scripts/clean.py +++ b/cylc/flow/scripts/clean.py @@ -71,7 +71,7 @@ def get_option_parser(): parser = COP( __doc__, - argdoc=[('REG', "Workflow name")], + argdoc=[('WORKFLOW', 'Workflow name or ID')], segregated_log=True ) diff --git a/cylc/flow/scripts/client.py b/cylc/flow/scripts/client.py index 9ae02b5eab4..a2263b6d632 100755 --- a/cylc/flow/scripts/client.py +++ b/cylc/flow/scripts/client.py @@ -44,7 +44,7 @@ def get_option_parser(): parser = COP(__doc__, comms=True, argdoc=[ - ('REG', 'Workflow name'), + ('WORKFLOW', 'Workflow name or ID'), ('METHOD', 'Network API function name')]) parser.add_option( diff --git a/cylc/flow/scripts/config.py b/cylc/flow/scripts/config.py index 31079dbdbe5..d095c7bc580 100755 --- a/cylc/flow/scripts/config.py +++ b/cylc/flow/scripts/config.py @@ -20,8 +20,9 @@ Parse and print Cylc configuration files. -Print parsed configuration, after runtime inheritance. If REG is specified, -print the workflow configuration, otherwise print the global configuration. +Print parsed configuration, after runtime inheritance. If WORKFLOW is +specified, print the workflow configuration, otherwise print the global +configuration. Note: This is different to `cylc view` which doesn't parse the configuration, @@ -66,7 +67,7 @@ def get_option_parser(): parser = COP( __doc__, - argdoc=[("[REG]", "Workflow name or path")], + argdoc=[("[WORKFLOW]", "Workflow name, ID, or path")], jset=True, icp=True ) diff --git a/cylc/flow/scripts/ext_trigger.py b/cylc/flow/scripts/ext_trigger.py index a979727d4c3..9e4307b308b 100755 --- a/cylc/flow/scripts/ext_trigger.py +++ b/cylc/flow/scripts/ext_trigger.py @@ -75,7 +75,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, - argdoc=[("REG", "Workflow name"), + argdoc=[("WORKFLOW", "Workflow name or ID"), ("MSG", "External trigger message"), ("ID", "Unique trigger ID")]) diff --git a/cylc/flow/scripts/get_workflow_contact.py b/cylc/flow/scripts/get_workflow_contact.py index 033c66ef9d8..38568ad59d1 100755 --- a/cylc/flow/scripts/get_workflow_contact.py +++ b/cylc/flow/scripts/get_workflow_contact.py @@ -32,7 +32,7 @@ def get_option_parser(): - return COP(__doc__, argdoc=[('REG', 'Workflow name')]) + return COP(__doc__, argdoc=[('WORKFLOW', 'Workflow name or ID')]) @cli_function(get_option_parser) diff --git a/cylc/flow/scripts/hold.py b/cylc/flow/scripts/hold.py index 54370b76f97..71c9b366d0d 100755 --- a/cylc/flow/scripts/hold.py +++ b/cylc/flow/scripts/hold.py @@ -97,7 +97,7 @@ def get_option_parser() -> COP: parser = COP( __doc__, comms=True, multitask=True, argdoc=[ - ('REG', "Workflow name"), + ('WORKFLOW', 'Workflow name or ID'), # TODO: switch back to TASK_ID? ('[TASK_GLOB ...]', "Task matching patterns")] ) diff --git a/cylc/flow/scripts/install.py b/cylc/flow/scripts/install.py index bbf221b4480..f0b79003fd7 100755 --- a/cylc/flow/scripts/install.py +++ b/cylc/flow/scripts/install.py @@ -22,18 +22,18 @@ The workflow can then be started, stopped, and targeted by name. -Normal installation creates a directory "~/cylc-run/REG/", with a run -directory "~/cylc-run/REG/run1". A "_cylc-install/source" symlink to the source -directory will be created in the REG directory. +Normal installation creates a directory "~/cylc-run/WORKFLOW_NAME/", with a run +directory "~/cylc-run/WORKFLOW_NAME/run1". A "_cylc-install/source" symlink to +the source directory will be created in the WORKFLOW_NAME directory. Any files or directories (excluding .git, .svn) from the source directory are copied to the new run directory. A ".service" directory will also be created and used for server authentication files at run time. -If the argument REG is used, Cylc will search for the workflow in the list of -directories given by "global.cylc[install]source dirs", and install the first -match. Otherwise, the workflow in the current working directory, or the one -specified by the "--directory" option, will be installed. +If the argument WORKFLOW_NAME is used, Cylc will search for the workflow in the +list of directories given by "global.cylc[install]source dirs", and install the +first match. Otherwise, the workflow in the current working directory, or the +one specified by the "--directory" option, will be installed. Workflow names can be hierarchical, corresponding to the path under ~/cylc-run. @@ -86,7 +86,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, prep=True, - argdoc=[("[REG]", "Workflow name")] + argdoc=[('[WORKFLOW_NAME]', 'Workflow name')] ) parser.add_option( @@ -153,7 +153,8 @@ def install( source = opts.source else: if opts.source: - parser.error("REG and --directory are mutually exclusive.") + parser.error( + "WORKFLOW_NAME and --directory are mutually exclusive.") source = search_install_source_dirs(reg) flow_name = opts.flow_name or reg diff --git a/cylc/flow/scripts/kill.py b/cylc/flow/scripts/kill.py index dbd1daa4af9..f054965aaf4 100755 --- a/cylc/flow/scripts/kill.py +++ b/cylc/flow/scripts/kill.py @@ -21,8 +21,8 @@ Kill running or submitted jobs. Examples: - $ cylc kill REG # kill all active tasks in the workflow - $ cylc kill REG TASK_GLOB ... # kill one or more active tasks + $ cylc kill WORKFLOW # kill all active tasks in the workflow + $ cylc kill WORKFLOW TASK_GLOB ... # kill one or more active tasks """ from typing import TYPE_CHECKING @@ -55,7 +55,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, multitask=True, argdoc=[ - ('REG', 'Workflow name'), + ('WORKFLOW', 'Workflow name or ID'), ('[TASK_GLOB ...]', 'Task matching patterns')]) return parser diff --git a/cylc/flow/scripts/message.py b/cylc/flow/scripts/message.py index ca1a637ffb4..d887c4dd4c1 100755 --- a/cylc/flow/scripts/message.py +++ b/cylc/flow/scripts/message.py @@ -90,7 +90,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, argdoc=[ - ('[REG]', 'Workflow name'), + ('[WORKFLOW]', 'Workflow name or ID'), ('[TASK-JOB]', 'Task job identifier CYCLE/TASK_NAME/SUBMIT_NUM'), ('[[SEVERITY:]MESSAGE ...]', 'Messages')]) parser.add_option( diff --git a/cylc/flow/scripts/pause.py b/cylc/flow/scripts/pause.py index 247826c4443..00893407d73 100644 --- a/cylc/flow/scripts/pause.py +++ b/cylc/flow/scripts/pause.py @@ -57,7 +57,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, multitask=True, - argdoc=[('REG', "Workflow name")] + argdoc=[('WORKFLOW', 'Workflow name or ID')] ) return parser diff --git a/cylc/flow/scripts/ping.py b/cylc/flow/scripts/ping.py index b2b1592da40..e648b13851c 100755 --- a/cylc/flow/scripts/ping.py +++ b/cylc/flow/scripts/ping.py @@ -20,7 +20,7 @@ Test communication with a running workflow. -If workflow REG is running or TASK in workflow REG is currently running, +If workflow WORKFLOW is running or TASK in WORKFLOW is currently running, exit with success status, else exit with error status.""" from ansimarkup import parse as cparse @@ -65,7 +65,11 @@ def get_option_parser(): parser = COP( __doc__, comms=True, - argdoc=[('REG', 'Workflow name'), ('[TASK]', 'Task ' + TaskID.SYNTAX)]) + argdoc=[ + ('WORKFLOW', 'Workflow name or ID'), + ('[TASK]', 'Task ' + TaskID.SYNTAX) + ] + ) return parser diff --git a/cylc/flow/scripts/poll.py b/cylc/flow/scripts/poll.py index 9bf4e665a8e..e9378ad4055 100755 --- a/cylc/flow/scripts/poll.py +++ b/cylc/flow/scripts/poll.py @@ -21,8 +21,8 @@ Poll (query) task jobs to verify and update their statuses. Examples: - $ cylc poll REG # poll all active tasks - $ cylc poll REG TASK_GLOB # poll multiple active tasks or families + $ cylc poll WORKFLOW # poll all active tasks + $ cylc poll WORKFLOW TASK_GLOB # poll multiple active tasks or families """ from typing import TYPE_CHECKING @@ -55,7 +55,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, multitask=True, argdoc=[ - ('REG', 'Workflow name'), + ('WORKFLOW', 'Workflow name or ID'), ('[TASK_GLOB ...]', 'Task matching patterns')] ) return parser diff --git a/cylc/flow/scripts/reinstall.py b/cylc/flow/scripts/reinstall.py index dbb70447572..93c86eba568 100644 --- a/cylc/flow/scripts/reinstall.py +++ b/cylc/flow/scripts/reinstall.py @@ -58,7 +58,7 @@ def get_option_parser(): parser = COP( - __doc__, comms=True, argdoc=[('[REG]', 'Workflow name')] + __doc__, comms=True, argdoc=[('[WORKFLOW]', 'Workflow name or ID')] ) parser.add_cylc_rose_options() diff --git a/cylc/flow/scripts/release.py b/cylc/flow/scripts/release.py index 6c6d29f08ac..f5da1da9134 100755 --- a/cylc/flow/scripts/release.py +++ b/cylc/flow/scripts/release.py @@ -84,7 +84,7 @@ def get_option_parser() -> COP: parser = COP( __doc__, comms=True, multitask=True, argdoc=[ - ('REG', "Workflow name"), + ('WORKFLOW', 'Workflow name or ID'), ('[TASK_GLOB ...]', "Task matching patterns")] ) diff --git a/cylc/flow/scripts/reload.py b/cylc/flow/scripts/reload.py index 40f5c16bf0f..227fd97c539 100755 --- a/cylc/flow/scripts/reload.py +++ b/cylc/flow/scripts/reload.py @@ -26,8 +26,8 @@ a task is already running at reload time. If the workflow was started with Jinja2 template variables set on the command -line (cylc play --set 'FOO="bar"' REG) the same template settings apply to the -reload (only changes to the flow.cylc file itself are reloaded). +line (cylc play --set 'FOO="bar"' WORKFLOW) the same template settings apply to +the reload (only changes to the flow.cylc file itself are reloaded). If the modified workflow definition does not parse, failure to reload will be reported but no harm will be done to the running workflow.""" diff --git a/cylc/flow/scripts/remove.py b/cylc/flow/scripts/remove.py index b603f0c49ab..3afe804a396 100755 --- a/cylc/flow/scripts/remove.py +++ b/cylc/flow/scripts/remove.py @@ -52,7 +52,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, multitask=True, argdoc=[ - ("REG", "Workflow name"), + ("WORKFLOW", "Workflow name or ID"), ('TASK_GLOB [...]', 'Task matching patterns')]) return parser diff --git a/cylc/flow/scripts/report_timings.py b/cylc/flow/scripts/report_timings.py index 2780d4a3661..272e3acfff4 100755 --- a/cylc/flow/scripts/report_timings.py +++ b/cylc/flow/scripts/report_timings.py @@ -89,7 +89,7 @@ def smart_open(filename=None): def get_option_parser(): parser = COP( __doc__, - argdoc=[('REG', 'Workflow name')] + argdoc=[('WORKFLOW', 'Workflow name or ID')] ) parser.add_option( "-r", "--raw", diff --git a/cylc/flow/scripts/set_outputs.py b/cylc/flow/scripts/set_outputs.py index 17a36edc34b..42530de743f 100755 --- a/cylc/flow/scripts/set_outputs.py +++ b/cylc/flow/scripts/set_outputs.py @@ -58,7 +58,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, multitask_nocycles=True, argdoc=[ - ("REG", "Workflow name"), + ("WORKFLOW", "Workflow name or ID"), ('TASK-GLOB [...]', 'Task match pattern')]) parser.add_option( "--output", metavar="OUTPUT", diff --git a/cylc/flow/scripts/set_verbosity.py b/cylc/flow/scripts/set_verbosity.py index 55270a0a32e..a674c0682b7 100755 --- a/cylc/flow/scripts/set_verbosity.py +++ b/cylc/flow/scripts/set_verbosity.py @@ -52,7 +52,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, argdoc=[ - ('REG', 'Workflow name'), + ('WORKFLOW', 'Workflow name or ID'), ('LEVEL', ', '.join(LOG_LEVELS.keys())) ] ) diff --git a/cylc/flow/scripts/show.py b/cylc/flow/scripts/show.py index e69fb1f218c..d17f74f46d8 100755 --- a/cylc/flow/scripts/show.py +++ b/cylc/flow/scripts/show.py @@ -21,9 +21,9 @@ Display workflow and task information. Query a running workflow for: - $ cylc show REG # workflow metadata - $ cylc show REG TASK_NAME # task metadata - $ cylc show REG TASK_GLOB # prerequisites and outputs of task instances + $ cylc show WORKFLOW # workflow metadata + $ cylc show WORKFLOW TASK_NAME # task metadata + $ cylc show WORKFLOW TASK_GLOB # prerequisites and outputs of task instances Prerequisite and output status is indicated for current active tasks. """ @@ -143,7 +143,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, multitask=True, argdoc=[ - ('REG', 'Workflow name'), + ('WORKFLOW', 'Workflow name or ID'), ('[TASK_NAME or TASK_GLOB ...]', 'Task names or match patterns')]) parser.add_option('--list-prereqs', action="store_true", default=False, diff --git a/cylc/flow/scripts/stop.py b/cylc/flow/scripts/stop.py index e3ac3aff821..9348364b122 100755 --- a/cylc/flow/scripts/stop.py +++ b/cylc/flow/scripts/stop.py @@ -112,7 +112,7 @@ def check(self): def get_option_parser(): parser = COP( __doc__, comms=True, - argdoc=[("REG", "Workflow name"), + argdoc=[("WORKFLOW", "Workflow name or ID"), ("[STOP]", "task POINT (cycle point), or TASK (task ID).")] ) diff --git a/cylc/flow/scripts/subscribe.py b/cylc/flow/scripts/subscribe.py index d77aca6cc02..674e79d7a8c 100755 --- a/cylc/flow/scripts/subscribe.py +++ b/cylc/flow/scripts/subscribe.py @@ -57,7 +57,7 @@ def get_option_parser(): parser = COP( __doc__, argdoc=[ - ('REG', 'Workflow name') + ('WORKFLOW_ID', 'Workflow ID') ], comms=True ) diff --git a/cylc/flow/scripts/trigger.py b/cylc/flow/scripts/trigger.py index 9ca2dd0e03e..586282145f7 100755 --- a/cylc/flow/scripts/trigger.py +++ b/cylc/flow/scripts/trigger.py @@ -20,8 +20,9 @@ Manually trigger tasks. Examples: - $ cylc trigger REG # trigger all tasks in a running workflow - $ cylc trigger REG TASK_GLOB ... # trigger some tasks in a running workflow + $ cylc trigger WORKFLOW # trigger all tasks in a running workflow + # trigger some tasks in a running workflow: + $ cylc trigger WORKFLOW TASK_GLOB ... NOTE waiting tasks that are queue-limited will be queued if triggered, to submit as normal when released by the queue; queued tasks will submit @@ -62,7 +63,7 @@ def get_option_parser(): parser = COP( __doc__, comms=True, multitask_nocycles=True, argdoc=[ - ('REG', 'Workflow name'), + ('WORKFLOW', 'Workflow name or ID'), ('[TASK_GLOB ...]', 'Task matching patterns')]) parser.add_option( diff --git a/cylc/flow/scripts/tui.py b/cylc/flow/scripts/tui.py index 788e0dc5f75..09263198a7c 100644 --- a/cylc/flow/scripts/tui.py +++ b/cylc/flow/scripts/tui.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -"""cylc tui REG +"""cylc tui WORKFLOW View and control running workflows in the terminal. @@ -53,7 +53,7 @@ def get_option_parser(): parser = COP( __doc__, argdoc=[ - ('REG', 'Workflow name') + ('WORKFLOW', 'Workflow name or ID') ], # auto_add=False, NOTE: at present auto_add can not be turned off color=False diff --git a/cylc/flow/scripts/workflow_state.py b/cylc/flow/scripts/workflow_state.py index dec2e2ec2b5..ddabdab793f 100755 --- a/cylc/flow/scripts/workflow_state.py +++ b/cylc/flow/scripts/workflow_state.py @@ -35,15 +35,15 @@ mirrored workflow databases, use --run-dir=DIR to specify the location. Examples: - $ cylc workflow-state REG --task=TASK --point=POINT --status=STATUS + $ cylc workflow-state WORKFLOW --task=TASK --point=POINT --status=STATUS # returns 0 if TASK.POINT reaches STATUS before the maximum number of # polls, otherwise returns 1. - $ cylc workflow-state REG --task=TASK --point=POINT --status=STATUS \ + $ cylc workflow-state WORKFLOW --task=TASK --point=POINT --status=STATUS \ > --offset=PT6H # adds 6 hours to the value of CYCLE for carrying out the polling operation. - $ cylc workflow-state REG --task=TASK --status=STATUS --task-point + $ cylc workflow-state WORKFLOW --task=TASK --status=STATUS --task-point # uses CYLC_TASK_CYCLE_POINT environment variable as the value for the # CYCLE to poll. This is useful when you want to use cylc workflow-state in a # cylc task. @@ -128,7 +128,7 @@ def check(self): def get_option_parser() -> COP: parser = COP( __doc__, - argdoc=[('REG', "Workflow name")] + argdoc=[('WORKFLOW', "Workflow name or ID")] ) parser.add_option( @@ -150,7 +150,7 @@ def get_option_parser() -> COP: parser.add_option( "-d", "--run-dir", help="The top level cylc run directory if non-standard. The " - "database should be DIR/REG/log/db. Use to interrogate " + "database should be DIR/WORKFLOW_ID/log/db. Use to interrogate " "workflows owned by others, etc.; see note above.", metavar="DIR", action="store", dest="run_dir", default=None) diff --git a/tests/functional/clock-expire/00-basic/flow.cylc b/tests/functional/clock-expire/00-basic/flow.cylc index f36b24ba741..936c078484b 100644 --- a/tests/functional/clock-expire/00-basic/flow.cylc +++ b/tests/functional/clock-expire/00-basic/flow.cylc @@ -4,7 +4,7 @@ Skip a daily post-processing workflow if the 'copy' task has expired.""" [scheduler] - cycle point format = %Y-%m-%dT%H + # cycle point format = %Y-%m-%dT%H%M allow implicit tasks = True [[events]] abort on stall timeout = True diff --git a/tests/functional/cylc-install/00-simple.t b/tests/functional/cylc-install/00-simple.t index 035d763c382..ddbf44312da 100755 --- a/tests/functional/cylc-install/00-simple.t +++ b/tests/functional/cylc-install/00-simple.t @@ -40,23 +40,23 @@ popd || exit 1 purge_rnd_workflow # ----------------------------------------------------------------------------- -# Test default name: "cylc install REG" (flow in confgured source dir) +# Test default name: "cylc install WORKFLOW_NAME" (flow in confgured source dir) make_rnd_workflow # Before adding workflow to ~/cylc-src/, check install fails: -TEST_NAME="${TEST_NAME_BASE}-REG-fail-no-src-dir" +TEST_NAME="${TEST_NAME_BASE}-WORKFLOW_NAME-fail-no-src-dir" run_fail "${TEST_NAME}" cylc install "${RND_WORKFLOW_NAME}" # Now add workflow to ~/cylc-src/ RND_WORKFLOW_SOURCE="${PWD}/cylc-src/${RND_WORKFLOW_NAME}" mv "$RND_WORKFLOW_NAME" "${PWD}/cylc-src/" pushd "${RND_WORKFLOW_SOURCE}" || exit 1 -# Test REG and --directory are mutually exclusive -TEST_NAME="${TEST_NAME_BASE}-REG-and--directory-forbidden" +# Test WORKFLOW_NAME and --directory are mutually exclusive +TEST_NAME="${TEST_NAME_BASE}-WORKFLOW_NAME-and--directory-forbidden" run_fail "${TEST_NAME}" cylc install "${RND_WORKFLOW_NAME}" -C "${RND_WORKFLOW_SOURCE}" contains_ok "${TEST_NAME}.stderr" <<__ERR__ -cylc: error: REG and --directory are mutually exclusive. +cylc: error: WORKFLOW_NAME and --directory are mutually exclusive. __ERR__ # Finally test normal case -TEST_NAME="${TEST_NAME_BASE}-REG-install-ok" +TEST_NAME="${TEST_NAME_BASE}-WORKFLOW_NAME-install-ok" run_ok "${TEST_NAME}" cylc install "${RND_WORKFLOW_NAME}" contains_ok "${TEST_NAME}.stdout" <<__OUT__ INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} diff --git a/tests/functional/cylc-play/07-provided-vars.t b/tests/functional/cylc-play/07-provided-vars.t new file mode 100644 index 00000000000..0ccb6400954 --- /dev/null +++ b/tests/functional/cylc-play/07-provided-vars.t @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# 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 . +#------------------------------------------------------------------------ + +# test the export of CYLC_WORKFLOW_ID and CYLC_WORKFLOW_NAME + +. "$(dirname "$0")/test_header" + +set_test_number 4 + +cat > flow.cylc <<'__FLOW_CONFIG__' +[scheduler] + cycle point format = %Y + [[events]] + stall timeout = PT0S + +[scheduling] + initial cycle point = 1066 + + [[dependencies]] + R1 = foo + +[runtime] + [[foo]] + script = """ + echo "CYLC_WORKFLOW_NAME is: ${CYLC_WORKFLOW_NAME}" + echo "CYLC_WORKFLOW_ID is: ${CYLC_WORKFLOW_ID}" + """ +__FLOW_CONFIG__ + +init_workflow "${TEST_NAME_BASE}" flow.cylc true + +run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" +workflow_run_ok "${TEST_NAME_BASE}-play" cylc play "${WORKFLOW_NAME}" --no-detach +named_grep_ok \ + "${TEST_NAME_BASE}-check-CYLC_WORKFLOW_NAME" \ + "CYLC_WORKFLOW_NAME is:.* ${WORKFLOW_NAME}" \ + "${WORKFLOW_RUN_DIR}/runN/log/job/1066/foo/NN/job.out" +named_grep_ok \ + "${TEST_NAME_BASE}-check-CYLC_WORKFLOW_ID" \ + "CYLC_WORKFLOW_ID is:.* ${WORKFLOW_NAME}/run1" \ + "${WORKFLOW_RUN_DIR}/runN/log/job/1066/foo/NN/job.out" + diff --git a/tests/functional/lib/bash/test_header b/tests/functional/lib/bash/test_header index 77686102f15..d7ba6e2dc5b 100644 --- a/tests/functional/lib/bash/test_header +++ b/tests/functional/lib/bash/test_header @@ -73,10 +73,11 @@ # Test that FILE exists # exists_fail FILE # Test that FILE does not exist -# init_workflow TEST_NAME [SOURCE] +# init_workflow TEST_NAME [SOURCE] [[RUN_NUMS]] # Create a workflow from SOURCE's "flow.cylc" called: # "cylctb-${CYLC_TEST_TIME_INIT}/${TEST_SOURCE_DIR##*tests/}/${TEST_NAME}" # Provides WORKFLOW_NAME and WORKFLOW_RUN_DIR variables. +# RUN_NUMS (defaults to false): If false run cylc install --no-rundir # install_workflow TEST_NAME SOURCE # Same as init_workflow, but SOURCE must be a directory containing a # "flow.cylc" file. @@ -453,12 +454,17 @@ graph_workflow() { init_workflow() { local TEST_NAME="$1" local FLOW_CONFIG="${2:--}" + local RUN_NUMS="${3:-false}" WORKFLOW_NAME="${CYLC_TEST_REG_BASE}/${TEST_SOURCE_DIR_BASE}/${TEST_NAME}" WORKFLOW_RUN_DIR="${RUN_DIR}/${WORKFLOW_NAME}" mkdir -p "${TEST_DIR}/${WORKFLOW_NAME}/" cat "${FLOW_CONFIG}" >"${TEST_DIR}/${WORKFLOW_NAME}/flow.cylc" cd "${TEST_DIR}/${WORKFLOW_NAME}" - cylc install --no-run-name --flow-name="${WORKFLOW_NAME}" --directory="${TEST_DIR}/${WORKFLOW_NAME}" + if "${RUN_NUMS}"; then + cylc install --flow-name="${WORKFLOW_NAME}" --directory="${TEST_DIR}/${WORKFLOW_NAME}" + else + cylc install --no-run-name --flow-name="${WORKFLOW_NAME}" --directory="${TEST_DIR}/${WORKFLOW_NAME}" + fi } install_workflow() {