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

Create cylc config save file (opt/rose-suite-cylc-install.conf) #20

Merged
merged 9 commits into from
Feb 5, 2021

Conversation

wxtim
Copy link
Member

@wxtim wxtim commented Jan 5, 2021

sibling: cylc/cylc-flow#4023

Summary

Partial response to cylc-flow:#3819
Required by a future PR to cylc-flow adding command line options similar to the following rose suite-run options:

  • --opt-conf-key
  • --defines
  • --suite-defines

Some auto tests will fail if Cylc-flow is master.

Checklist

  • Written functionality.
  • Unit-ized functionality.
  • Written what I think are fairly thorough unit tests for non-top level functions.
  • Written a basic set of functional tests for the top level function.
    • Files are produced in the expected way.
    • Output nodes are what you'd expect.
  • Read through and double checked.
  • Re-read (proposal)[https://github.com/cylc/cylc-admin/blob/master/docs/proposal-cylc-rose-installing-rose-configs.md].
  • Sure that there are enough functional tests: I think that there are enough unit tests that functional testing can be quite a small selection. I've lifted these cases more or less wholesale from the cylc install proposal.
  • Manually check coverage of new code. - 100% for new code. rose.py.pdf

Outstanding questions

Protected filenames:

Configuration would be written to an optional configuration called cylc-install. The cylc install command would exclude this file from the rsync in order to protect it.

cylc install proposal

Is this the rose-suite-cylc-install.conf file. Does this need doing in cylc/cylc-flow?

@wxtim wxtim self-assigned this Jan 5, 2021
@wxtim wxtim marked this pull request as draft January 5, 2021 16:51
@wxtim wxtim force-pushed the create-cylc-config-save-file branch from c8e649e to 375cb92 Compare January 5, 2021 16:56
@wxtim wxtim mentioned this pull request Jan 5, 2021
3 tasks
@wxtim wxtim force-pushed the create-cylc-config-save-file branch from cdc19d5 to 4636222 Compare January 6, 2021 14:03
@wxtim wxtim marked this pull request as ready for review January 6, 2021 14:04
cylc/rose/rose.py Outdated Show resolved Hide resolved
@wxtim wxtim marked this pull request as draft January 8, 2021 16:13
@wxtim wxtim marked this pull request as ready for review January 15, 2021 09:14
@oliver-sanders
Copy link
Member

I think this should close #3819 wdyt?

@wxtim
Copy link
Member Author

wxtim commented Jan 18, 2021

I didn't enjoy rebasing this - I think that there is scope for tidying up the testing a little before release, but if things are functional I should like to have this PR merged.

@oliver-sanders
Copy link
Member

Is this the rose-suite-cylc-install.conf file. Does this need doing in cylc/cylc-flow?

Yes, and yes.

This needs adding to the cylc-install rsync exclude list.

@oliver-sanders
Copy link
Member

cylc install is erroring because the opts kwarg is not always passed through to the plugin and the code doesn't check is opts before trying to access attributes of opts.

cylc/cylc-flow#4023 (comment)

@wxtim
Copy link
Member Author

wxtim commented Jan 19, 2021

@oliver-sanders and @datamel Ready for review. Sorry about all the messing about.

@wxtim wxtim force-pushed the create-cylc-config-save-file branch 2 times, most recently from 46507cf to 479c87d Compare January 20, 2021 12:03
@wxtim wxtim mentioned this pull request Jan 20, 2021
cylc/rose/entry_points.py Outdated Show resolved Hide resolved
cylc/rose/entry_points.py Show resolved Hide resolved
cylc/rose/entry_points.py Outdated Show resolved Hide resolved
cylc/rose/entry_points.py Show resolved Hide resolved
@wxtim wxtim force-pushed the create-cylc-config-save-file branch from eeb3429 to c23bfbf Compare January 21, 2021 10:50
@oliver-sanders
Copy link
Member

oliver-sanders commented Jan 21, 2021

  1. Any new “defines” should be written to a new optional configuration with a special protected name

✅ Tested -D and -S.
✅ The (cylc-install) config is added to the end of the list.

  1. The cylc reinstall command should always move the cylc-install opt conf to the end of the list

⌛ Will test the reinstall part once we have a reinstall command.

  1. The cylc reinstall command should have an option to delete the cylc-install opt conf

⌛ Saving this one for a future PR.

  1. cylc install should record optional configs to the cylc-install optional config

❌ via -O CLI opt.
✅ via ROSE_SUITE_OPT_CONF_KEYS env var.
cylc-install|opts are appended to rose-suite.conf|opts

my test suite:

$ find .  -type f -name '*.conf' -exec echo -e '\n=== {} ===' \; -exec cat '{}' \;

=== ./opt/rose-suite-foo.conf ===
[jinja2:suite.rc]
Y="f"

=== ./opt/rose-suite-bar.conf ===
[jinja2:suite.rc]
Y="b"

=== ./rose-suite.conf ===
opts=

[jinja2:suite.rc]
Y="base"

my test install:

$ ROSE_SUITE_OPT_CONF_KEYS=foo cylc install -O bar -D '[env]a=b' -S 'a="b"'
INSTALLED foo from ~/roses/foo -> ~/cylc-run/foo/run1

the result:

$ find ~/cylc-run/foo/runN/ -type f -name '*.conf' -exec echo -e '\n=== {} ===' \; -exec cat '{}' \;

=== ~/cylc-run/foo/runN//opt/rose-suite-foo.conf ===
[jinja2:suite.rc]
Y="f"

=== ~/cylc-run/foo/runN//opt/rose-suite-bar.conf ===
[jinja2:suite.rc]
Y="b"

=== ~/cylc-run/foo/runN//opt/rose-suite-cylc-install.conf ===
# This file records CLI Options.

!opts=foo

[env]
a=b

[jinja2:suite.rc]
a="b"

=== ~/cylc-run/foo/runN//rose-suite.conf ===
# Config Options '(cylc-install)' from CLI appended to options already in `rose-suite.conf`.
!opts=(cylc-install)

[jinja2:suite.rc]
Y="base"

the diff:

 === ~/cylc-run/foo/runN//opt/rose-suite-cylc-install.conf ===
 # This file records CLI Options.

-!opts=foo
+!opts=bar foo

 [env]
 a=b

 [jinja2:suite.rc]
 a="b"

 === ~/cylc-run/foo/runN//rose-suite.conf ===
 # Config Options '(cylc-install)' from CLI appended to options already in `rose-suite.conf`.
-!opts=(cylc-install)
+opts=bar foo (cylc-install)

 [jinja2:suite.rc]
 Y="base"

@oliver-sanders
Copy link
Member

rose-suite.conf|opts setting is still ignored (which means it won't be loaded by metomi.rose.config_tree).

@wxtim wxtim force-pushed the create-cylc-config-save-file branch from 615d87c to c2211c3 Compare January 27, 2021 11:59
wxtim and others added 2 commits February 1, 2021 14:12
Co-authored-by: Oliver Sanders <oliver.sanders@metoffice.gov.uk>
cylc/rose/entry_points.py Outdated Show resolved Hide resolved
@wxtim wxtim changed the title Create cylc config save file [Test failure may be OK] Create cylc config save file Feb 2, 2021
@oliver-sanders
Copy link
Member

$ cylc install
...
PluginError: Error in plugin cylc.post_install.rose_files
can only concatenate str (not "bytes") to str

@oliver-sanders
Copy link
Member

cylc-flow: tim/cli-setting-of-rose-opts@d7f6cb18214776f63a336af1f478f584e1827192
cylc-rose: tim/create-cylc-config-save-file@6e7e0172bcaba225dc4961406f89e661d7c6853a

$ cylc install
...
PluginError: Error in plugin cylc.post_install.rose_files
can only concatenate str (not "bytes") to str

@wxtim
Copy link
Member Author

wxtim commented Feb 4, 2021

cylc-flow: tim/cli-setting-of-rose-opts@d7f6cb18214776f63a336af1f478f584e1827192
cylc-rose: tim/create-cylc-config-save-file@6e7e0172bcaba225dc4961406f89e661d7c6853a

$ cylc install
...
PluginError: Error in plugin cylc.post_install.rose_files
can only concatenate str (not "bytes") to str

I just can't replicate this @oliver-sanders

@oliver-sanders
Copy link
Member

oliver-sanders commented Feb 4, 2021

Here's an example flow:

$ find . -type f -exec echo -e '\n# {}\n' \; -exec cat '{}' \;

# ./flow.cylc


# ./opt/rose-suite-x.conf

[env]
FILENAME=x

# ./rose-suite.conf

[env]
FILENAME=base

[file:myfile]
source=localhost:$PWD/$FILENAME

# ./x

x

# ./base

base

For the record it turns out this was caused by the localhost: prefix on the source. This works (or at least parses) in Rose2019, however, does not at Rose2. Not related to this PR, a Rose issue will follow.

@oliver-sanders
Copy link
Member

oliver-sanders commented Feb 4, 2021

Opt conf key stuff looks good, for interest here is my test:

$ lsd
# ./opt/rose-suite-y.conf
[env]
O=Y

# ./opt/rose-suite-x.conf
[env]
O=X

# ./suite.rc

# ./rose-suite.conf
[env]
O=B



# base conf installed ✅
$ cylc clean conf-test; cylc install
$ rose config --file ~/cylc-run/conf-test/runN/rose-suite.conf env O
B

# opt conf overrides base conf ✅
$ cylc clean conf-test; cylc install -O x
$ rose config --file ~/cylc-run/conf-test/runN/rose-suite.conf env O
X

# ROSE_SUITE_OPT_CONF_KEYS override base conf in the correct order ✅
$ cylc clean conf-test; ROSE_SUITE_OPT_CONF_KEYS='x y' cylc install
$ rose config --file ~/cylc-run/conf-test/runN/rose-suite.conf env O
Y

# -O applied after ROSE_SUITE_OPT_CONF_KEY ✅
$ cylc clean conf-test; ROSE_SUITE_OPT_CONF_KEYS='x y' cylc install -O x
$ rose config --file ~/cylc-run/conf-test/runN/rose-suite.conf env O
X

# -O applied in order ✅
$ cylc clean conf-test; ROSE_SUITE_OPT_CONF_KEYS='x y' cylc install -O x -O y
$ rose config --file ~/cylc-run/conf-test/runN/rose-suite.conf env O
Y

@oliver-sanders
Copy link
Member

  1. Any new “defines” should be written to a new optional configuration with a special protected name

✅ Tested -D and -S.
✅ The (cylc-install) config is added to the end of the list.

  1. The cylc reinstall command should always move the cylc-install opt conf to the end of the list

⌛ Will test the reinstall part once we have a reinstall command.

  1. The cylc reinstall command should have an option to delete the cylc-install opt conf

⌛ Saving this one for a future PR.

  1. cylc install should record optional configs to the cylc-install optional config

✅ via -O CLI opt.
✅ via ROSE_SUITE_OPT_CONF_KEYS env var.
cylc-install|opts are appended to rose-suite.conf|opts

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.

All good except one last thing :(

The .rose-config_processors-file.db gets created in the source directory rather than the run directory.

This means that file installation from one installation can effect file installation in another.

It may be necessary to cd into the run dir before the file installation then back again afterwards (perhaps in a try/finally).

Otherwise all good, @datamel please review when you get time.

@wxtim
Copy link
Member Author

wxtim commented Feb 4, 2021

The .rose-config_processors-file.db gets created in the source directory rather than the run directory.
I believe that I have now fixed this. :)

@oliver-sanders
Copy link
Member

oliver-sanders commented Feb 5, 2021

Good to go here!

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.

@datamel could you review 2.

Cylc option parser object - we want to extract the following
values:
- opt_conf_keys (list or str):
Equivelent of ``rose suite-run --option KEY``
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

Suggested change
Equivelent of ``rose suite-run --option KEY``
Equivalent of ``rose suite-run --option KEY``

- defines (list of str):
Equivelent of ``rose suite-run --define KEY=VAL``
- suite_defines (list of str):
Equivelent of ``rose suite-run --define-suite KEY=VAL``
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Equivelent of ``rose suite-run --define-suite KEY=VAL``
Equivalent of ``rose suite-run --define-suite KEY=VAL``

@datamel datamel merged commit 8d64fd5 into cylc:master Feb 5, 2021
@wxtim wxtim mentioned this pull request Feb 8, 2021
2 tasks
wxtim added a commit to wxtim/cylc-rose that referenced this pull request Feb 8, 2021
…nal-tests

* master:
  [Test failure may be OK] Create cylc config save file (cylc#20)
wxtim added a commit to wxtim/cylc-rose that referenced this pull request Feb 8, 2021
…se-conf

* master:
  [Test failure may be OK] Create cylc config save file (cylc#20)
@wxtim wxtim changed the title [Test failure may be OK] Create cylc config save file Create cylc config save file (opt/rose-suite-cylc-install.conf) Mar 3, 2021
@wxtim wxtim deleted the create-cylc-config-save-file branch March 3, 2021 08:38
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.

3 participants