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

made reinstall work on multiple workflows #5803

Merged

Conversation

markgrahamdawson
Copy link
Contributor

@markgrahamdawson markgrahamdawson commented Nov 1, 2023

closes #4579

Updates to code

To make the reinstall operation work for multiple workflows we need to make the main function asynchronous. To do this we switch out the reinstall_cli function which is called in def main for a call_multi function which is passed reinstall_cli wrapped in a partial.

We then have to go through the call stack and make sure that async and await keywords are used in the correct places - or that async versions of functions are used. So in this case the reinstall_cli function needed the async keyword added and get_option_parser multiworkflow=True.

That would be job done - however cylc_reinstall is also imported in validate_reinstall so we have to repeat the process of making everything conform with the asynchronous process here also. This includes:

  1. using wrapped_main instead of _main
  2. starting a new event loop for vro_cli
  3. using parse_id_async instead of parse_id
  4. making vro_cli asynchronous with the async keyword
  5. await cylc_reinstall and scheduler_cli

As scheduler_cli was now being called asynchronously but was not an async function so this needed to be implemented in cylc/flow/scheduler.py which was achieved by:

  1. switching out parse_ids for parse_ids_async
  2. ...some other stuff

Updates to tests

-- updates to tests --

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).
  • CHANGES.md 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.

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.

Looks good.

cylc/flow/scheduler_cli.py Outdated Show resolved Hide resolved
cylc/flow/scripts/reinstall.py Outdated Show resolved Hide resolved
tests/integration/test_reinstall.py Outdated Show resolved Hide resolved
@oliver-sanders oliver-sanders added this to the cylc-8.3.0 milestone Nov 15, 2023
@wxtim
Copy link
Member

wxtim commented Nov 15, 2023

I don't think that VR is quite right, sorry - I don't think it will yet take wild cards:

# for name in foo foot footling fool; do cylc vip ~/cylc-src/simplest/ -n $name; done
cylc stop '*'
fool/run1
Command submitted; the scheduler will log any problems.
 ...
# ensure it's stopped
cylc scan
# Make some reinstall-worthy change:
sed -i 's@a => b & c => d@a => b@' ~/cylc-src/simplest/flow.cylc 
cylc vr 'foo*'
WorkflowFilesError: invalid workflow name 'foo*' - can only contain: alphanumeric, `/`, `_`, `+`, `-`, `.`, `@`

@markgrahamdawson
Copy link
Contributor Author

I don't think that VR is quite right, sorry - I don't think it will yet take wild cards:

# for name in foo foot footling fool; do cylc vip ~/cylc-src/simplest/ -n $name; done
cylc stop '*'
fool/run1
Command submitted; the scheduler will log any problems.
 ...
# ensure it's stopped
cylc scan
# Make some reinstall-worthy change:
sed -i 's@a => b & c => d@a => b@' ~/cylc-src/simplest/flow.cylc 
cylc vr 'foo*'
WorkflowFilesError: invalid workflow name 'foo*' - can only contain: alphanumeric, `/`, `_`, `+`, `-`, `.`, `@`

Hmm I think this must be something to do with parsing of workflow ids but Im not sure why

@oliver-sanders
Copy link
Member

@wxtim, this PR is just about cylc reinstall, cylc vr does not yet accept multiple workflows.

@wxtim
Copy link
Member

wxtim commented Nov 16, 2023

@wxtim, this PR is just about cylc reinstall, cylc vr does not yet accept multiple workflows.

So it's out of scope. Agreed.

@oliver-sanders
Copy link
Member

LGTM, works well.

Tested cylc play with and without detaching locally and remotely to ensure this logic is still working as expected.

@oliver-sanders
Copy link
Member

oliver-sanders commented Nov 21, 2023

There are some unrelated test failures on this branch which have been fixed on master.

Suggest rebasing this branch to pull in the updates:

$ git fetch upstream
$ git checkout reinstall-multi-workflows
$ git branch reinstall-multi-workflows-safe  # make a safe copy before performing rebase
$ git rebase upstream/master
$ git push -f origin HEAD

You can squash the commits on this branch down at the same time by adding the -i argument to git rebase. In the file that opens, replace pick for all but the topmost commit to squash, then save and close the file.

@wxtim wxtim self-requested a review November 22, 2023 10:20
flake8 clean up

fixed unit tests

fixed cylc-combination/01-vr-reload functional test

fixed cylc-reinstall/00-simple.t functional test

updated change log

review amends
@oliver-sanders oliver-sanders merged commit c86f3e9 into cylc:master Nov 22, 2023
22 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reinstall: support reinstalling multiple workflows
3 participants