CI updates/fixes, test updates#1495
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1495 +/- ##
========================================
Coverage 72.47% 72.48%
========================================
Files 250 250
Lines 54039 54039
========================================
+ Hits 39166 39170 +4
+ Misses 14873 14869 -4
|
4a0a89f to
c1eede5
Compare
|
What do the benchmark plot look like? |
|
@jdhughes-usgs it makes one like this for each benchmarked test full example here |
bef2328 to
2c54012
Compare
|
This is looking really nice, Wes. Is this ready to merge in? |
|
@langevin-usgs yes, I think it's ready. |
| uses: actions/cache@v3 | ||
| with: | ||
| path: $HOME/.local/bin | ||
| key: modflow-exes-${{ matrix.os }} |
There was a problem hiding this comment.
How will the cache be updated when there is a new release on the modflow-executables repo?
Here and elsewhere.
code.json in the zip files has the version numbers. We could add the code.json to the release and maybe that could be hashed so that the latest will always be used.
There was a problem hiding this comment.
Hashing code.json should work if it lives in the executables repo. Flopy CI would just need to check it out. The code.json file is currently only in the release archives though.
Another option is invalidating the cache via API per MODFLOW-ORG/executables#7.
The former would require changes to this PR, latter some changes to the executables repo PR.
There was a problem hiding this comment.
I was thinking of adding it as a release asset but could add it as a file to the repo. If it is a release asset, it could be pulled using the GitHub API before the MODFLOW executable step in the workflows. Adding it as a file in the repo would allow us to tag the commit and tie the release to the tag. I think we would have to make a new release after adding code.json to the repo to test this option.
There was a problem hiding this comment.
The release asset option might be simplest. I'll update this PR to look for code.json in the executables repo release assets & use its hash in the cache key if it finds one, otherwise just using modflow-exes-<system> as above. That should allow caching to work now as well as if/when we do include code.json as a release asset.
Marked as draft again, will re-mark for review when done.
There was a problem hiding this comment.
Added cache_exes composite action to .github/actions. This action packages the modflow exe install so workflows can all reuse it. The action checks the latest executables release for a code.json file, and if found, hashes it to determine if there's been a new release. (This file is not yet a release asset, and the cache won't be invalidated until it becomes one.)
The cache_exes action works on ubuntu and mac runners & there's a functionally identical Windows one
The cache_exes action is cross-platform and works on Windows, Linux and Mac runners.
A further option is to move the action to its own repository so modflow6 and other repos could use them.
75b9c53 to
bb8ae28
Compare
f65b4e7 to
3fa932d
Compare
1fdf021 to
8c97cc3
Compare
* fix ci.yml -> commit.yml * fix modflowpy#1491: workaround intermittent macos CI matplotlib failures * fix modflowpy#1479: sort in child's ctor instead of _ModpathSeries.get_data() * don't plt.show() in tests * add comments to conftest.py * give test_mt3d.py::test_mfnwt_CrnkNic more retries * skip ex-gwtgwt-mt3dms-p10 mf6 example (per MODFLOW-ORG/modflow6#1008) * rename release/ to scripts/ * move pull_request_prepare.py to scripts/ * add postprocess_benchmarks.py to scripts/ * separate CI workflows for benchmarks, examples and regression tests * name benchmark CI artifacts benchmarks-<system>-python version>-<run ID> * add CI job to post-process benchmarks (creates artifact benchmarks-<run ID>) * add cross-platform CI action to cache modflow exes & invalidate on new release * reenable PathlineFile.get_destination_pathline_data() benchmark * don't upload coverage after smoke tests, benchmarks, regression tests and example tests * upload coverage on PR as well as push (fix codecov bot comments) * decrease coverage precision to 1 decimal place (avoid small deltas) * update to codecov action v3
* fix ci.yml -> commit.yml * fix modflowpy#1491: workaround intermittent macos CI matplotlib failures * fix modflowpy#1479: sort in child's ctor instead of _ModpathSeries.get_data() * don't plt.show() in tests * add comments to conftest.py * give test_mt3d.py::test_mfnwt_CrnkNic more retries * skip ex-gwtgwt-mt3dms-p10 mf6 example (per MODFLOW-ORG/modflow6#1008) * rename release/ to scripts/ * move pull_request_prepare.py to scripts/ * add postprocess_benchmarks.py to scripts/ * separate CI workflows for benchmarks, examples and regression tests * name benchmark CI artifacts benchmarks-<system>-python version>-<run ID> * add CI job to post-process benchmarks (creates artifact benchmarks-<run ID>) * add cross-platform CI action to cache modflow exes & invalidate on new release * reenable PathlineFile.get_destination_pathline_data() benchmark * don't upload coverage after smoke tests, benchmarks, regression tests and example tests * upload coverage on PR as well as push (fix codecov bot comments) * decrease coverage precision to 1 decimal place (avoid small deltas) * update to codecov action v3
* fix ci.yml -> commit.yml * fix modflowpy#1491: workaround intermittent macos CI matplotlib failures * fix modflowpy#1479: sort in child's ctor instead of _ModpathSeries.get_data() * don't plt.show() in tests * add comments to conftest.py * give test_mt3d.py::test_mfnwt_CrnkNic more retries * skip ex-gwtgwt-mt3dms-p10 mf6 example (per MODFLOW-ORG/modflow6#1008) * rename release/ to scripts/ * move pull_request_prepare.py to scripts/ * add postprocess_benchmarks.py to scripts/ * separate CI workflows for benchmarks, examples and regression tests * name benchmark CI artifacts benchmarks-<system>-python version>-<run ID> * add CI job to post-process benchmarks (creates artifact benchmarks-<run ID>) * add cross-platform CI action to cache modflow exes & invalidate on new release * reenable PathlineFile.get_destination_pathline_data() benchmark * don't upload coverage after smoke tests, benchmarks, regression tests and example tests * upload coverage on PR as well as push (fix codecov bot comments) * decrease coverage precision to 1 decimal place (avoid small deltas) * update to codecov action v3
* fix ci.yml -> commit.yml * fix #1491: workaround intermittent macos CI matplotlib failures * fix #1479: sort in child's ctor instead of _ModpathSeries.get_data() * don't plt.show() in tests * add comments to conftest.py * give test_mt3d.py::test_mfnwt_CrnkNic more retries * skip ex-gwtgwt-mt3dms-p10 mf6 example (per MODFLOW-ORG/modflow6#1008) * rename release/ to scripts/ * move pull_request_prepare.py to scripts/ * add postprocess_benchmarks.py to scripts/ * separate CI workflows for benchmarks, examples and regression tests * name benchmark CI artifacts benchmarks-<system>-python version>-<run ID> * add CI job to post-process benchmarks (creates artifact benchmarks-<run ID>) * add cross-platform CI action to cache modflow exes & invalidate on new release * reenable PathlineFile.get_destination_pathline_data() benchmark * don't upload coverage after smoke tests, benchmarks, regression tests and example tests * upload coverage on PR as well as push (fix codecov bot comments) * decrease coverage precision to 1 decimal place (avoid small deltas) * update to codecov action v3
* fix ci.yml -> commit.yml * fix modflowpy#1491: workaround intermittent macos CI matplotlib failures * fix modflowpy#1479: sort in child's ctor instead of _ModpathSeries.get_data() * don't plt.show() in tests * add comments to conftest.py * give test_mt3d.py::test_mfnwt_CrnkNic more retries * skip ex-gwtgwt-mt3dms-p10 mf6 example (per MODFLOW-ORG/modflow6#1008) * rename release/ to scripts/ * move pull_request_prepare.py to scripts/ * add postprocess_benchmarks.py to scripts/ * separate CI workflows for benchmarks, examples and regression tests * name benchmark CI artifacts benchmarks-<system>-python version>-<run ID> * add CI job to post-process benchmarks (creates artifact benchmarks-<run ID>) * add cross-platform CI action to cache modflow exes & invalidate on new release * reenable PathlineFile.get_destination_pathline_data() benchmark * don't upload coverage after smoke tests, benchmarks, regression tests and example tests * upload coverage on PR as well as push (fix codecov bot comments) * decrease coverage precision to 1 decimal place (avoid small deltas) * update to codecov action v3

This PR:
ci.ymltocommit.ymlscriptsCodecov configuration
Uploads coverage reports on
pull_requestas well aspushevents to fix inaccurate codecov bot comments on PRs.Also:
flopymodule is)codecov-action@v3PathlineFileperformanceFix #1479 by sorting once in the ctor instead of each call to parent's
_ModpathSeriesmethodget_data()(occurs in a loop in_MoadpathSeries.get_destination_data()).Previous performance:
New benchmarks:
The operation completes in a fraction of the previous time. I don't think moving the
sort()will cause problems as_ModpathSeriesand children don't expose methods to update internal data after it's set in the constructor.CI updates
Moves benchmarking, example scripts & notebook tests, and regression tests into their own workflows to allow for independent testing and scheduling. (However all three still run on the same daily schedule as before).
Benchmarks
Previously benchmark comparisons (with
pytest --benchmark-compare) were failing due to an issue in the CI caching configuration. Now benchmarks are no longer saved in the cache, only as artifacts, and artifacts are postprocessed after benchmark jobs complete. The scriptscripts/process_benchmarks.pyaccepts 2 arguments, the input and output directory, and:--benchmark-autosaveor--benchmark-json=<file>, searching recursively in the input directoryFor instance, to look in the default benchmark save location
autotest/.benchmarksand save results in the same place:Individual artifacts are still saved for each combination of system and python version. An aggregate artifact is created by
process_benchmarks.pyin a job that runs after all benchmark jobs finish (example here).Macos/matplotlib errors
Tentatively fixes #1491 by using the non-interactive
aggmatplotlib backend on macos CI. Previously the macos backend was selected by default. This involves aFigureManager, which wraps a CocoaNSWindow. Maybe something in Cocoa doesn't like being invoked from multiple processes.Modflow exe caching
Cache modflow executables in commit-triggered and daily workflows with new composite action
.github/actions/cache_exes. This installs & caches modflow executables, checking the exe repo's latest release for acode.jsonasset and hashing its contents if found to determine whether to invalidate the cache. Required inputs are:path: the path to restore the cache togithub_token: the GitHub access token to authenticate API requestsLinux/MacOS
To cache Modflow executables in
.local/binin the runner's home directory, add a step like the following:Windows
An equivalent step for Windows:
The home directory path is explicitly provided here — although tilde expansion works in recent versions of Powershell, it does not seem to work on Windows runners.
Tests
ex-gwtgwt-mt3dms-p10mf6 example test (fix(gwtgwt): allow exchange to work without XT3D active for dispersion MODFLOW-ORG/modflow6#1008)test_mt3d.py::test_mfnwt_CrnkNicmore retries due to fortran errorsplt.show()usage intest_sfr.py(plot tests can check attributes ofax)conftest.pyandregression/conftest.pyPathlineFilesorts on initializationScripts
Rename
releasefolder toscripts, movepull_request_prepare.pyfromautotesttoscripts, and add new scripts for postprocessing benchmarks.