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

Flow trigger CLI and defaults #4739

Merged
merged 31 commits into from
Apr 13, 2022
Merged

Conversation

hjoliver
Copy link
Member

@hjoliver hjoliver commented Mar 14, 2022

These changes close #4686. Built on top of - and now replaces - #4738

Implement final agreed CLI and defaults for flow triggering.

TBD

  • currently spawns on all outputs of the triggered task on continuing the flow; use actual completed outputs
  • make it work even if the same task is triggered multiple times
  • tests for --flow=INT

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).
  • Applied any dependency changes to both setup.cfg and conda-environment.yml.
  • Appropriate tests are included (unit and/or functional).
  • Appropriate change log entry included.

@hjoliver hjoliver added this to the cylc-8.0rc3 milestone Mar 14, 2022
@hjoliver hjoliver self-assigned this Mar 14, 2022
@hjoliver hjoliver force-pushed the flow-triggers-wait branch 2 times, most recently from d5e6156 to 7bbc0c4 Compare March 15, 2022 00:15
@hjoliver hjoliver force-pushed the flow-triggers-wait branch from 7bbc0c4 to a1eefed Compare March 21, 2022 04:31
@hjoliver
Copy link
Member Author

Fast tests will fail till #4746 goes in.

@hjoliver hjoliver force-pushed the flow-triggers-wait branch 2 times, most recently from 742e4e4 to eb958ca Compare March 21, 2022 21:52
@hjoliver
Copy link
Member Author

This fixes and extends the DB task_outputs table. On master, the table holds only custom outputs, for the most recent submit of each task. Here, it holds all outputs, with flow numbers. E.g.:

$ sqlite3 -header ~/cylc-run/ft/runN/log/db "select * from task_outputs;"
cycle|name|flow_nums|outputs
1|foo|[1]|["submitted", "started", "succeeded"]
1|bar|[1]|["submitted", "started", "the quick brown fox", "succeeded"]
1|baz|[1]|["submitted", "started", "failed"]

For repeat-running a task in the same flow via cylc trigger --wait we care about outputs from the most recent run in the right flow, not necessarily the most recent submit. So at this stage I don't think it's necessary to add submit number to the table as well.

@hjoliver
Copy link
Member Author

hjoliver commented Mar 22, 2022

(One last TODO for tomorrow: correctly handle n=0 flow merge with a still-running trigger --wait task)

DONE

@hjoliver hjoliver force-pushed the flow-triggers-wait branch 2 times, most recently from b00913e to 52b7f52 Compare March 23, 2022 04:29
@hjoliver hjoliver marked this pull request as ready for review March 25, 2022 00:17
@hjoliver hjoliver force-pushed the flow-triggers-wait branch from 52b7f52 to bf94081 Compare March 25, 2022 04:02
@hjoliver hjoliver force-pushed the flow-triggers-wait branch from bf94081 to 294cc56 Compare April 4, 2022 00:26
@hjoliver
Copy link
Member Author

hjoliver commented Apr 4, 2022

(Rebased and deconflicted)

@oliver-sanders
Copy link
Member

Reviewing both parts together, only one issue found so far, the trigger mutation is broken in Tui and needs a small metadata change.

Here's a PR that adds a default value to the flow arg to allow tui to work with the mutation:

hjoliver#21

And a UI PR to fix a bug that caused the flow arg to be registered as required (in the amended schema):

cylc/cylc-ui#982

@hjoliver
Copy link
Member Author

hjoliver commented Apr 6, 2022

Here's a PR that adds a default value to the flow arg to allow tui to work with the mutation:

Thanks, merged!

Copy link
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.

Most the way through.

@hjoliver hjoliver changed the title Flow triggers 2/2: --wait via the DB Flow trigger CLI and defaults Apr 10, 2022
@hjoliver hjoliver force-pushed the flow-triggers-wait branch from 2093722 to 70ce9e6 Compare April 11, 2022 01:05
@hjoliver
Copy link
Member Author

Feedback addressed.

@hjoliver hjoliver force-pushed the flow-triggers-wait branch from 70ce9e6 to 1c59e54 Compare April 11, 2022 01:43
@dwsutherland
Copy link
Member

Here's a PR that adds a default value to the flow arg to allow tui to work with the mutation:

Thanks, merged!

Doesn't look like it's merged..

@hjoliver
Copy link
Member Author

Here's a PR that adds a default value to the flow arg to allow tui to work with the mutation:

Thanks, merged!

Doesn't look like it's merged..

Oops, good spot. It is now. I must have been waiting for tests or something.

@dwsutherland
Copy link
Member

dwsutherland commented Apr 11, 2022

Here's a PR that adds a default value to the flow arg to allow tui to work with the mutation:

Thanks, merged!

Doesn't look like it's merged..

Oops, good spot. It is now. I must have been waiting for tests or something.

Rightly so, it appears, Looks like there's a style hick-up over the f-docstring:

./cylc/flow/network/schema.py:14[10](https://github.com/cylc/cylc-flow/runs/5968017405?check_suite_focus=true#step:8:10):5: B021 f-string used as docstring.This will be interpreted by python as a joined string rather than a docstring.
Error: Process completed with exit code 1.

You wouldn't mind rebasing also? so I don't have to pip install (the master changes)

(though I've done my testing, so all good either way)

hjoliver and others added 8 commits April 11, 2022 19:38
* Set default values for args to allow them to be fired without
  additional context information.
* Add descriptions.
* Centralise the "flow" argument so it can be easily added to other
  mutations later.
@hjoliver hjoliver force-pushed the flow-triggers-wait branch from bf2797c to be68c3c Compare April 11, 2022 07:39
@hjoliver
Copy link
Member Author

Rebased.

@hjoliver
Copy link
Member Author

(Damn it, tests all passed before I merged that side PR and rebased!)

@hjoliver
Copy link
Member Author

Imported a flake8-bugbear error from @oliver-sanders side-PR:

./cylc/flow/network/schema.py:1410:5: B021 f-string used as docstring.This will be interpreted by python as a joined string rather than a docstring.

FYI @oliver-sanders (and others) - doc-strings cannot be f-strings:

https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals

@hjoliver hjoliver force-pushed the flow-triggers-wait branch from 113325b to a847222 Compare April 12, 2022 02:37
@hjoliver
Copy link
Member Author

All fixed 🎉

Copy link
Member

@dwsutherland dwsutherland left a comment

Choose a reason for hiding this comment

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

Looks good to me:

  • Worked in my environment.
  • Tests passed.
  • Code is fine.

👍

@@ -1404,6 +1406,11 @@ def description(self):
return StopMode(self.value).describe()


class Flow(String):
"""An integer or one of {FLOW_ALL}, {FLOW_NEW} or {FLOW_NONE}."""
Copy link
Member

Choose a reason for hiding this comment

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

Happy to leave those variables unexpanded?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't expand them, or the docstring ceases to be a docstring (see my comment on that).

I think it's fine to leave like that. Docstrings describe code, so it's not unreasonable for them to refer to variable (or constant) names. I should perhaps have removed the braces, but I added to comment to note that it shouldn't be turned back into an f-string.

@oliver-sanders
Copy link
Member

FYI @oliver-sanders (and others) - doc-strings cannot be f-strings:

TIL. You can modify, format or even replace a docstring after it has been declared, however, you cannot do so at the time of declaration.

FOO = 42


class Modified:
    '{FOO}'
    

Modified.__doc__ = Modified.__doc__.format(**globals())


class FString:
    f'''{FOO}'''
    
    
class Format:
    '''{FOO}'''.format(**globals())


# this works
print(Modified.__doc__)

# these don't
print(FString.__doc__)
print(Format.__doc__)
$ python mess.py 
42
None
None

@oliver-sanders
Copy link
Member

oliver-sanders commented Apr 12, 2022

Note: confirmed the tests from #4651 now all pass on this branch.

Copy link
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.

Completed functional review, all good except one bug which can cause multiple new flows to be created for a single trigger --flow=new event.

Put up a fix: hjoliver#22

Otherwise good!

Copy link
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.

🎉

Thanks @hjoliver this has been a fun one!

@oliver-sanders oliver-sanders merged commit 2d10d17 into cylc:master Apr 13, 2022
@hjoliver
Copy link
Member Author

tada

Thanks @hjoliver this has been a fun one!

Heheh, yes it has 🤣

🎉

@hjoliver hjoliver deleted the flow-triggers-wait branch April 13, 2022 20:24
@MetRonnie MetRonnie added the db change Change to the workflow database structure label Oct 11, 2022
MetRonnie added a commit to MetRonnie/cylc-flow that referenced this pull request Oct 11, 2022
It turns out there was a change to the DB structure in cylc#4739 (8.0rc3).
The restart incompat version should have been bumped but this was missed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db change Change to the workflow database structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trigger: generalisation of triggering approaches
4 participants