This repository houses pytests that are used as part CI checks for model configurations, as well as reusable components of model configuration CI.
The checksum pytests are used for reproducibility CI checks in this repository. The quick configuration tests are used in any repository that calls config-pr-1-ci.yml
or is templated by `ACCESS-NRI/model-configs-template. For example, ACCESS-NRI/access-om2-configs.
Code from these pytests is adapted from COSIMAS's ACCESS-OM2's bit reproducibility tests.
-
Load payu module - this provides the dependencies needed to run the model
module use /g/data/vk83/modules module load payu/1.1.4
-
Create and activate a python virtual environment for installing and running tests
python3 -m venv <path/to/test-venv> --system-site-packages source <path/to/test-venv>/bin/activate
-
Either pip install a released version of
model-config-tests
,pip install model-config-tests==0.0.1
Or to install
model-config-tests
in "editable" mode, first clone the repository, and then run pip install from the repository. This means any changes to the code are reflected in the installed package.git clone https://github.com/ACCESS-NRI/model-config-tests/ <path/to/model-config-tests> pip install -e <path/to/model-config-tests>
-
Checkout an experiment (in this case it is using an ACCESS-OM2 config)
git clone https://github.com/ACCESS-NRI/access-om2-configs/ <path/to/experiment> cd <path/to/experiment> git checkout <branch/tag>
-
Run the pytests
model-config-tests
-
Once done with testing, deactivate the virtual environment, and if the environment is no longer needed, remove the environment
deactivate rm -rf <path/to/test-venv> # Deletes the test environment
The output directory for pytests defaults to $TMPDIR/test-model-repro
and contains the following subdirectories:
control
- contains copies of the model configuration used for each experiment run in the tests.lab
- containspayu
model output directories containingwork
andarchive
sub-directories.
This output directory also contains files generated by pytests, including the checksum
directory which is used as part of reproducibility CI workflows.
To specify a different folder for pytest outputs, use --output-path
command flag, for example:
model-config-tests --output-path /some/other/path/for/output
By default, the control directory, e.g. the model configuration to test, is the current working directory. This can be set similarly to above by using the
--control-path
command flag.
The path containing the checksum file to check against can also be set using
--checksum-path
command flag. The default is the testing/checksum/historical-<default-model-runtime>hr-checksums.json
file which is stored in the control directory.
To run only CI reproducibility checksum tests, use -m checksum
, e.g.
model-config-tests -m checksum
To run quick configuration tests, use the config
marker. To additionally run
ACCESS-OM2 specific quick configuration tests, use access_om2
marker,
e.g.:
model-config-tests -m "config or access_om2"
The .github
directory contains many different workflows and actions. This section describes how they are used.
CI.yml
and CD.yml
are used to test, package and upload the model-config-tests
package that is used by model-configs
-style repositories across the ACCESS-NRI. These are the only workflows that run on this repository. The others are reusable workflows called by model-configs
-style repositories, among others.
The config-*.yml
, generate-checksums.yml
and test-repro.yml
workflows are called by model-configs
-style repositories to test model configurations. They are stored in this repository to allow a central place to update generic CI used by all model configuration repositories.
Currently, these repositories make use of the reusable CI:
- access-om2-configs
- access-esm1.5-configs
- access-esm1.6-configs
- access-om3-configs
- access-om3-wav-configs
Below is information on the use of these workflows.
The config-pr-*
Pipeline is a series of workflows that govern the testing, ChatOps and merging procedures of pull requests for model configuration repositories, such as ACCESS-NRI/access-om2-configs
.
Essentially, these files work on two types of configuration branch pull requests in the model configuration repository. More information on the terminology used in model configuration repositories can be found in the README.md
of the ACCESS-NRI/model-configs-template
repository. The types of pull requests are:
- Pull requests into
dev-*
: Allows quick checks of configuration metadata and common mistakes in configurations during PRs into thedev-*
configuration branches. - Pull requests from
dev-*
intorelease-*
: Allows both quick checks, as well as a longer, more comprehensive check on the reproducibility of the changes being brought into therelease-*
configuration branch, compared to the previousrelease-*
commit. It also acts on 'comment commands' run during the pull request, like!bump
for updating the version of the configuration (see the 'Config Tags' section in theACCESS-NRI/model-configs-template
repository for more). It is also responsible for the creation of the final config tag and release, once merged.
The config-schedule-*
Pipeline is a series of workflows used to check the reproducibility of certain config tags against themselves, every month. This is used as a kind of canary to make sure that we continue to get the same results on the same deployment targets.
This workflow is used to easily generate the checksums used in the reproducibility checks, for a specific branch of a model configuration repository, if they don't already exist. This is most often used for the initial commit of a checksum to the release-*
configuration branch.
This workflow is used to test the reproducibility of a given model repository against historical checksums, and can be used as a standalone workflow.
Using it has some requirements outside of just filling in the inputs: One must have a valid GitHub Environment (specified by the environment-name
input) in the calling repository, that has the following secrets
and vars
defined:
secrets.SSH_HOST
- hostname for the deployment targetsecrets.SSH_HOST_DATA
- hostname for the data mover on the deployment target (if it exists)secrets.SSH_KEY
- private key for access to the deployment targetsecrets.SSH_USER
- username for access to the deployment targetvars.EXPERIMENTS_LOCATION
- directory on the deployment target that will contain all the experiments used during testing of reproducibility across multiple runs of this workflow (ex./scratch/some/directory/experiments
)vars.MODULE_LOCATION
- directory on the deployment target that contains module files for payu used during reproducibility testing (ex./g/data/vk83/modules
)vars.PRERELEASE_MODULE_LOCATION
- directory on the deployment target that contains module files for development version of payu (ex./g/data/vk83/prerelease/modules
)
This comment command allows a repro check from any branch, rather than just the dev-*
-> release-*
PR pipeline.
It requires all the secrets
/vars
defined on the caller (as above), as well as vars.CONFIG_CI_SCHEMA_VERSION
.
Usage is as follows:
!test TYPE [commit]
Where TYPE
is a test suite that we support. Currently, this consists of repro
.
The commands are all case sensitive and require lower case.
Using commit
as an option will commit the result of the test to the PR, provided the commenter has at least write
permission, and the checksums differ.
!test repro
: will compare the HEAD
of the current PR source branch against the common ancestor on the target branch. For example, in the below diagram we would be comparing generated checksums in C
against checksums already stored at A
:
D (PR Target Branch)
|
| C (PR Source Branch)
| |
| B
|/
A (Common Ancestor)