-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow-specific hold/release #5698
base: master
Are you sure you want to change the base?
Changes from all commits
e8d957c
58dc6c5
95fa798
1e7d548
b5f83a4
584bea8
77acf44
ad81aa3
2b570d5
ff07668
d3c776c
b2e7440
151537e
f554c96
6597431
e1fb7fe
9e93454
e912f63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1 @@ | ||
Flow-specific task hold and release. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 20,7 @@ | |
import datetime | ||
|
||
from cylc.flow import LOG | ||
from cylc.flow.exceptions import InputError | ||
from cylc.flow.workflow_db_mgr import WorkflowDatabaseManager | ||
|
||
|
||
|
@@ -30,6 31,15 @@ | |
FLOW_NONE = "none" | ||
|
||
|
||
def validate_flow_opt(val): | ||
"""Validate command line --flow opions.""" | ||
if val is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How will the parser allow this value to be |
||
try: | ||
int(val) | ||
except ValueError: | ||
raise InputError(f"--flow={val}: value must be integer.") | ||
|
||
|
||
class FlowMgr: | ||
"""Logic to manage flow counter and flow metadata.""" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1735,7 1735,9 @@ class Arguments: | |
description='Hold all tasks after the specified cycle point.', | ||
required=True | ||
) | ||
|
||
flow_num = Int( | ||
description='Number of flow to hold.' | ||
) | ||
Comment on lines
1738
to
1740
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the default be The pattern used in other mutations is a field called In this case |
||
result = GenericScalar() | ||
|
||
|
||
|
@@ -2035,6 2037,11 @@ class Meta: | |
''') | ||
resolver = mutator | ||
|
||
class Arguments(TaskMutation.Arguments): | ||
flow_num = Int( | ||
description='Number of flow to hold.' | ||
) | ||
|
||
|
||
class Release(Mutation, TaskMutation): | ||
class Meta: | ||
|
@@ -2047,6 2054,11 @@ class Meta: | |
''') | ||
resolver = mutator | ||
|
||
class Arguments(TaskMutation.Arguments): | ||
flow_num = Int( | ||
description='Number of flow to release.' | ||
) | ||
|
||
|
||
class Kill(Mutation, TaskMutation): | ||
# TODO: This should be a job mutation? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 59,7 @@ | |
from typing import TYPE_CHECKING | ||
|
||
from cylc.flow.exceptions import InputError | ||
from cylc.flow.flow_mgr import validate_flow_opt | ||
from cylc.flow.network.client_factory import get_client | ||
from cylc.flow.option_parsers import ( | ||
FULL_ID_MULTI_ARG_DOC, | ||
|
@@ -67,18 68,21 @@ | |
from cylc.flow.terminal import cli_function | ||
from cylc.flow.network.multi import call_multi | ||
|
||
|
||
if TYPE_CHECKING: | ||
from optparse import Values | ||
|
||
|
||
HOLD_MUTATION = ''' | ||
mutation ( | ||
$wFlows: [WorkflowID]!, | ||
$tasks: [NamespaceIDGlob]! | ||
$tasks: [NamespaceIDGlob]!, | ||
$flowNum: Int | ||
) { | ||
hold ( | ||
workflows: $wFlows, | ||
tasks: $tasks | ||
tasks: $tasks, | ||
flowNum: $flowNum | ||
) { | ||
result | ||
} | ||
|
@@ -88,11 92,13 @@ | |
SET_HOLD_POINT_MUTATION = ''' | ||
mutation ( | ||
$wFlows: [WorkflowID]!, | ||
$point: CyclePoint! | ||
$point: CyclePoint!, | ||
$flowNum: Int | ||
) { | ||
setHoldPoint ( | ||
workflows: $wFlows, | ||
point: $point | ||
point: $point, | ||
flowNum: $flowNum | ||
) { | ||
result | ||
} | ||
|
@@ -114,6 120,11 @@ def get_option_parser() -> COP: | |
help="Hold all tasks after this cycle point.", | ||
metavar="CYCLE_POINT", action="store", dest="hold_point_string") | ||
|
||
parser.add_option( | ||
"--flow", | ||
help="Hold tasks that belong to a specific flow.", | ||
metavar="INT", action="store", dest="flow_num") | ||
Comment on lines
123
to
126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably |
||
|
||
return parser | ||
|
||
|
||
|
@@ -123,12 134,14 @@ def _validate(options: 'Values', *task_globs: str) -> None: | |
if task_globs: | ||
raise InputError( | ||
"Cannot combine --after with Cylc/Task IDs.\n" | ||
"`cylc hold --after` holds all tasks after the given " | ||
"cycle point.") | ||
"`cylc hold --after` holds ALL tasks after the given " | ||
"cycle point. Can be used with `--flow`.") | ||
elif not task_globs: | ||
raise InputError( | ||
"Must define Cycles/Tasks. See `cylc hold --help`.") | ||
|
||
validate_flow_opt(options.flow_num) | ||
|
||
|
||
async def run(options, workflow_id, *tokens_list): | ||
_validate(options, *tokens_list) | ||
|
@@ -137,14 150,18 @@ async def run(options, workflow_id, *tokens_list): | |
|
||
if options.hold_point_string: | ||
mutation = SET_HOLD_POINT_MUTATION | ||
args = {'point': options.hold_point_string} | ||
args = { | ||
'point': options.hold_point_string, | ||
'flowNum': options.flow_num | ||
} | ||
else: | ||
mutation = HOLD_MUTATION | ||
args = { | ||
'tasks': [ | ||
id_.relative_id_with_selectors | ||
for id_ in tokens_list | ||
] | ||
], | ||
'flowNum': options.flow_num | ||
} | ||
|
||
mutation_kwargs = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this semi duplicate the logic in cylc trigger? Surely all use-cases of
--flow
should behave roughly the same, and probably be centralized inoption_parser.py
. Centralizing them here is reasonable too, but on balance this is more about options than flows?You might want to give it a kwarg where you pass it a list of acceptable strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, there are some differences, e.g.
cylc trigger --flow=new
makes sense, butcylc hold --flow=new
doesn't.