Skip to content
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

cylc set stuffs #44

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions cylc/flow/scripts/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
'''


SELECTOR_ERROR = (
'Use "--output={1}" to specify outputs, not "{0}:{1}"'
)


def get_option_parser() -> COP:
parser = COP(
__doc__,
Expand Down Expand Up @@ -296,18 +301,19 @@ def get_output_opts(output_options: List[str]):
"""Convert outputs options to a flat list, and validate.

Examples:
Good:
>>> get_output_opts(['a', 'b,c'])
['a', 'b', 'c']

# OK: "required" is explicit default
>>> get_output_opts(["required"])
>>> get_output_opts(["required"]) # "required" is explicit default
[]


Bad:
>>> get_output_opts(["required", "a"]) # "required" must be used alone
Traceback (most recent call last):
InputError:
# Error: "required" must be used alone
>>> get_output_opts(["required", "a"])
>>> get_output_opts(["waiting"]) # cannot "reset" to waiting
Traceback (most recent call last):
...
InputError:

"""
Expand All @@ -319,6 +325,10 @@ def get_output_opts(output_options: List[str]):

if "required" in outputs:
raise InputError("--out=required must be used alone")
if "waiting" in outputs:
raise InputError(
"Tasks can not be set to waiting, use a new flow to re-run"
)
Comment on lines +328 to +331
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-empting people trying to cylc set --out=waiting.


return outputs

Expand All @@ -341,11 +351,44 @@ def validate_opts(output_opt: List[str], prereq_opt: List[str]):
raise InputError("Use --prerequisite or --output, not both.")


def validate_tokens(tokens_list):
"""Check the cycles/tasks provided.

This checks that cycle/task selectors have not been provided in the IDs.

Examples:
Good:
>>> validate_tokens([Tokens('w//c')])
>>> validate_tokens([Tokens('w//c/t')])

Bad:
>>> validate_tokens([Tokens('w//c:s')])
Traceback (most recent call last):
cylc.flow.exceptions.InputError
>>> validate_tokens([Tokens('w//c/t:s')])
Traceback (most recent call last):
cylc.flow.exceptions.InputError

"""
for tokens in tokens_list:
if tokens['cycle_sel']:
raise InputError(SELECTOR_ERROR.format(
tokens['cycle'],
tokens['cycle_sel'],
))
if tokens['task_sel']:
raise InputError(SELECTOR_ERROR.format(
tokens['task'],
tokens['task_sel'],
))
Comment on lines +379 to +383
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I absent-mindedly tried running a command like this cylc set workflow//cycle/task:output rather than cylc set workflow//cycle/task --out=output.

The CLI accepted this, but it didn't match any tasks because it merged the output in with the task name.



async def run(
options: 'Values',
workflow_id: str,
*tokens_list
) -> None:
validate_tokens(tokens_list)

pclient = get_client(workflow_id, timeout=options.comms_timeout)

Expand Down
5 changes: 3 additions & 2 deletions cylc/flow/unicode_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
_TASK_NAME_PREFIX,
)
from cylc.flow.task_qualifiers import TASK_QUALIFIERS
from cylc.flow.task_state import TASK_STATUSES_ORDERED

ENGLISH_REGEX_MAP = {
r'\w': 'alphanumeric',
Expand Down Expand Up @@ -350,8 +351,8 @@ class TaskOutputValidator(UnicodeRuleChecker):
not_starts_with('_cylc'),
# blacklist keywords
not_equals('required', 'optional', 'all'),
# blacklist built-in task qualifiers
not_equals(*TASK_QUALIFIERS),
# blacklist built-in task qualifiers and statuses (e.g. "waiting")
not_equals(*sorted({*TASK_QUALIFIERS, *TASK_STATUSES_ORDERED})),
]


Expand Down
4 changes: 2 additions & 2 deletions tests/functional/authentication/00-shared-fs.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ WORKFLOW_LOG="${WORKFLOW_RUN_DIR}/log/scheduler/log"
# Note: double poll existence of workflow log on workflow host and then localhost to
# avoid any issues with unstable mounting of the shared file system.
poll ssh -oBatchMode=yes -n "${CYLC_TEST_HOST}" test -e "${WORKFLOW_LOG}"
poll_grep_workflow_log -E '19700101T0000Z/t1 submitted .* => running'
poll_grep_workflow_log -E '19700101T0000Z/t1 running .* => failed'
poll_grep_workflow_log -E '19700101T0000Z/t1/01:submitted.* => running'
poll_grep_workflow_log -E '19700101T0000Z/t1/01:running.* => failed'
Comment on lines +44 to +45
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test got missed as it isn't run in CI


run_ok "${TEST_NAME_BASE}-broadcast" \
cylc broadcast -n 't1' -s '[environment]CYLC_TEST_VAR_FOO=foo' "${WORKFLOW_NAME}"
Expand Down
Loading