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

cylc vip #5121

Merged
merged 7 commits into from
Nov 17, 2022
Merged

cylc vip #5121

merged 7 commits into from
Nov 17, 2022

Conversation

wxtim
Copy link
Member

@wxtim wxtim commented Sep 7, 2022

Replaces #5094

#3896 - Implements the validate install play (VIP) working practice. I think that it works in principle for the other working practices.

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.
  • 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 vip cylc-doc#533.

@wxtim wxtim force-pushed the implement.VIP branch 2 times, most recently from fc088e7 to 9e821ec Compare September 7, 2022 10:22
@wxtim wxtim self-assigned this Sep 7, 2022
@wxtim wxtim added this to the cylc-8.1.0 milestone Sep 7, 2022
Copy link
Contributor

@datamel datamel left a comment

Choose a reason for hiding this comment

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

This is running smoothly for me with basic examples. I will test passing various options and re-review. A couple of comments so far.

cylc/flow/scripts/validate_install_play.py Outdated Show resolved Hide resolved
cylcvip Outdated Show resolved Hide resolved
@wxtim wxtim requested a review from datamel September 27, 2022 12:50
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.

There a quite a few of these kicking about, worth running through the lot to make sure.

FYI: PyPa / flake8 / black now agree that operators should proceed statements rather than follow e.g:

# do this
foo = (
    1
    + 2
    - 3
    + 4
)

# not this
foo = (
    1 +
    2 -
    3 +
    4
)
  • Reads better.
  • Better association of operators.
  • Safer to add/remove lines.
  • Super obvious when an operator is missing.

For the same reason I prefer preceding whitespace:

foo = (
    'Lorel'
    ' ipsum'
    ' dolor.'
    '\nSid'
    ' amet'
    ' apising'
    ' ellet!'
)

Which makes it really easy to spot missing whitespace in text like this.

cylc/flow/scheduler_cli.py Outdated Show resolved Hide resolved
cylc/flow/scheduler_cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@datamel datamel left a comment

Choose a reason for hiding this comment

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

Next lot of small comments from me.

cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
@wxtim
Copy link
Member Author

wxtim commented Sep 30, 2022

There a quite a few of these kicking about, worth running through the lot to make sure.

The text version of what your highlighting? Not the operator example? (I found plenty of the former, but none of the latter (I also found a string which had become accidentally truncated)).

Copy link
Contributor

@datamel datamel left a comment

Choose a reason for hiding this comment

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

This is working well for me. A couple of small comments...
When cylc vip is not given any arguments, we get traceback with a TypeError, rather than the standard cylc: error: Wrong number of arguments (too few).

cylc/flow/scripts/validate_install_play.py Show resolved Hide resolved
cylc/flow/scheduler_cli.py Outdated Show resolved Hide resolved
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.

I seem to be hitting a missing positional argument issue?

$ cylc vip
Traceback (most recent call last):
  File "~/mambaforge/envs/cylc.dev/bin/cylc", line 33, in <module>
    sys.exit(load_entry_point('cylc-flow', 'console_scripts', 'cylc')())
  File "/net~/cylc-flow/cylc/flow/scripts/cylc.py", line 657, in main
    execute_cmd(command, *cmd_args)    
  File "/net~/cylc-flow/cylc/flow/scripts/cylc.py", line 284, in execute_cmd
    entry_point.resolve()(*args)
  File "/net~/cylc-flow/cylc/flow/terminal.py", line 229, in wrapper                 
    wrapped_function(*wrapped_args, **wrapped_kwargs)
TypeError: main() missing 1 required positional argument: 'workflow_id'

cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
cylc/flow/scripts/validate_install_play.py Outdated Show resolved Hide resolved
cylc/flow/scripts/validate_install_play.py Outdated Show resolved Hide resolved
cylc/flow/scripts/validate_install_play.py Outdated Show resolved Hide resolved
tests/functional/cylc-combination-scripts/00-vip.t Outdated Show resolved Hide resolved
tests/functional/cylc-combination-scripts/00-vip.t Outdated Show resolved Hide resolved
@wxtim wxtim marked this pull request as draft October 25, 2022 09:07
@wxtim wxtim force-pushed the implement.VIP branch 5 times, most recently from a23a00c to ba5cd5e Compare October 25, 2022 13:25
@wxtim wxtim marked this pull request as ready for review October 26, 2022 06:59
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.

The OptionSettings approach is looking much cleaner / more intuitive for people adding new args 👍.

I think the kwarg constants (e.g. APPEND, HELP & DEST) can be removed now?

Comment on lines +139 to +140
icp_option = Option(
*ICP_OPTION.args, **ICP_OPTION.kwargs) # type: ignore[arg-type]
Copy link
Member

Choose a reason for hiding this comment

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

FYI you can provide args as kwargs and vice versa:

>>> def foo(a, b=2):
...     print(a, b)
... 
>>> foo(1, b=3)
1 3
>>> foo(1, 3)
1 3
>>> foo(a=1, b=3)
1 3
>>> foo(b=3, a=1)
1 3

So you could potentially absorb the positional args into the kwargs for simplicity.

@oliver-sanders
Copy link
Member

Testing going well so far. I've spotted one oddity in the logged command:

$ cylc vip generic --workflow-name foo --no-run-name
$ cylc validate ~/cylc-src/generic
Valid for cylc-8.1.0.dev
$ cylc install .
INSTALLED foo from ~/cylc-src/generic
$ cylc play foo

The logged output says cylc install . which is incorrect as PWD=$HOME at the time.

@oliver-sanders
Copy link
Member

oliver-sanders commented Nov 15, 2022

The install part of vip seems to be skipping the previous-run check.

If I install the workflow directly...

$ cylc install generic --workflow-name foo
INSTALLED foo/run3 from ~/cylc-src/generic
NOTE: 2 runs of "foo" are already active:
  ▶ foo/run1 vld601.cmpd1.metoffice.gov.uk:43118
  ▶ foo/run2 vld601.cmpd1.metoffice.gov.uk:43002
You can stop them all with:         
  cylc stop 'foo/*'                 
See "cylc stop --help" for options. 

... any previous runs are listed. Whereas cylc vip doesn't display this:

$ cylc vip generic --workflow-name foo                                               
$ cylc validate ~/cylc-src/generic
Valid for cylc-8.1.0.dev
$ cylc install .
INSTALLED foo/run2 from ~/cylc-src/generic
$ cylc play foo
 
 ▪ ■  Cylc Workflow Engine 8.1.0.dev
 ██   Copyright (C) 2008-2022 NIWA
▝▘    & British Crown (Met Office) & Contributors
 
INFO - Extracting job.sh to ~/cylc-run/foo/run2/.service/etc/job.sh
foo/run2: vld601.cmpd1.metoffice.gov.uk PID=128496

This also means the --no-ping option is currently functionless in cylc vip.

Should try to get the previous-run-scanning working in cylc vip as the compound command makes it much easier to end up with multiple runs running in parallel.

@wxtim
Copy link
Member Author

wxtim commented Nov 15, 2022

Should try to get the previous-run-scanning working in cylc vip as the compound command makes it much easier to end up with multiple runs running in parallel.

I think this is straightforward - I was looking at that code yesterday.

@wxtim
Copy link
Member Author

wxtim commented Nov 15, 2022

The OptionSettings approach is looking much cleaner / more intuitive for people adding new args +1.

I think the kwarg constants (e.g. APPEND, HELP & DEST) can be removed now?

DEST is indeed no-longer required. The other two are still used. I've been able to remove ACTION, DEFAULT, METAVAR, CHOICES, OPTS, USEIF

@wxtim wxtim mentioned this pull request Nov 16, 2022
8 tasks
@oliver-sanders
Copy link
Member

All looking good to me, will finish off tomorrow.

Copy link
Contributor

@datamel datamel left a comment

Choose a reason for hiding this comment

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

Small flake8 fix needed. I have checked this branch out and have been working with it for a while.
I have read the code and run the tests locally, I have run a bunch of manual tests, no problems from me found. I'm happy to approve once CI passing.

cylc/flow/option_parsers.py Outdated Show resolved Hide resolved
Co-authored-by: Melanie Hall <37735232+datamel@users.noreply.github.com>
@wxtim
Copy link
Member Author

wxtim commented Nov 17, 2022

@datamel I found a new bug this very morning - would you care to check a22d978 too?

Did your testing include

cd ~/cylc-src/myworkflow
cylc vip

@datamel
Copy link
Contributor

datamel commented Nov 17, 2022

@datamel I found a new bug this very morning - would you care to check a22d978 too?

Did your testing include

cd ~/cylc-src/myworkflow
cylc vip

For info. This was tested by me but my setup uses localhost as the run host so it worked without error for me!
Retesting this change now.

Copy link
Contributor

@datamel datamel left a comment

Choose a reason for hiding this comment

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

I've double checked the remote re-invocation is working correctly. Thanks @wxtim, great change, super handy one to have in!

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.

Sorted 🚀!

I especially love how fast this is compared to rose suite-ruin!

Comment on lines +26 to +27
cp -r "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/flow.cylc" .
cp -r "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/reference.log" .
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cp -r "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/flow.cylc" .
cp -r "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/reference.log" .
cp "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/flow.cylc" .
cp "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/reference.log" .

@@ -10,7 +10,7 @@ def main():
os.path.join(os.getenv("CYLC_WORKFLOW_RUN_DIR"), "log", "db"))
lockf(handle, LOCK_SH)
call([
"cylc", "task", "message", "I have locked the public database file"])
"cylc", "task-message", "I have locked the public database file"])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"cylc", "task-message", "I have locked the public database file"])
"cylc", "message", "I have locked the public database file"])

@@ -11,7 +11,7 @@ def main():
os.path.join(os.getenv("CYLC_WORKFLOW_RUN_DIR"), "log", "db"))
lockf(handle, LOCK_SH)
call([
"cylc", "task", "message", "I have locked the public database file"])
"cylc", "task-message", "I have locked the public database file"])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"cylc", "task-message", "I have locked the public database file"])
"cylc", "message", "I have locked the public database file"])

@oliver-sanders oliver-sanders merged commit ecfdd88 into cylc:master Nov 17, 2022
@wxtim wxtim deleted the implement.VIP branch December 1, 2022 13:16
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.

None yet

3 participants