Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Psyplot diagnostic #2653

Merged
merged 8 commits into from
May 16, 2022
Merged

Add new Psyplot diagnostic #2653

merged 8 commits into from
May 16, 2022

Conversation

schlunma
Copy link
Contributor

@schlunma schlunma commented May 16, 2022

Description

This PR adds a recipe and diagnostic that provides a high-level interface for the Psyplot package. This package can produce a large variety of plots, e.g., plot unstructured UGRID and ICON data:

CMIP6_ICON-ESM-LR_Amon_historical_r1i1p1f1_tas_gn_1995-2014

Links to documentation:

@lukruh Would you be able to briefly test this recipe and approve the changes if you like them? I think this diagnostic might be especially interesting to you since it allows plotting arbitrary ICON output on the native grid. Maybe you could even try to plot native ICON output with it? Cheers!


Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.

New or updated recipe/diagnostic


To help with the number of pull requests:

@schlunma schlunma added this to the v2.6.0 milestone May 16, 2022
@schlunma schlunma self-assigned this May 16, 2022
@@ -1,8 +0,0 @@
Diagnostic scripts
Copy link
Contributor Author

@schlunma schlunma May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I removed this page since it contains no useful information. In the current doc it looks like this:

grafik

Copy link
Contributor

@valeriupredoi valeriupredoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one, Manu! I am guessing this has nothing to do with PSY eh? 😁 - two minor comments from me, and a quick request to turn on then off one of the Test Github Actions to see if all's good with the env after adding those psy packages 👍

doc/sphinx/source/conf.py Show resolved Hide resolved
esmvaltool/diag_scripts/psyplot_diag.py Outdated Show resolved Hide resolved
@valeriupredoi
Copy link
Contributor

ah also - would this not make for a nice preprocessor? Not now - when we'll have plotting preprocessors - but just to keep it in mind, that is

@schlunma
Copy link
Contributor Author

ah also - would this not make for a nice preprocessor? Not now - when we'll have plotting preprocessors - but just to keep it in mind, that is

ah also - would this not make for a nice preprocessor? Not now - when we'll have plotting preprocessors - but just to keep it in mind, that is

Definitely!! Plotting preprocessors is actually something we should discuss at the workshop as part of the long-term strategy 👍

@schlunma
Copy link
Contributor Author

All GH action tests ran successful 🎉

@schlunma
Copy link
Contributor Author

Thanks for the reviews @valeriupredoi @lukruh 🚀

@schlunma schlunma merged commit 43a3c7e into main May 16, 2022
@schlunma schlunma deleted the psyplot_diag branch May 16, 2022 13:25
@zklaus
Copy link

zklaus commented May 17, 2022

The test introduced in this PR produced an error in the nightly tests (see here). The problem seems to be a race condition where the package finds that it has no config file and tries to create that, but two processes try that at the same time and then can interfere. Upstream may be unwilling to address this because it is not likely a real life problem; we might mitigate it by creating the config before running the test.

@schlunma
Copy link
Contributor Author

I didn't add a test in this PR...

I'm not really sure which test actually fails, the error message just says ERROR collecting esmvaltool/diag_scripts/psyplot_diag.py. Do we have a test that just imports diagnostics and checks if that works?

@zklaus
Copy link

zklaus commented May 17, 2022

Hm. Good point. I didn't read the message carefully enough. @bouweandela, @valeriupredoi any ideas?

@valeriupredoi
Copy link
Contributor

having a looksee at this right now, I smell gagnam-style coding on the part of Psy

@zklaus
Copy link

zklaus commented May 17, 2022

I don't think the psyplot code is very bad. As @schlunma pointed out, it looks like pytest is searching for tests also in esmvaltool, even though we have separated them out in tests. This may be relevant.

@valeriupredoi
Copy link
Contributor

Do we have a test that just imports diagnostics and checks if that works?

pytest does that - checks all imports in all recognized python scripts - it's actually a very useful feature since sometimes one doesn't have tests per se, but can just run a pytest instance in the CI to check if all imports work

@valeriupredoi
Copy link
Contributor

I don't think the psyplot code is very bad. As @schlunma pointed out, it looks like pytest is searching for tests also in esmvaltool, even though we have separated them out in tests. This may be relevant.

ah yeah, was just saying in my previous comment 😁

@zklaus
Copy link

zklaus commented May 17, 2022

I don't think we should abuse Pytest's discovery logic as a poor man's import test.

@schlunma
Copy link
Contributor Author

So how can we solve this? Adding a conftest.py file as suggeted here?

@bouweandela
Copy link
Member

@zklaus We use pytest to run flake8 and doctests, that's the kind of tests it will find in the esmvaltool directory.

@valeriupredoi
Copy link
Contributor

the problem is I can not manage to reproduce the fail on Linux under any circumstance: running five instance of a pytest (that only imports that module) in parallel with ./parallel_commands "pytest tests/unit/test_psy.py" "pytest tests/unit/test_psy_2.py" "pytest tests/unit/test_psy_2.py" "pytest tests/unit/test_psy.py" "pytest tests/unit/test_psy.py" where that parallel_commands actually runs each of the scripts on a separate thread, running with pytest -n 8 tests/unit/test_psy.py tests/unit/test_psy_2.py as well (many times too, gather some statistic) - can't hit that race issue even if you ask me to! OSX issue if you asked me

@bouweandela
Copy link
Member

The problem seems to be a race condition where the package finds that it has no config file and tries to create that, but two processes try that at the same time and then can interfere. Upstream may be unwilling to address this because it is not likely a real life problem; we might mitigate it by creating the config before running the test.

It should be possible to use a library from different programs simultaneously. I would suggest reporting the issue and if the authors are indeed not interested in getting itt fixed we can think about workarounds.

@valeriupredoi
Copy link
Contributor

I agree with Bouwe - I am trying to see if it's an OSX specific issue now, so we can noarrow down the parameter space for the Psy devvs, a bit hard coz it's like fishing on a frozen lake, not having a Mac myself

@zklaus
Copy link

zklaus commented May 17, 2022

Alright, sounds good. In the meantime, we just accept the occasional red cross on osx?

@valeriupredoi
Copy link
Contributor

yeah we can change the sticker on the main README to point only to the Linux tests I think, so we save face for new users 😁

@valeriupredoi
Copy link
Contributor

OK I managed to force the race condition to come from an actual test https://github.com/ESMValGroup/ESMValTool/runs/6470528634?check_suite_focus=true - again on OSX only, and it clearly is a race condition, probably due to how slow the execution is on Darwin machines on GA. Here is a suggestion for the Psy guys https://stackoverflow.com/questions/1586648/race-condition-creating-folder-in-python - @schlunma you wanna do the nonors to open an issue on the Psy GH? 🍺

@schlunma
Copy link
Contributor Author

See psyplot/psyplot#52

@schlunma
Copy link
Contributor Author

I already got an answer to the issue with a PR and was asked to check if that fix solves our problem. Any suggestions on how to do that? I also don't own a Mac, and as far as I can tell this only happens on OSX 😅

psyplot/psyplot#53

@zklaus
Copy link

zklaus commented May 18, 2022

@valeriupredoi, did you have a reproducible way to trigger the error? Otherwise I would say that the fix looks appropriate and explain that we have the issue only in a race condition that occurs rarely and that we'll get back if it doesn't solve the problem.

@valeriupredoi
Copy link
Contributor

@zklaus not an 100% reproducible case, it looks to be 1 out of 6 or 9 times reproducible, so it's best to go the way you suggest 👍

@valeriupredoi
Copy link
Contributor

BTW the psy thingie failed for Linux too - so it's not just OSX - it's a stock race condition, that happens everytime a magpie craps on a BMW 🐦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants