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

Recipe parametrisation #337

Merged
merged 43 commits into from
Jan 30, 2024
Merged

Recipe parametrisation #337

merged 43 commits into from
Jan 30, 2024

Conversation

jfrost-mo
Copy link
Member

@jfrost-mo jfrost-mo commented Dec 18, 2023

Fixes #296

I hope you both had a good break, and I apologies for the rather large review request on your return. This PR adds variables into the recipe, which allows recipes to be make generic across times, locations, model fields, and more.

  • Update documentation Rendered
    • Bake CLI docs
    • Cookbook CLI docs
    • New usage guide on recipe variables
  • Add tests
  • Add recipe using variables.

@jfrost-mo jfrost-mo self-assigned this Dec 18, 2023
@jfrost-mo jfrost-mo added the enhancement New feature or request label Dec 18, 2023
@jfrost-mo jfrost-mo changed the title Recipe parameterisation Recipe parametrisation Dec 18, 2023
@jfrost-mo

This comment was marked as resolved.

@jfrost-mo

This comment was marked as resolved.

Copy link
Contributor

github-actions bot commented Dec 19, 2023

Coverage

@jfrost-mo jfrost-mo force-pushed the 296_recipe_parameterisation branch 3 times, most recently from 586ff31 to 7b1bc09 Compare December 19, 2023 16:38
This is needed to fix the coverage failures detailed at
nedbat/coveragepy#512

We may instead need to have this listed somewhere else however, as
if pytest can't pick up the pyproject.toml it can't read the line
telling it to use it.
This also fixes cset cookbook, that has been unknowingly broken when
not installed from source. This was due to it not including the recipes
in the package.
Also rearranged the cookbook CLI arguments.

Specifically test for None

Previously any falsey value could have unexpectedly worked.
This makes order irrelevant, and means they match the other arguments.

Make input and output dirs required for bake

Also improve a docstring

Exist non-zero when unhandled arguments are given

Add required options to bake test
These are variables that can be put into a recipe and are replaced
at runtime with values specified as command line arguments.

In a recipe file they are any string value of the form `$VARIABLE`,
where the variable name can consist of A-Z and _.

The runtime value is given to cset bake in the form `--VARIABLE=value`.

Add fix variable handling and add tests

Test for missing variable value

Add documentation for recipe variables
@jfrost-mo

This comment was marked as outdated.

As we use conda the pip update doesn't do anything. We use our own
autoupdate system for our conda lock files.
@jfrost-mo jfrost-mo changed the title Recipe parametrisation Recipe parametrisation and looping in include file level Jan 15, 2024
@jfrost-mo jfrost-mo changed the title Recipe parametrisation and looping in include file level Recipe parametrisation Jan 15, 2024
Copy link
Contributor

@Sylviabohnenstengel Sylviabohnenstengel left a comment

Choose a reason for hiding this comment

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

Overall the code looks correct to me.

cset-workflow/meta/rose-meta.conf Show resolved Hide resolved
docs/source/reference/cli.rst Outdated Show resolved Hide resolved
src/CSET/_common.py Show resolved Hide resolved
Copy link
Contributor

@Sylviabohnenstengel Sylviabohnenstengel left a comment

Choose a reason for hiding this comment

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

happy to approve subject to @JorgeBornemann review.

@Sylviabohnenstengel
Copy link
Contributor

Sylviabohnenstengel commented Jan 17, 2024

@JorgeBornemann I am holding off with the merge request until you had a chance to do the technical/portability review.
@jfrost-mo

@jfrost-mo jfrost-mo added the full_review Requires a technical, scientific, and portability review label Jan 18, 2024
Copy link
Collaborator

@JorgeBornemann JorgeBornemann left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. The changes look good, but I have not been able to test it fully, as I have been having troubles with my conda environments.
I have not seen in the changes anything that can prevent portability, and as this review is blocking other developments I am happy to approve and will create a separate issue to address portability problems that may surface.

.github/workflows/pr_ci.yml Outdated Show resolved Hide resolved
subprocess.run(("cset", "-v", "cookbook", cset_recipe), check=True)
else:
cset_recipe = Path("recipe.yaml")
cset_recipe.write_bytes(os.getenvb("CSET_RECIPE"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

In our installation getenvb causes a type error, at the end of the traceback, in _check_bytes (line 781 of os.py) bails with TypeError("bytes expected, not %s" % type(value).__name__)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably related to the problems with my conda environments, so feel free to ignore.

Copy link
Member Author

Choose a reason for hiding this comment

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

And here I was hoping that not having to deal with any encoding would be better for portability.

Re: conda environment issues, have you tried doing a fresh install? conda update does some funny things, and as we resolve from lock files it is more reliable to remove the conda environment and recreate it.

# Remove existing conda env
conda env remove -n cset-dev
# Create new one (from inside CSET directory)
conda create -n cset-dev --file requirements/locks/py312-lock-linux-64.txt

@jfrost-mo
Copy link
Member Author

Thanks for the review. I'll go ahead and merge it. Hopefully we can resolve your conda troubles and get it working again soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request full_review Requires a technical, scientific, and portability review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parameterise recipes and looping in include file level
3 participants