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

Update and test example notebooks #6

Merged
merged 21 commits into from
Jun 22, 2022
Merged

Update and test example notebooks #6

merged 21 commits into from
Jun 22, 2022

Conversation

znicholls
Copy link
Collaborator

@znicholls znicholls commented Jun 9, 2022

Adds new example notebooks for all climate models we currently support and adds infrastructure for testing the notebooks. Note that this means we're effectively running the WG3 reproduction test twice. I would suggest removing that duplication in a follow up PR.

  • Tests added
  • Documentation added
  • Example added (in the documentation, to an existing notebook, or in a new notebook)
  • Description in CHANGELOG.rst added (single line such as: (`#XX <https://github.com/iiasa/climate-assessment/pull/XX>`_) Added feature which does something)

Depends on:

Supercedes #2

@znicholls znicholls mentioned this pull request Jun 9, 2022
5 tasks
@znicholls znicholls force-pushed the example-notebooks branch from 27a902c to 02e2775 Compare June 9, 2022 14:00
@znicholls znicholls marked this pull request as ready for review June 9, 2022 15:56
@znicholls znicholls requested a review from phackstock June 9, 2022 16:33
@znicholls znicholls force-pushed the example-notebooks branch from 8e7d45e to 9ff630c Compare June 9, 2022 16:36
@znicholls
Copy link
Collaborator Author

#8 to be addressed in future

@znicholls znicholls requested a review from jkikstra June 17, 2022 07:27
@znicholls
Copy link
Collaborator Author

@phackstock and @jkikstra any objections to merging?

@phackstock
Copy link
Contributor

I just took a quick look at the files changed and I was wondering why you we need .github/workflows/get-infiller-database.py. Is that not covered by the confest fixture version of downloading the required files?

@znicholls
Copy link
Collaborator Author

znicholls commented Jun 17, 2022 via email

@phackstock
Copy link
Contributor

@znicholls not sure I can follow your explanation. Would the purpose of this be that the users can run the tests locally? If so that mechanism already exists and is explained in the skip reason. In order to not skip the user simply need to download this file from the Scenario Explorer and place it in the correct folder.
The way that .github/workflows/get-infiller-database.py would currently work is that it would crash because the environment variables SCENARIO_EXPLORER_USER and SCENARIO_EXPLORER_PASSWORD would need to be set in order to enable the download.
In the conftest this is deliberately not the case as simply downloading the file and placing it in the correct spot causes the tests to be executed.
If you would really want to include get-infiller-database.py I think a better spot would be within the core package as .github/workflows should be reserved for yaml files that define workflows.

@znicholls
Copy link
Collaborator Author

@znicholls not sure I can follow your explanation

Oops, let me try again.

So, the overall idea is that we can run the notebooks as part of the CI routine. They test reproduction of what is in the WG3 database, but just in a way which is easier for new users, understand and explore.

In order to reproduce the WG3 database, we need to download the infiller database. So the question is, where to put that script? My thinking was:

  • in tests/conftest.py. This would be best, but I don't know if it is possible to force pytest to run a fixture before running the notebooks (I can't find a way to run a fixture standalone).
  • as a standalone script. This is what I've gone for given the issue with the above. I put it in the workflows folder to highlight that it's very specific for this workflow (i.e. only devs should be using it for this one application, it's not meant to be touched by others), but I'd be happy to move it. My suggestion would be to put it in tests/utils_scripts.
  • Put this function in src and support it (we could do this if we're happy to have failing tests if pyam ever changes its interface and I don't love the idea of supporting a bunch of download helpers as that's really outside the project's scope...)

Does that help?

@phackstock
Copy link
Contributor

@znicholls thanks for the explanation, now it get it.

Not sure I am the biggest fan though of using juptyer notebooks for this dual purpose.
I really like them for introducing users to the concepts of each model and how to run them. For this they're doing a great job here.
However, any changes to a notebook like this, who's primary purpose is playing around with and getting a feeling for the software package could break the tests.
Additionally, it the notebooks there are many things that are done for illustrative purposes like printing out intermediate results or plotting. To me a test should be as single focus as possible. In my opinion, any changes introduced to a test should only be done to fix a test in case any code changes deliberate broke it.
In short I would vote for keeping the tests as is, keeping the notebooks as is and reverting the github action workflows to the way they were before.
What do you think? Also @jkikstra what's your take on this?

@znicholls
Copy link
Collaborator Author

znicholls commented Jun 20, 2022 via email

@phackstock
Copy link
Contributor

@znicholls thanks for the detailed response. I see your points and I think we agree on all the important ones.
Illustration of how to replicate and customize running the climate assessment pipeline is important and as part of that testing that the results line up is important as well.
The only thing where I'm slightly hesitant about is having it as part of a GitHub action, although I agree that with your point that examples that we show must work and the best way of ensuring that is to test them directly and not build some type of mock-up and test that. So ultimately I'm with you on that as well.

The only thing I'd request as a change is to move the get_infiller_download_link function into the utils module. There should really only be GitHub action yaml files in the .github/workflows folder and this way the test can also import it from the utils so we have less code duplication.

@znicholls
Copy link
Collaborator Author

The only thing I'd request as a change is to move the get_infiller_download_link function into the utils module. There should really only be GitHub action yaml files in the .github/workflows folder and this way the test can also import it from the utils so we have less code duplication.

Ok will do (maybe tonight, maybe Thursday after scenario forum), thanks for the discussion!

@znicholls
Copy link
Collaborator Author

This will fail until pyam database is back up

@phackstock phackstock mentioned this pull request Jun 21, 2022
Copy link
Contributor

@phackstock phackstock left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for all the updates @znicholls.
Will merge as soon as the tests run through if that's ok with you.

@znicholls
Copy link
Collaborator Author

znicholls commented Jun 22, 2022 via email

@phackstock phackstock merged commit c6af289 into main Jun 22, 2022
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.

2 participants