Skip to content

[WIP] Python testing framework and workflow - #45

Draft
ma595 wants to merge 7 commits into
fluxnet:mainfrom
Cambridge-ICCS:tests_framework
Draft

[WIP] Python testing framework and workflow#45
ma595 wants to merge 7 commits into
fluxnet:mainfrom
Cambridge-ICCS:tests_framework

Conversation

@ma595

@ma595 ma595 commented Jan 31, 2023

Copy link
Copy Markdown

Add python testing framework and github actions workflow for automated testing. The PR downloads US-ARc_sample* data and sets up the nighttime partitioning step. The test runs in a few seconds and the generated output (*.csv files) are compared for equality against reference output.

The nighttime partitioning step was chosen as an integration test as it runs much faster than other steps in the ONEFlux pipeline (i.e. daytime partitioning). Python unit tests will be implemented in a later PR.

TODOs:

  • Python function to copy data is unused
  • Test doesn't pass - Can provide notebook illustrating issue.
  • Apply style
  • Edit commit messages
  • Update workflow - python 2.7.18 is no longer supported by Github.
  • Rebase PR
  • check numerical precision of comparison - load csvs as dataframes - use np.isclose() fn. Number of columns and specific values of certain columns do not agree..
  • convert pre-existing unittest test tests/test_context.py to use pytest.
  • delete pre-existing unittest boilerplate and replace with pytest.
  • partitioning_nt integration test tests/python/integration/test_partitioning.py
  • workflow to deploy ONEFlux, pull relevant data for test, copy required input from expected output of US-ARc_sample* and execute integration test. .github/workflows/python-app.yaml

Fixes #46

@ma595
ma595 marked this pull request as draft January 31, 2023 18:34
@ma595 ma595 self-assigned this Jan 31, 2023
@ma595 ma595 changed the title Tests framework Testing framework Feb 2, 2023
@ma595 ma595 changed the title Testing framework Python testing framework Mar 2, 2023
@ma595 ma595 changed the title Python testing framework Python testing framework and workflow Mar 2, 2023
@ma595 ma595 mentioned this pull request Mar 15, 2023
6 tasks
@ma595
ma595 marked this pull request as ready for review April 4, 2023 09:54
@ma595
ma595 requested review from gilbertozp and removed request for gilbertozp April 4, 2023 09:54
@ma595
ma595 marked this pull request as draft April 4, 2023 11:16
@ma595

ma595 commented Apr 4, 2023

Copy link
Copy Markdown
Author

Coming back to this PR I am now noticing a number of differences between the 'new' computed output and the reference output. On the nee_y_1.25_US-ARc_2005.csv file, for instance, there are 48 columns in the generated file vs the expected 45. The additional columns are gpp_2_nongf, gpp_2rob_nongf and gpp_2e_nongf.

Eliminating these from the output and comparing floating points, most values agree except 3 or 4 columns including gpp_2rob. @gilbertozp could you check that I'm executing the test_partitioning_nt test correctly within the test_partitioning.py file ? I'll continue to investigate...

@ma595

ma595 commented Apr 13, 2023

Copy link
Copy Markdown
Author

Following up on this, I notice differences between reference US-ARc_sample_output and computed output on the following columns: rrefoptord_se, rrefopttrim_se, gpp_2, gpp_2rob, gpp_2e, and ls_status in the nee_y_1.25_US-ARc_2005.csv file. Any ideas @gilbertozp ?

I assume some steps are not deterministic, so should I ignore certain output columns?

@dorchard

dorchard commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

@gilbertozp is this blocked on the comment above from Matt? Or can this be merged?

@dorchard

Copy link
Copy Markdown
Contributor

@gilbertozp is taking a look at this

@ma595 ma595 changed the title Python testing framework and workflow [WIP] Python testing framework and workflow Oct 17, 2024
@ma595

ma595 commented Oct 17, 2024

Copy link
Copy Markdown
Author

A few notes after revisiting this. @gilbertozp has the reference dataset been updated since we last looked at this?

PY differences compared to the provided reference for the 1.25 quantile.
There are 74 rows and 6 columns. For each column the discrepancies are as follows:

Column type: (int, float, float, float, int, string)
Discrepancies (rtol = 1e-4): (0, 28, 0, 0, 18, 0)

Where 'discrepancies' refers to the number of mismatches between the reference and computed output.

This does not seem to be stochastic (repeated runs give the same number of discrepancies). I use the reference 08, 07, and 02 as inputs.

I can provide the jupyter notebook I used to do this analysis if that would help?

@ma595
ma595 force-pushed the tests_framework branch 2 times, most recently from 4b2d6ae to a98c3e4 Compare October 18, 2024 10:40
Comment thread oneflux_steps/Makefile
The -a flag causes the build to break on HPC systems.
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.

Python testing with pytest

3 participants