Skip to content

Commit

Permalink
add sequential arg option and to wall_clock as True
Browse files Browse the repository at this point in the history
  • Loading branch information
dwsutherland committed Oct 6, 2023
1 parent 0537f49 commit 3248197
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cylc/flow/cfgspec/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,8 @@ def get_script_common_text(this: str, example: Optional[str] = None):
Instead of out to the runahead limit (default: ``False``).
This workflow wide default can be overridden by a reserved
keyword argument in the xtrigger function declaration
(``sequential=True/False``).
keyword argument in the xtrigger function declaration and/or
function (``sequential=True/False``).
The presence of one sequential xtrigger on a parentless task with
multiple xtriggers will cause sequential behavior.
Expand Down
30 changes: 21 additions & 9 deletions cylc/flow/xtrigger_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,27 @@ def validate_xtrigger(label: str, fctx: SubFuncContext, fdir: str) -> None:
fname,
f"'{fname}' not callable in xtrigger module '{fname}'",
)
if 'sequential' in getfullargspec(func).args:
raise XtriggerConfigError(
label,
fname,
(
f"xtrigger module '{fname}' contains reserved"
" argument name 'sequential'"
),
)
x_argspec = getfullargspec(func)
if 'sequential' in x_argspec.args:
if (
x_argspec.defaults is None
or not isinstance(
x_argspec.defaults[x_argspec.args.index('sequential')],
bool
)
):
raise XtriggerConfigError(
label,
fname,
(
f"xtrigger module '{fname}' contains reserved argument"
" name 'sequential' that has no boolean default"
),
)
elif 'sequential' not in fctx.func_kwargs:
fctx.func_kwargs['sequential'] = x_argspec.defaults[
x_argspec.args.index('sequential')
]

# Check any string templates in the function arg values (note this
# won't catch bad task-specific values - which are added dynamically).
Expand Down
4 changes: 3 additions & 1 deletion cylc/flow/xtriggers/wall_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
from time import time


def wall_clock(trigger_time=None):
def wall_clock(trigger_time=None, sequential=True):
"""Return True after the desired wall clock time, False.
Args:
trigger_time (int):
Trigger time as seconds since Unix epoch.
sequential (bool):
Used by the workflow to flag corresponding xtriggers as sequential.
"""
return time() > trigger_time

0 comments on commit 3248197

Please sign in to comment.