-
Notifications
You must be signed in to change notification settings - Fork 94
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
events: refactor key and make the event message available to handlers #5769
Conversation
c73a5cc
to
4ef5109
Compare
@@ -108,7 +108,7 @@ jobs: | |||
run: | | |||
# install system deps | |||
brew update | |||
brew install bash coreutils gnu-sed | |||
brew install bash coreutils gnu-sed grep |
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.
Install GNU grep.
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.
I think this may not work out of the box: You will probably have to do some path wrangling as well to make grep
be ggrep
rather than the BSD grep native to macos.
When I tried this however I got tonnes of errors: https://github.com/cylc/cylc-flow/actions/runs/6863292558/job/18662797573?pr=5819
It might be better if you do this since you have a local mac to try this stuff out on.
(draft until I can confirm there are no glaring coverage holes) |
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.
LGTM 👍 .. (MacOS test pending, of course)
@@ -159,6 +163,12 @@ def __eq__(self, other): | |||
for key in self._KEYS | |||
) | |||
|
|||
def __lt__(self, other): | |||
return self.id < other.id |
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.
Trying to figure out the utility of this beyond different cycles or submissions of the same task.. I guess I'll find out (?), maybe a requirement for use in dicts or sets?
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.
I think something was sorting tokens somewhere, possibly to get cycles/tasks in order in emails.
for key in ( | ||
WorkflowEventData.Workflow.value, | ||
WorkflowEventData.Host.value, | ||
WorkflowEventData.Port.value, |
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.
Fix a small bug where the port was never provided to the event handler as it had changed from Scheduler.port
to Scheduler.server.port
.
tokens: 'Tokens' | ||
|
||
|
||
def get_event_id(event: str, itask: 'TaskProxy') -> str: |
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.
This was pre-existing code which I centralised.
stdin_str += f'job: {id_key.tokens.relative_id}\n' | ||
stdin_str += f'event: {id_key.event}\n' | ||
stdin_str += f'message: {id_key.message}\n\n' |
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.
- Add the message into the email.
- Split the oneline email template into multiple lines with a blank line between 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.
Will check, but both the source and the output I'm expecting look more readable.
* Having Tokens objects mutable seemed like a good idea at the time. * But in practice, Tokens are rarely modified. * And their mutability is a barrier to use as dictionary keys and caching. * Implement the `__hash__` interface and block the `__setitem__` and `update` interfaces.
* Use a named tuple to store task event keys. * Rationalise the fields of task event keys. * Centralise event ID code. * Fixes an unrelated bug where the workflow port was not being included in emails.
* Closes cylc#5566 * Note, the event message is not stored in the database, so when events are restored from the DB on restart, the event message will default to the event name.
* Test had become broken by a positive behaviour change.
98% Happy Discussed example
with
In this case you don't get a message in the warning but you do get the event. |
@wxtim & @oliver-sanders - is there still something to finish off on this? |
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.
LGTM
The example above - Oliver was going to have a think about it. TBH this is a massive improvement. |
Latest commit makes the message available to the scheduler mail footer. Note entirely sure this makes sense (there may be multiple events/messages, the current logic just uses the last one), but this makes it consistent with the use of "event". Note: lint failures fixed on master |
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.
Looks like the best for the moment. Are you happy with 1 review for the last commit?
It's trivial (pass the message with the event), I think we're good. Lint failures are from master. |
#5566 turned out to be remarkably awkward to solve, as a result there are two other changes on this PR.
key1
field has been flattened out.Check List
CONTRIBUTING.md
and added my name as a Code Contributor.setup.cfg
(andconda-environment.yml
if present).CHANGES.md
entry included if this is a change that can affect users?.?.x
branch.