Skip to content

Commit 5b2b180

Browse files
wxtimoliver-sandersMetRonniehjoliver
authored
Skip Mode (#6039)
Implement Skip Mode * Add `[runtime][<namespace>]run mode` and `[runtime][<namespace>][skip]`. * Spin run mode functionality into separate modules. * Run sim mode check with every main loop - we don't know if any tasks are in sim mode from the scheduler, but it doesn't cost much to check if none are. * Implemented separate job "submission" pathway switching. * Implemented skip mode, including output control logic. * Add a linter and a validation check for tasks in nonlive modes, and for combinations of outputs * Enabled setting outputs as if task ran in skip mode using `cylc set --out skip`. * Testing for the above. * Allow cylc set --out=skip,optional_output * Prevent cleanup from attempting to remote clean platforms skip and simulation --------- Co-authored-by: Oliver Sanders <[email protected]> Co-authored-by: Ronnie Dutta <[email protected]> Co-authored-by: Hilary James Oliver <[email protected]>
1 parent b004e54 commit 5b2b180

File tree

85 files changed

+3034
-908
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3034
-908
lines changed

changes.d/6039.feat.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added a new task run mode "skip" in which tasks instantly generate their required outputs without actually running. This allows us to configure tasks to "skip" ahead of time, e.g. to skip a cycle of tasks that is no longer needed.

cylc/flow/cfgspec/workflow.py

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@
5656
from cylc.flow.platforms import (
5757
fail_if_platform_and_host_conflict, get_platform_deprecated_settings,
5858
is_platform_definition_subshell)
59+
from cylc.flow.run_modes import RunMode
5960
from cylc.flow.task_events_mgr import EventData
61+
from cylc.flow.run_modes import TASK_CONFIG_RUN_MODES
62+
6063

6164
# Regex to check whether a string is a command
6265
REC_COMMAND = re.compile(r'(`|\$\()\s*(.*)\s*([`)])$')
@@ -1334,6 +1337,36 @@ def get_script_common_text(this: str, example: Optional[str] = None):
13341337
"[platforms][<platform name>]submission retry delays"
13351338
)
13361339
)
1340+
Conf(
1341+
'run mode', VDR.V_STRING,
1342+
options=list(TASK_CONFIG_RUN_MODES),
1343+
default=RunMode.LIVE.value,
1344+
desc=f'''
1345+
When the workflow is running in live mode, run this *task*
1346+
in one of the following modes:
1347+
1348+
``{RunMode.LIVE.value}`` (default):
1349+
{RunMode.LIVE.describe()}
1350+
``{RunMode.SKIP.value}``:
1351+
{RunMode.SKIP.describe()}
1352+
1353+
.. note::
1354+
1355+
This is primarily intended to be set at runtime via
1356+
a broadcast; Cylc will warn you about any tasks
1357+
set to run in skip mode in the workflow
1358+
configuration at validation time.
1359+
If you are using skip mode to create a dummy task,
1360+
you can ignore this warning.
1361+
1362+
.. seealso::
1363+
1364+
- :ref:`task-run-modes.skip`
1365+
- :cylc:conf:`flow.cylc[runtime][<namespace>][skip]`
1366+
1367+
.. versionadded:: 8.4.0
1368+
1369+
''')
13371370
with Conf('meta', desc=r'''
13381371
Metadata for the task or task family.
13391372
@@ -1406,13 +1439,51 @@ def get_script_common_text(this: str, example: Optional[str] = None):
14061439
determine how an event handler responds to task failure
14071440
events.
14081441
''')
1442+
with Conf('skip', desc='''
1443+
Task configuration for :ref:`task-run-modes.skip`.
14091444
1445+
.. seealso::
1446+
1447+
- :ref:`task-run-modes.skip`
1448+
- :cylc:conf:`flow.cylc[runtime][<namespace>]run mode`
1449+
1450+
.. versionadded:: 8.4.0
1451+
'''):
1452+
Conf(
1453+
'outputs',
1454+
VDR.V_STRING_LIST,
1455+
desc='''
1456+
Outputs to be emitted by a task in skip mode.
1457+
1458+
* By default, all required outputs will be generated
1459+
plus succeeded if success is optional.
1460+
* If skip-mode outputs is specified and does not
1461+
include either succeeded or failed then succeeded
1462+
will be produced.
1463+
* The outputs submitted and started are always
1464+
produced and do not need to be defined in here.
1465+
1466+
.. versionadded:: 8.4.0
1467+
'''
1468+
)
1469+
Conf(
1470+
'disable task event handlers',
1471+
VDR.V_BOOLEAN,
1472+
default=True,
1473+
desc='''
1474+
Task event handlers are turned off by default for
1475+
skip mode tasks. Changing this setting to ``False``
1476+
will re-enable task event handlers.
1477+
1478+
.. versionadded:: 8.4.0
1479+
'''
1480+
)
14101481
with Conf('simulation', desc='''
14111482
Task configuration for workflow *simulation* and *dummy* run
14121483
modes.
14131484
14141485
For a full description of simulation and dummy run modes see
1415-
:ref:`SimulationMode`.
1486+
:ref:`workflow-run-modes.simulation`.
14161487
'''):
14171488
Conf('default run length', VDR.V_INTERVAL, DurationFloat(10),
14181489
desc='''

cylc/flow/commands.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@
8383
from cylc.flow.log_level import log_level_to_verbosity
8484
from cylc.flow.network.schema import WorkflowStopMode
8585
from cylc.flow.parsec.exceptions import ParsecError
86+
from cylc.flow.run_modes import RunMode
8687
from cylc.flow.task_id import TaskID
87-
from cylc.flow.workflow_status import (
88-
RunMode,
89-
StopMode,
90-
)
88+
from cylc.flow.workflow_status import StopMode
9189

9290

9391
if TYPE_CHECKING:

cylc/flow/config.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
is_relative_to,
8282
)
8383
from cylc.flow.task_qualifiers import ALT_QUALIFIERS
84-
from cylc.flow.simulation import configure_sim_modes
84+
from cylc.flow.run_modes.simulation import configure_sim_mode
85+
from cylc.flow.run_modes.skip import skip_mode_validate
8586
from cylc.flow.subprocctx import SubFuncContext
8687
from cylc.flow.task_events_mgr import (
8788
EventData,
@@ -98,6 +99,7 @@
9899
get_trigger_completion_variable_maps,
99100
trigger_to_completion_variable,
100101
)
102+
from cylc.flow.run_modes import RunMode
101103
from cylc.flow.task_trigger import TaskTrigger, Dependency
102104
from cylc.flow.taskdef import TaskDef
103105
from cylc.flow.unicode_rules import (
@@ -113,7 +115,6 @@
113115
WorkflowFiles,
114116
check_deprecation,
115117
)
116-
from cylc.flow.workflow_status import RunMode
117118
from cylc.flow.xtrigger_mgr import XtriggerCollator
118119

119120
if TYPE_CHECKING:
@@ -512,9 +513,10 @@ def __init__(
512513

513514
self.process_runahead_limit()
514515

515-
run_mode = self.run_mode()
516+
run_mode = RunMode.get(self.options)
516517
if run_mode in {RunMode.SIMULATION, RunMode.DUMMY}:
517-
configure_sim_modes(self.taskdefs.values(), run_mode)
518+
for taskdef in self.taskdefs.values():
519+
configure_sim_mode(taskdef.rtconfig, None, False)
518520

519521
self.configure_workflow_state_polling_tasks()
520522

@@ -566,6 +568,8 @@ def __init__(
566568

567569
self.mem_log("config.py: end init config")
568570

571+
skip_mode_validate(self.taskdefs)
572+
569573
@staticmethod
570574
def _warn_if_queues_have_implicit_tasks(
571575
config, taskdefs, max_warning_lines
@@ -1700,10 +1704,6 @@ def process_config_env(self):
17001704
]
17011705
)
17021706

1703-
def run_mode(self) -> str:
1704-
"""Return the run mode."""
1705-
return RunMode.get(self.options)
1706-
17071707
def _check_task_event_handlers(self):
17081708
"""Check custom event handler templates can be expanded.
17091709
@@ -2455,7 +2455,9 @@ def _get_taskdef(self, name: str) -> TaskDef:
24552455

24562456
# Get the taskdef object for generating the task proxy class
24572457
taskd = TaskDef(
2458-
name, rtcfg, self.run_mode(), self.start_point,
2458+
name,
2459+
rtcfg,
2460+
self.start_point,
24592461
self.initial_point)
24602462

24612463
# TODO - put all taskd.foo items in a single config dict

cylc/flow/data_messages.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ message PbRuntime {
128128
optional string environment = 16;
129129
optional string outputs = 17;
130130
optional string completion = 18;
131+
optional string run_mode = 19;
131132
}
132133

133134

cylc/flow/data_messages_pb2.py

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)