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

Validate task messages & task outputs separately #3820

Merged
merged 4 commits into from
Sep 18, 2020

Conversation

MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented Sep 16, 2020

Follow on from #3788, these changes close #3428

I didn't quite get it right in #3788. There are two different requirements for task messages and task outputs/message triggers.

  • Task messages (e.g. cylc message -- "${CYLC_SUITE_NAME}" "${CYLC_TASK_JOB}" "WARNING: Uh-oh"):
    • Can have colons only if there's one at the end of the first word of the message, which will be the (possibly custom) severity level
  • Task outputs/message triggers (e.g. [runtime][my_task][outputs]foo = "Uh-oh"):
    • Cannot have colons at all

Note: Task messages can be used for purposes other than for message triggering, so they can have colons after SEVERITY:. However, colons cannot be used in task messaging if indeed they are used for triggering, as suite/flow validation will fail if the task outputs contain colons.

Requirements 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).
  • Appropriate tests are included (doctests).
  • Appropriate change log entry included.
  • (master branch) I have opened a documentation PR at Add note on task message validation cylc-doc#157.
  • No dependency changes.

@MetRonnie MetRonnie added bug Something is wrong :( small labels Sep 16, 2020
@MetRonnie MetRonnie added this to the cylc-8.0a3 milestone Sep 16, 2020
@MetRonnie MetRonnie self-assigned this Sep 16, 2020
@MetRonnie MetRonnie changed the title Validate msg triggers2 Validate task messages & task outputs separately Sep 16, 2020
@MetRonnie MetRonnie mentioned this pull request Sep 16, 2020
7 tasks
@MetRonnie MetRonnie marked this pull request as draft September 16, 2020 15:15
@MetRonnie MetRonnie linked an issue Sep 16, 2020 that may be closed by this pull request
@MetRonnie MetRonnie force-pushed the validate-msg-triggers2 branch from 16e1803 to 4ea61fd Compare September 16, 2020 17:04
Comment on lines 136 to +140
elif ':' in message_str:
valid, err_msg = TaskMessageValidator.validate(message_str)
if not valid:
raise UserInputError(
f'Invalid task message "{message_str}" - {err_msg}')
Copy link
Member Author

Choose a reason for hiding this comment

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

The trouble with this is, it doesn't fail until the cylc message ... command inside [runtime][<task>]script is finally run. Not sure if there is a better way; trying to parse the contents of the script setting seems overly complicated

Copy link
Member

Choose a reason for hiding this comment

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

Ooh, yeah, hadn't thought of that. If messages were separate config items, that would be easier, but that train left the station long ago.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, maybe this is OK. It results in job, not scheduler, failure. So it can be fixed on the fly (fix task def, reload and retrigger).

Copy link
Member

Choose a reason for hiding this comment

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

On that basis I'm OK with this; but we'll see what @oliver-sanders thinks.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we could really hope to do anything better with the current system.

In cylc-message, allow colons only if one is present at the end of the first word
(i.e. severity level)
Not needed as each class already has doctests
@MetRonnie MetRonnie force-pushed the validate-msg-triggers2 branch from 4ea61fd to 3de4bb3 Compare September 16, 2020 20:29
@MetRonnie MetRonnie marked this pull request as ready for review September 16, 2020 20:35
Copy link
Member

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

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

(See discussion on validation above)

@MetRonnie
Copy link
Member Author

Not sure why tests timed out

2020-09-16T20:47:43Z [02:17:43] tests/f/cyclers/01-hourly.t ... ok    67572 ms (0.02 usr  0.00 sys + 96.47 cusr 10.37 csys = 106.86 CPU)
2020-09-16T21:14:41Z ##[error]The operation was canceled.

Re-running...

@oliver-sanders
Copy link
Member

oliver-sanders commented Sep 17, 2020

...Re-timed-out

Usually happens when a test is waiting for some form of signal but where no appropriate timeout was set. It's more than likely that this validation has flushed out an error in a test suite? The test should hang locally too, you should be able to see which one it is when run locally:

$ CHUNK=1/4 etc/bin/run-functional-tests tests/f

@MetRonnie
Copy link
Member Author

MetRonnie commented Sep 17, 2020

I should have expected that, considering that task message validation failure will stall the workflow (Cylc workflow, not GH Actions workflow...)

Task outputs are validated by
:py:class:`cylc.flow.unicode_rules.TaskOutputValidator`.

.. autoclass:: cylc.flow.unicode_rules.TaskOutputValidator
Copy link
Member

Choose a reason for hiding this comment

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

I think your cylc-doc PR also contains the line .. autoclass:: cylc.flow.unicode_rules.TaskOutputValidator.

I think that will attempt to document it twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

In that PR it's .. autoclass:: cylc.flow.unicode_rules.TaskMessageValidator

They're quite similarly named; maybe TaskMessageValidator should be renamed CylcMessageValidator?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, ok, these classes aren't user facing so don't need to worry too much about nomenclature.

Comment on lines 136 to +140
elif ':' in message_str:
valid, err_msg = TaskMessageValidator.validate(message_str)
if not valid:
raise UserInputError(
f'Invalid task message "{message_str}" - {err_msg}')
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we could really hope to do anything better with the current system.

@oliver-sanders
Copy link
Member

Tests passing.

@oliver-sanders
Copy link
Member

I'll leave the merge to you so you can decide where you want to put the .. autoclass:: directive.

@MetRonnie MetRonnie merged commit a4ff5d6 into cylc:master Sep 18, 2020
@MetRonnie MetRonnie deleted the validate-msg-triggers2 branch September 18, 2020 10:07
@hjoliver hjoliver removed this from the cylc-8.0a3 milestone Feb 25, 2021
@hjoliver hjoliver added this to the cylc-8.0b0 milestone Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is wrong :( small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cylc Validate check custom task outputs
3 participants