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

Rose conf.read jinja2 #3913

Merged
merged 10 commits into from
Dec 30, 2020
Merged

Rose conf.read jinja2 #3913

merged 10 commits into from
Dec 30, 2020

Conversation

wxtim
Copy link
Member

@wxtim wxtim commented Nov 3, 2020

These changes address #3819
Summary of Changes

  • Added ability to use cylc.configure entry point to parse variables for Cylc in cylc/flow/parsec/fileparse.py.
  • Written a template cylc install which installs files listed in rose-suite.conf using cylc.install entry point.
  • Written functional tests (this seems pretty odd, since they will only work if the rose-cylc plugin is installed, but it's probably ok, for now)
  • Added CYLC_VERSION jinja2 variable (not to be confused with env var environ['CYLC_VERSION'] (which might not be set at all))

I have not raised a warning for absence of root-dir - I think that this needs to be in the plugin.

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Appropriate tests are included (unit and/or functional).
    • Unit test all functionality in new python code
    • Functional test basic rose-suite.conf reading functionality, but cannot check the optional config reading until it's plumbed into the CLI
  • Appropriate change log entry included.
  • No documentation update required: Full documentation of all sections of the rose-suite.conf work after all done.

@TomekTrzeciak
Copy link
Contributor

Do you plan to get this working for [empy:suite.rc] too (currently it doesn't)?

Also, rose suite-run adds a few extra variables (ROSE_ORIG_HOST, ROSE_SITE, ROSE_VERSION and ROSE_SUITE_VARIABLES metomi/rose#2338).

@wxtim
Copy link
Member Author

wxtim commented Nov 4, 2020

Do you plan to get this working for [empy:suite.rc] too (currently it doesn't)?

Yes.

@wxtim wxtim force-pushed the rose-conf.read_jinja2 branch 3 times, most recently from a89ea8d to f37b424 Compare November 6, 2020 07:48
@wxtim wxtim requested a review from datamel November 6, 2020 11:19
@wxtim wxtim self-assigned this Nov 6, 2020
@wxtim wxtim force-pushed the rose-conf.read_jinja2 branch 2 times, most recently from 42e834f to 699343e Compare November 10, 2020 08:22
cylc/flow/config.py Outdated Show resolved Hide resolved
@wxtim wxtim force-pushed the rose-conf.read_jinja2 branch 2 times, most recently from fafcee2 to 84703f8 Compare November 10, 2020 14:52
@wxtim wxtim marked this pull request as draft November 11, 2020 08:25
@wxtim
Copy link
Member Author

wxtim commented Nov 11, 2020

I've converted this back to a draft PR having decided to steam 🚂 on into dealing with empy, fileinstall and environment variables.

@wxtim wxtim force-pushed the rose-conf.read_jinja2 branch 2 times, most recently from 771c256 to 0aef19d Compare November 13, 2020 14:03
cylc/flow/parsec/fileparse.py Outdated Show resolved Hide resolved
@wxtim wxtim marked this pull request as ready for review November 17, 2020 16:30
@wxtim wxtim force-pushed the rose-conf.read_jinja2 branch 2 times, most recently from 5f443ab to 58fb759 Compare November 18, 2020 16:42


def lion():
raise TerriblePunException("This is a Lion's Main script")
Copy link
Member

Choose a reason for hiding this comment

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

🍌

Copy link
Member Author

@wxtim wxtim Dec 17, 2020

Choose a reason for hiding this comment

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

wait until you hear about

count_of = 0
for i in monte_christo:
    count_of += 1

@oliver-sanders
Copy link
Member

@TomekTrzeciak some follow on work captured in these issues otherwise this should be done.

Note: The cylc install command (replacement for rose suite-run) is not yet implemented hence this PR adds a quick dummy command which doesn't make much sense in of itself. The src/run dir separation and the rest of the install functionality will come in #4000.

@oliver-sanders
Copy link
Member

Code looks good, need to go through and test again but not expecting any surprises.

@TomekTrzeciak
Copy link
Contributor

@TomekTrzeciak some follow on work captured in these issues otherwise this should be done.

Thanks everyone for perseverance on this one, I think the final result is better for it.

One more thing: I think the suggestion to consolidate jinja2/empy code paths #3913 (comment) is still worth doing at some point, but it would require altering cylc view options. It was my mistake to add --empy option there alongside --jinja2 rather than replace it with something more generic. Since you can't have more than one templating engine on the shebang line, it makes no sense to have more than one option for it. Perhaps it's worth to capture this in a separate ticket?

@oliver-sanders
Copy link
Member

Can do, tag it against 8.x.

@TomekTrzeciak
Copy link
Contributor

What's the plan for replacement of -O command line option: #3819 (comment). Is it this PR or follow on?

@oliver-sanders
Copy link
Member

oliver-sanders commented Dec 21, 2020

Will stay as -O, not to be done in this PR (needs a plugin interface that can mutate the CLI)

Detail:

-O, -S and -D options will be implemented in cylc install as they were for rose suite-run, however,
cylc install will now record these settings in a new optional config (called cylc install).

The Rose config will be installed into the run dir and the rose config command will be able to load
this picking up all specified optional configs.

There will be a new --clear-rose-install-options option to cylc reinstall that removes this opt config
before reinstalling (equiv to removing the file manually before reinstallation).

cylc/flow/parsec/fileparse.py Outdated Show resolved Hide resolved
cylc/flow/parsec/fileparse.py Outdated Show resolved Hide resolved
cylc/flow/parsec/fileparse.py Outdated Show resolved Hide resolved
tests/functional/rose-conf/01-empy.t Outdated Show resolved Hide resolved
tests/functional/rose-conf/04-opts-set-from-env.t Outdated Show resolved Hide resolved
tests/functional/rose-conf/06-jinja2.thorough/suite.rc Outdated Show resolved Hide resolved
tests/functional/rose-conf/08-template-engine-conflict.t Outdated Show resolved Hide resolved
@wxtim wxtim requested a review from MetRonnie December 21, 2020 23:18
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.

LGTM assuming tests pass

@oliver-sanders
Copy link
Member

oliver-sanders commented Dec 22, 2020

Tests now passing, will have a final test today tomorrow next week :(.

@oliver-sanders
Copy link
Member

Commits will need rationalising pre-merge.

stub tests for rose fileinstall

added cylc install and functional test

added check that hash is in flow.cylc if reqd.

added rose vars to environment for scheduler.
Removed literal_eval - it's now in the Rose-plugin.
Removed writing Environment vars to scheduler environment as the plugin now does this.
Assertation Error -> Assertion Error.
Added Oliver's through Jinja2 functional test.

added the pre_install step to the install script
…empy

added Oliver's suggestion about multiple plugins

fail if empy/jinja2 section in suite.conf and wrong shebang line

refactor fileparse logic

added export XYZ to jinja2 test
make sure that template_vars is always available

attempt to make template variables safe

Update cylc/flow/parsec/fileparse.py

Co-authored-by: Oliver Sanders <oliver.sanders@metoffice.gov.uk>

Apply suggestions from code review

added validate step to rose conf tests

re-add warning if templates vars will be over-written fromt he CLI

fail horribly if multiple plugins clash

added test to demonstrate that you can't conflict the templating engine in the plugin.

Fixed failure to provide env vars in install

pre_configure: test entry point

fixes to review items
@wxtim
Copy link
Member Author

wxtim commented Dec 22, 2020

Commits will need rationalising pre-merge.

@oliver-sanders down to 9 ok?

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.

🥳

@oliver-sanders oliver-sanders merged commit 9b9dd86 into cylc:master Dec 30, 2020
@TomekTrzeciak TomekTrzeciak mentioned this pull request Jan 11, 2021
3 tasks
@hjoliver hjoliver modified the milestones: cylc-8.0a3, cylc-8.0b0 Feb 25, 2021
@wxtim wxtim deleted the rose-conf.read_jinja2 branch March 22, 2022 16:58
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.

6 participants