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

Config change.stop after cycle point #3883

Merged

Conversation

wxtim
Copy link
Member

@wxtim wxtim commented Oct 21, 2020

These changes close #3694 : Implement a [scheduling]stop after cycle point configuration to match the cylc run --stop-cycle-point=POINT cli option.

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 (unit and/or functional).
  • Appropriate change log entry included.
  • Appropriate Auto-doc string added for the command reference.
  • Documentation PR.
  • No dependency changes.

@wxtim wxtim self-assigned this Oct 21, 2020
@wxtim wxtim added the small label Oct 21, 2020
@wxtim wxtim added this to the cylc-8.0.0 milestone Oct 21, 2020
@wxtim wxtim marked this pull request as draft October 22, 2020 06:24
Comment on lines 488 to 503
if (
not self.is_restart or
not self.options.ignore_stopcp
):
if (
'stop after cycle point' in self.config.cfg['scheduling'] and
self.options.stopcp is None
):
self.pool.set_stop_point(get_point(
self.config.cfg['scheduling']['stop after cycle point']
))
self.options.stopcp = self.config.cfg['scheduling'][
'stop after cycle point'
]
if self.options.stopcp:
self.pool.set_stop_point(get_point(self.options.stopcp))
Copy link
Member

Choose a reason for hiding this comment

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

Can this be simplified along the lines of:

if not self.options.stopcp:
    # doesn't matter if stop after cycle point is None
    self.options.stopcp = self.config.cfg['scheduling']['stop after cycle point']
if self.options.stopcp:
    self.pool.set_stop_point(get_point(self.options.stopcp))

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really: Your suggestion would never allow the command line to over-ride the config: I'm not against tidying or commenting the logic though. It's a bit wierd.

Also, not having 'stop after cycle point' in self.config.cfg['scheduling'] would mean putting this in a try:/except: in case the config item was blank(I mean, I could set a default, but that seems weird in this instance).

Copy link
Member Author

@wxtim wxtim Oct 22, 2020

Choose a reason for hiding this comment

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

Sources of stopcp by priority

  • Command line
  • Database
  • Config

We can simplify the logic by creating a temporary variable to store our stopcp in, and only overwriting the self.options.stopcp at the end of the process.

We also need to check that --ignore-stop-after-cycle-point works.

I wish that this were an easily unit-testable bit.

Test Cases

Command Line Set Database Set Config Set How
✔️ run or restart; check stopped correctly
✔️ ✔️ run with config set; restart with command line set; check finished at CLI stop point
✔️ ✔️ run with CLI stop sooner than config; ensure has stopped at CLI stop point
✔️ ✔️ ✔️ run with config set, stop with cylc stop; restart with command line set
✔️ run with CLI, stop artificially; restart without CLI set; check flow stopped at stop point
✔️ run with config; check stopped at right place
✔️ ✔️ run with stop point, stop with cylc stop in suite; sed mod the config stop point restart; check finish at db stop point
Not a test case

Additionally we should test each of these cases with a restart with and without the --ignore-stop-cycle-point cli option.

Copy link
Member

Choose a reason for hiding this comment

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

Not really: Your suggestion would never allow the command line to over-ride the config

I think it would, the config value is only read if the CLI opt is not set.

@wxtim wxtim force-pushed the config-change.stop-after-cycle-point branch 2 times, most recently from 462226c to 7fba3cf Compare October 23, 2020 10:33
@wxtim wxtim force-pushed the config-change.stop-after-cycle-point branch from 7fba3cf to a195573 Compare October 23, 2020 11:03
@wxtim wxtim requested a review from oliver-sanders October 23, 2020 11:03
@wxtim wxtim marked this pull request as ready for review October 23, 2020 11:03
Comment on lines +1873 to +1874

def process_cylc_stop_point(self):
Copy link
Member

@MetRonnie MetRonnie Oct 23, 2020

Choose a reason for hiding this comment

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

I would have thought a unit test for this method would be better suited than a functional test (quicker to run; we only need to test the logic in the method, otherwise the test corresponding to set_stop_point() should handle the rest? (assuming such a test exists))

Copy link
Member Author

Choose a reason for hiding this comment

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

I considered it, but because it's a method of the class it'd require some in un-fun mocking. However it'd be nicer, and I like the idea of working out how.

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

Looks good apart from question of unit vs functional test (up to you). However still needs a change log entry and maybe a cylc-doc PR?

@wxtim
Copy link
Member Author

wxtim commented Oct 25, 2020

Looks good apart from ... and a cylc-doc PR?

I'm not sure about a cylc-doc PR.

I have added some detail to the desc field in the config which should go into the reference section of the documentation.

I don't think there is value in copying that somewhere else. I can't remember what was behind the inclusion of the stop after cycle point item and the workshop notes don't lead me to enlightenment.

What is the use-case for this config item @oliver-sanders? If I understood that I could probably do something in src/tutorial/scheduling/further_scheduling. Otherwise further changes to cylc-doc seem like duplication.

@oliver-sanders
Copy link
Member

Don't think this needs adding to the user guide or anything. The best documentation would likely be to note the CLI opt referencing this config (and vice versa).

- Update cylc/flow/cfgspec/suite.py [Co-authored-by: Oliver Sanders <oliver.sanders@metoffice.gov.uk>]
- added explanation of priority for stop-after-cycle-point to cli
- fix review issues.
@wxtim wxtim force-pushed the config-change.stop-after-cycle-point branch from c8b6733 to 0c55c94 Compare October 27, 2020 09:06
@oliver-sanders oliver-sanders merged commit 5073409 into cylc:master Oct 27, 2020
@MetRonnie MetRonnie modified the milestones: cylc-8.0.0, cylc-8.0a3 Oct 27, 2020
@hjoliver hjoliver modified the milestones: cylc-8.0a3, cylc-8.0b0 Feb 25, 2021
@wxtim wxtim deleted the config-change.stop-after-cycle-point branch March 22, 2022 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

conf: [scheduling]stop after cycle point
4 participants