CALIPSO-project / SPINacc

A spinup acceleration procedure for land surface models (LSM)
4 stars 0 forks source link

Rewrite tests to make use of `pytest` #45

Open tztsai opened 1 month ago

tztsai commented 1 month ago

This PR rewrites the testing approach in SPINacc. Previously, tests were written to execute at the end of a run. There are two problems:

Instead, this PR introduces pytest, which allows users to run tests after a step of the pipeline has completed. To utilise pytest all previous tests have been renamed to test_task*.py and all functions now have a test prefix.

To summarise:

Execution

To run the tests, use the command pytest tests/.

Automatic testing

The tests rely on a job being completed before execution as output data needs to be there for a comparison to happen. For automated testing (regression), this presents a problem. We have therefore shown how it may be possible to use github actions to run the job in advance and then execute a single test.

The automated job needs the following data to execute a test.

The zenodo data is approximately 1.1GB. We cannot run SPINacc from scratch because the data dependencies are just too large. This is explained more here

Testing is steered using a .github actions file. .github/workflows/python.yml, and assumes that the initialisation step has already been executed. Therefore auxil.npy and packdata.npy are already there.

It does the following:

Outstanding issues

In order to merge the following issues should be addressed:

Closes #37 and #40.

ma595 commented 1 month ago

All tests pass locally for me, except for step 3 which we don't care about at the moment.

TomMelt commented 2 weeks ago

Discussed idea of generating idealized test case for integration test. Not necessarily physically meaningful but something that uses the code in a realistic manner.

@dsgoll123 will make a new small training set for new version ORCHIDEE