-
Notifications
You must be signed in to change notification settings - Fork 94
Validate workflow and task handler/mail event names #6838
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
Conversation
b008b4d
to
0e42c66
Compare
0e42c66
to
2c88a81
Compare
2c88a81
to
4d88c5f
Compare
4d88c5f
to
428420e
Compare
Wow, 2018 issue! Maybe a matter for another PR, but I think $ cat global.cylc
[scheduler]
[[events]]
mail events = elephant
$ CYLC_CONF_PATH=$PWD cylc config
[scheduler]
[[events]]
mail events = elephant
Parsec has an cylc-flow/cylc/flow/cfgspec/globalcfg.py Lines 1005 to 1007 in 0711cc9
This provides validation, but also gets pulled through into the config when documented: I don't know if this supports
I think parsec only offers The We could develop this functionality in parsec, it might come in handy again and the closer the functionality is to parsec, the closer it is to the docs. But at the end of the day, meh, whatever works! |
6934dfb
to
0b1057e
Compare
Moved validation of workflow event names to parsec
0b1057e
to
a2f74d9
Compare
EVENT_SUCCEEDED = TASK_OUTPUT_SUCCEEDED | ||
NON_UNIQUE_EVENTS = ('warning', 'critical', 'custom') | ||
STD_EVENTS = [ |
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.
Even if we can't validate these at the parsec level, it would be great to document them there.
I think something like this will make list the options in the same format the parsec autodoc would:
With conf('task events', desc = f'''
:Options: ``{"``, ``".join(STD_EVENTS)}}``, any custom event
Configure the task event handling system.
''')
Punt to issue if short on time.
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.
def _upg_wflow_event_names(self) -> None: | ||
"""Upgrade any Cylc 7 workflow handler/mail events names.""" | ||
for setting in ('handler events', 'mail events'): | ||
event_names: Optional[List[str]] = self.cfg['scheduler']['events'][ | ||
setting | ||
] | ||
if not event_names: | ||
continue | ||
upgraded: Dict[str, str] = {} | ||
for i, event in enumerate(event_names): | ||
if event in WorkflowEventHandler.EVENTS_DEPRECATED: | ||
event_names[i] = upgraded[event] = ( | ||
WorkflowEventHandler.EVENTS_DEPRECATED[event] | ||
) | ||
if upgraded and not cylc.flow.flags.cylc7_back_compat: | ||
LOG.warning( | ||
f"{upgrader.DEPR_MSG}\n" | ||
f" * (8.0.0) [scheduler][events][{setting}] " | ||
+ ', '.join(f'{k} -> {v}' for k, v in upgraded.items()) | ||
) |
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.
[minor] We could potentially make depr_options
a dict of {deprecated_opt: replacement}
and handle this in the parsec layer if we thought this functionality would be reused elsewhere.
Looks good, this is a huge improvement in the docs! Thanks for looking into the parsec changes. |
Closes #2756
The names set in these settings are now validated:
[scheduler][events]handler events
[scheduler][events]mail events
[runtime][X][events]handler events
[runtime][X][events]mail events
Any invalid event names will raise an
IllegalValueError
orWorkflowConfigError
.If there are any outdated Cylc 7
[scheduler][events]handler/mail events
they are automatically upgraded.Check List
CONTRIBUTING.md
and added my name as a Code Contributor.?.?.x
branch.