Add YAML linting and improve setup script#80
Conversation
| @@ -1,5 +1,7 @@ | |||
| # This is the base EAGLE config. It currently configures the Nested EAGLE case. | |||
|
|
|||
| # yamllint disable rule:anchors rule:line-length | |||
There was a problem hiding this comment.
When final configs are created by composing multiple YAML files together, it may be that one config contains a YAML alias for which no corresponding anchor is apparently available -- but it will be available after composition.
EAGLE YAML configs may also have long lines.
| @(set -x && shellcheck --format=gcc --severity=info --shell=bash $(BASHSRCS)) | ||
|
|
||
| test: lint shellcheck typecheck | ||
| test: lint shellcheck typecheck yamllint |
There was a problem hiding this comment.
make test will now also run make yamllint, though the latter can also be requested independently.
src/setup
Outdated
| # invoking make targets requires make itself; and driver execution and config management require | ||
| # uwtools, so install those. | ||
| conda create -y -q -c ufs-community -n $* jq $MAKE $UWTOOLS | ||
| conda create -y -q -c ufs-community -n $* $UWTOOLS |
There was a problem hiding this comment.
Only the base environment needs jq, and make needs to be available outside the conda installation, as it is used to create the conda installation. A note has been added to the README.md about the make requirement. This should be present, or easily made available, on just about any system.
| $UWTOOLS | ||
| yamllint=1.38.* | ||
| ) | ||
| test -v EAGLE_DEV && pkgs+=( $(devpkgs) ) |
There was a problem hiding this comment.
By conditionally appending the development packages to the list of packages to install, a single conda create or conda install command can be performed instead of two.
| if conda_env_exists $name; then | ||
| conda_install ${args[@]} | ||
| else | ||
| conda_create ${args[@]} |
There was a problem hiding this comment.
Given this logic, if e.g. make env ... is run once to create a non-dev environment, make devenv ... can later be run and conda (and pip) will find almost all required packages already installed, and will only need to install the missing dev packages. Or, a user could change version numbers here for experimental reasons, re-run make env, and update the existing conda environments without deleting them or the conda installation itself. This could be a big time saver.
| yamllint: | ||
| $(call activate,base) | ||
| @echo "=> Linting YAML configs" | ||
| @(set -x && yamllint --no-warnings config/) | ||
|
|
There was a problem hiding this comment.
each recipe line runs in a separate shell. conda activate base line won’t affect the later yamllint. meaning yamllint will run in whatever environment Make happens to have.
possible suggestion
yamllint:
@echo "=> Linting YAML configs"
$(call activate,base) && (set -x && yamllint --no-warnings config/)
There was a problem hiding this comment.
The .ONESHELL: directive higher in the Makefile ensures that all recipe lines run in the same shell.
| python=3.13 | ||
| xesmf=0.8.* |
There was a problem hiding this comment.
Note: may be fine on Ursa if you’ve validated solver availability, but python 3.13 + compiled geo stack (ESMF / esmpy / xesmf) is a common point of failure on HPC channels.
There was a problem hiding this comment.
I haven't seen issues yet, but thanks for the heads-up.
src/setup
Outdated
| # invoking make targets requires make itself; and driver execution and config management require | ||
| # uwtools, so install those. | ||
| conda create -y -q -c ufs-community -n $* jq $MAKE $UWTOOLS | ||
| conda create -y -q -c ufs-community -n $* $UWTOOLS |
There was a problem hiding this comment.
conda_create to use -n "$name" with shift ?
There was a problem hiding this comment.
Good idea, I think that would be clearer. I'll update and test. Thanks!
src/setup
Outdated
| # shellcheck disable=1090,1091,2046,2048,2068,2086,2206,2155 | ||
| # shellcheck disable=1090,1091,2046,2048,2068,2086,2206,2207 | ||
|
|
||
| set -aeu |
There was a problem hiding this comment.
do we really need -a?
prefer set -euo pipefail
There was a problem hiding this comment.
Yes, -a ensures that the functions defined at the top level are available in subshells.
I'll test with -o pipefail and either add it or address any issues. I remember having problems with it in ternary expressions like stmt && then || else, but maybe it doesn't matter here.
| ) | ||
| } | ||
|
|
||
| parse_kvargs $@ |
There was a problem hiding this comment.
parse_kvargs should use "$@"?? (both in the call and in the loop).
There was a problem hiding this comment.
In the general case I agree, because the individual arguments in $@ could in theory contain spaces. But the only arguments allowed here are of the form key=value, with no spaces. In my opinion, having "$@" suggests to readers that we think that there might be spaces, which isn't true. I think using syntax choices to communicate intent is useful and so am reluctant to add more syntax where it isn't needed.
But I might be missing something -- please let me know if so!
There was a problem hiding this comment.
Its fine - will see if any issues later.
Description:
Fixes #78 by adding
yamllintto thebaseconda environment, adding amake yamllinttarget, incorporating that target into thetesttarget, and documenting this in theREADME.md.Also, improve the
setupscript by installing both run and dev packages in a single command to reduce the amount of time spent by conda in resolving package sets; and make it easy to install dev packages on top of a non-dev set of environments, or to change package versions, without removing conda or its environments.Type of change:
Area(s) affected
uwtools-based software environment andMakefiletargets undersrc/Commit Requirements:
Testing / Verification:
I ran the Quickstart routine from the README.md.
Runtime Environment:
As specified in the
README.mdQuickstart, on Ursa.