Skip to content

allow workflow config to unset global events config#6518

Merged
MetRonnie merged 5 commits intocylc:8.4.xfrom
TomekTrzeciak:workflow_events_fix
Feb 14, 2025
Merged

allow workflow config to unset global events config#6518
MetRonnie merged 5 commits intocylc:8.4.xfrom
TomekTrzeciak:workflow_events_fix

Conversation

@TomekTrzeciak
Copy link
Copy Markdown
Contributor

@TomekTrzeciak TomekTrzeciak commented Dec 6, 2024

This addresses a bug whereby it is not possible to reset list-type values like mail events from the global config to empty list by overriding them in the workflow config.

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.cfg (and conda-environment.yml if present).
  • Tests are included (or explain why tests are not needed).
  • Changelog entry included if this is a change that can affect users
  • Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/XXXX.
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@MetRonnie MetRonnie self-requested a review December 6, 2024 12:37
@MetRonnie MetRonnie added this to the 8.4.1 milestone Dec 6, 2024
@MetRonnie MetRonnie added bug? Not sure if this is a bug or not small labels Dec 6, 2024
@TomekTrzeciak TomekTrzeciak force-pushed the workflow_events_fix branch 3 times, most recently from a4d2d8f to c718f8b Compare December 6, 2024 19:23
@TomekTrzeciak TomekTrzeciak marked this pull request as ready for review December 6, 2024 22:57
@MetRonnie
Copy link
Copy Markdown
Member

Thanks @TomekTrzeciak 👍 it might be January before we have a chance to look at this however

@oliver-sanders
Copy link
Copy Markdown
Member

oliver-sanders commented Jan 6, 2025

This would change the meaning of mail events = from "reset to global default" to "reset to empty list".

The "reset to empty lisy" behaviour makes sense, but unfortunately, I think there may be valid use cases for both behaviours (especially when you take inheritance into account). I had a skim through workflows at our site to see what list items are being "unset" in this way and found the following:

  • mail events (a lot of instances)
  • (submission|execution) retry delays (a lot of instances)
  • handler events (a few instances)
  • collapsed families (a couple instances)

@MetRonnie
Copy link
Copy Markdown
Member

I think this "reset to global default" behaviour only happens for events settings and no other settings?

@TomekTrzeciak
Copy link
Copy Markdown
Contributor Author

I think this "reset to global default" behaviour only happens for events settings and no other settings?

My reading is that only events and mail settings under scheduler section would be affected by this change.

This would change the meaning of mail events = from "reset to global default" to "reset to empty list".

The "reset to empty lisy" behaviour makes sense, but unfortunately, I think there may be valid use cases for both behaviours (especially when you take inheritance into account). I had a skim through workflows at our site to see what list items are being "unset" in this way and found the following:

  • mail events (a lot of instances)
  • (submission|execution) retry events (a lot of instances)
  • handler events (a few instances)
  • collapsed families (a couple instances)

Out of this list only mail events and handler events would be affected by this change. On our site only the former (mail events) is set in the global config and thus would behave differently (and as expected IMHO).

@hjoliver
Copy link
Copy Markdown
Member

hjoliver commented Jan 7, 2025

So this change would mean:

  • no mention in workflow config: you get the global defaults
  • explicit key = # nothing: you get nothing

Seems good to me, no blockers as far as NIWA is concerned.

@oliver-sanders - would it be sufficient for you just to ping the owners of the workflows you found and tell them about the change?

@MetRonnie MetRonnie changed the base branch from master to 8.4.x January 9, 2025 18:33
@oliver-sanders
Copy link
Copy Markdown
Member

@oliver-sanders - would it be sufficient for you just to ping the owners of the workflows you found and tell them about the change?

Will do. I'll confirm the scope of the change and try to work out the intention of the users impacted. So long as it's just [scheduler][events and [scheduler][mail], I'm not expecting any issues.

Copy link
Copy Markdown
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

👍

I've taken a look into the change and am happy with the scope.

I had a look on site and found mail events = in 513 run dirs belonging to 47 users internally. I highly doubt that this change has the potential to cause any issues, but I've put up an internal bulletin to ensure that folks are aware. I don't think we need to go any further than that.

A quick changelog would be appreciated.

@MetRonnie
Copy link
Copy Markdown
Member

MetRonnie commented Feb 5, 2025

Sorry, just gotten round to this.

Apparently though, it is already possible to unset events by using a value of None, i.e.

# flow.cylc
[scheduler]
    [[events]]
        mail events = None

(Apologies for not realising this when you asked me back in December!)

@oliver-sanders oliver-sanders modified the milestones: 8.4.1, 8.4.x Feb 12, 2025
@oliver-sanders
Copy link
Copy Markdown
Member

^ @TomekTrzeciak thoughts?

@hjoliver
Copy link
Copy Markdown
Member

hjoliver commented Feb 13, 2025

with Conf('events',
desc=global_default(EVENTS_DESCR, '[scheduler][events]')):
for item, desc in EVENTS_SETTINGS.items():
desc = global_default(desc, f"[scheduler][events]{item}")
vdr_type = VDR.V_STRING_LIST
default: Any = Conf.UNSET
if item in {'handlers', 'handler events', 'mail events'}:
# Note: default of None for V_STRING_LIST is used to
# differentiate between not set vs set to empty
default = None

I had forgotten about this too, sorry.

However, it doesn't seem to be documented, and use of "None" (being Pythonic) is weird in a config file.
So I'd prefer this PR.
And we should document it.

@MetRonnie
Copy link
Copy Markdown
Member

MetRonnie commented Feb 14, 2025

Actually I've realised that mail events = None is no different from mail events = meow, giraffe, i.e. as long as you put a (list of) invalid values it will turn off mail events 😅 (The code Hillary linked is not actually relevant). Edit: an issue has been open for this for a while:

@MetRonnie MetRonnie modified the milestones: 8.4.x, 8.4.1 Feb 14, 2025
Copy link
Copy Markdown
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

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

I've pushed a changelog entry. Got one optional suggestion, take or leave it 👍

try:
cmd = handler % (template_variables)
except KeyError as exc:
except (KeyError, TypeError, ValueError) as exc:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Think this could be simplified to

Suggested change
except (KeyError, TypeError, ValueError) as exc:
except Exception as exc:

@MetRonnie
Copy link
Copy Markdown
Member

Actually, might as well merge

@MetRonnie MetRonnie merged commit aad39a9 into cylc:8.4.x Feb 14, 2025
wxtim added a commit to wxtim/cylc that referenced this pull request Mar 12, 2025
* upstream/8.4.x:
  Ensure `cylc message` exceptions are printed to stderr (cylc#6647)
  fix typo in stop.py - options.max_poll -> options.max_polls
  doc: improve NamespaceIDGlob description (cylc#6637)
  Document that "ex" prefix means "exclude" [skip ci]
  tests: remove string templating in SQL statements (cylc#6631)
  Bump dev version
  Prepare release 8.4.1
  Merge pull request cylc#6578 from MetRonnie/graphql-err-handling
  Update cylc/flow/etc/examples/expiry/index.rst
  Pytest: full verbosity for assertions
  Fix test picking up user global config
  Wrapper script: fix `PATH` override preventing selection of Cylc version in GUI under Cylc Hub
  Get poll to return task failure if job/log has been removed. (cylc#6577)
  work around NFS caching issues (cylc#6603)
  allow workflow config to unset global events config (cylc#6518)
  examples: document expiry workflow design patterns
wxtim added a commit to wxtim/cylc that referenced this pull request Mar 13, 2025
* upstream/8.4.x:
  Ensure `cylc message` exceptions are printed to stderr (cylc#6647)
  fix typo in stop.py - options.max_poll -> options.max_polls
  doc: improve NamespaceIDGlob description (cylc#6637)
  Document that "ex" prefix means "exclude"
  tests: remove string templating in SQL statements (cylc#6631)
  Bump dev version
  Prepare release 8.4.1
  Merge pull request cylc#6578 from MetRonnie/graphql-err-handling
  Update cylc/flow/etc/examples/expiry/index.rst
  Pytest: full verbosity for assertions
  Fix test picking up user global config
  Wrapper script: fix `PATH` override preventing selection of Cylc version in GUI under Cylc Hub
  Get poll to return task failure if job/log has been removed. (cylc#6577)
  work around NFS caching issues (cylc#6603)
  allow workflow config to unset global events config (cylc#6518)
  examples: document expiry workflow design patterns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug? Not sure if this is a bug or not small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants