Skip to content

Commit 756b52f

Browse files
committed
Implement --set=all.
1 parent 1a0bde0 commit 756b52f

File tree

4 files changed

+42
-31
lines changed

4 files changed

+42
-31
lines changed

cylc/flow/flow_mgr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_flow_opts(parser):
4545
help=f'Assign new tasks to all active flows ("{FLOW_ALL}");'
4646
f' no flow ("{FLOW_NONE}"); a new flow ("{FLOW_NEW}");'
4747
f' or a specific flow (e.g. "2"). The default is "{FLOW_ALL}".'
48-
' Reuse the option to assign multiple specific flows.'
48+
' Reuse the option to assign multiple flow numbers.'
4949
)
5050

5151
parser.add_option(

cylc/flow/scripts/set.py

+27-23
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,34 @@
1818

1919
"""cylc set [OPTIONS] ARGS
2020
21-
Override task status in a running workflow.
21+
Override task status in a running workflow by setting outputs (`--out=...`), or
22+
setting prerequisites and promoting tasks to the active window (`--pre=...`).
2223
23-
By default (no options) this command sets all required outputs in target tasks.
24-
(Note this won't set the `succeeded` output if it is not a required output!)
24+
By default, it sets all required outputs. (Note this won't set the `succeeded`
25+
output unless succeeded is a required output!)
2526
26-
With `--pre`, bring tasks into the active window with specified prequisites,
27-
if any, satisfied. This affects task readiness to run. It does not override
28-
clock triggers, xtriggers, or task hold.
27+
Setting prerequisites contributes to a task's readiness to run. It does not
28+
override clock triggers, xtriggers, or task hold (in fact these will be
29+
activated by promoting the task to the scheduler's active window).
2930
30-
With `--out`, complete specified outputs. This affects task completion.
31-
It also sets the prerequisites of downstream tasks that depend on those outputs,
32-
and any implied outputs (started implies submitted; succeeded and failed imply
33-
started; custom outputs and expired do not imply any other outputs).
31+
Setting outputs affects task completion, and it sets the prerequisites of
32+
downstream tasks that depend on those outputs. It also sets implied outputs:
33+
started implies submitted; succeeded and failed imply started; custom outputs
34+
and expired do not imply other outputs.
3435
3536
Examples:
3637
37-
Satisfy all required outputs of `3/bar`:
38-
cylc set my-workflow//3/bar
38+
# satisfy all required outputs of `3/bar`:
39+
$ cylc set my-workflow//3/bar
3940
40-
Satisfy the succeeded output of `3/bar`:
41-
cylc set my-workflow//3/bar succeeded
41+
$ satisfy the succeeded output of `3/bar`:
42+
# cylc set my-workflow//3/bar succeeded
4243
43-
Bring `3/bar` to the active window with its dependence on `3/foo` satisfied:
44-
cylc set --pre=3/foo:succeeded my-workflow//3/bar
44+
# bring `3/bar` to the active window with dependence on `3/foo` satisfied:
45+
$ cylc set --pre=3/foo:succeeded my-workflow//3/bar
4546
46-
Bring `3/bar` to the active window with all prerequisites (if any satisfied)
47-
to start checking on clock and xtriggers, and task expiry:
48-
49-
cylc set --pre=all my-workflow//3/bar
47+
# bring `3/bar` to the active window with any/all prerequisites satisfied:
48+
$ cylc set --pre=all my-workflow//3/bar
5049
5150
"""
5251

@@ -117,8 +116,8 @@ def get_option_parser() -> COP:
117116
help=(
118117
"Set task prerequisites satisfied."
119118
" PREREQUISITE format: 'point/task:message'."
120-
" Multiple use allowed, items may be comma separated. See also"
121-
" `cylc trigger` (equivalent to setting all prerequisites)."
119+
" Multiple use allowed, items may be comma separated."
120+
" Use 'all' to satisfy any and all prerequisites."
122121
),
123122
action="append", default=None, dest="prerequisites"
124123
)
@@ -145,8 +144,13 @@ def get_prerequisite_opts(options):
145144
for p in options.prerequisites:
146145
result += p.split(',')
147146

147+
if "all" in result:
148+
if len(result) != 1:
149+
raise InputError("--pre=all must be used alone")
150+
return result
151+
148152
for p in result:
149-
if not REC_CLI_PREREQ.match(p):
153+
if REC_CLI_PREREQ.match(p):
150154
raise InputError(f"Bad prerequisite: {p}")
151155

152156
return result

cylc/flow/task_pool.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1673,13 +1673,14 @@ def set_prereqs(self, point, taskdef, prereqs, flow_nums):
16731673
# Can't spawn it, so can't set its prerequisites.
16741674
return
16751675

1676-
for pre in prereqs:
1677-
m = REC_CLI_PREREQ.match(pre)
1678-
if m is not None:
1679-
itask.satisfy_me({m.groups()})
1680-
else:
1681-
# TODO warn here? (checked on CLI)
1682-
continue
1676+
if prereqs == ["all"]:
1677+
itask.state.set_all_satisfied()
1678+
else:
1679+
for pre in prereqs:
1680+
m = REC_CLI_PREREQ.match(pre)
1681+
if m is not None:
1682+
itask.satisfy_me({m.groups()})
1683+
# (regex already checked in the CLI)
16831684

16841685
self.data_store_mgr.delta_task_prerequisite(itask)
16851686
self.add_to_pool(itask)

cylc/flow/task_state.py

+6
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ def external_triggers_all_satisfied(self):
332332
"""Return True if all external triggers are satisfied."""
333333
return all(self.external_triggers.values())
334334

335+
def set_all_satisfied(self):
336+
"""Set all my prerequisites satisfied."""
337+
for p in self.prerequisites:
338+
p.set_satisfied()
339+
self._is_satisfied = True
340+
335341
def prerequisites_all_satisfied(self):
336342
"""Return True if (non-suicide) prerequisites are fully satisfied."""
337343
if self._is_satisfied is None:

0 commit comments

Comments
 (0)