hi there,
in my model development, i frequently get to the stage where i have loads of runs ‘alive’ at the same time because of trial and error…
is there a way to run something like?..
cylc stop -k workflow/run{all active runs before runN}
just wondering!
cheers
for this particular example i’ve just done this which works fine, but just wondering if there is a more cylc
-y way of doing it!
for i in {1..20}; do cylc stop -k u-cw586/run$i; done
Cylc commands support basic pattern-matching for workflow and task IDs. See cylc help id
. Note you have to quote the pattern on the command line to protect it from immediate shell expansion.
There’s no pattern for <= n
but it’s usually easy to get the result with one or two commands. For your example:
$ cylc stop "u-cw586/run?[!1]" # any character, then any character except 1
For running workflows, check you got the pattern right first with cylc ping
:
$ cylc ping "u-cw586/run?[!1]"
u-cw586/run14
u-cw586/run15
u-cw586/run16
u-cw586/run17
u-cw586/run18
u-cw586/run19
u-cw586/run20
(This pattern wouldn’t be correct if any of runs 1 through 11 were active, but it is correct for the group of runs shown in your screenshot above).
1 Like
thanks @hilary.j.oliver,
ok that’s super helpful.
one of the things that i come up against a lot (not just cylc
!) is that when using pattern-matching (same as ‘regex’?) is that i don’t know exactly what type of patterns are matched. my understanding is that there are several types of regex? do you have a link to a dictionary or similar of exactly what is matched by cylc in this instance?
cheers,
Well, regular expressions are a particularly powerful and general kind of pattern matching for arbitrary text. But like anything in computing, capabilities have evolved and different implementations support different syntax and different concepts. To be sure of what’s supported, you really have to consult the documentation for the language or program you’re using.
There are also simpler kinds of pattern matching, such as shell “globbing”, as used for matching filenames in Bash etc., with only a few simple meta-characters.
The Cylc CLI just uses a type of globbing for matching workflow IDs, because going full regex would be overkill.
See cylc help id
for details!
1 Like
Just to be clear - these are glob patterns, not regex patterns. See glob (programming) - Wikipedia for the syntax
1 Like
thanks a lot @hilary.j.oliver and @MetRonnie
i must admit i hadn’t come across !
used in globs before.
cheers