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 loading and running recipes to the notebook API #907

Merged
merged 48 commits into from
Jan 21, 2021
Merged

Conversation

stefsmeets
Copy link
Contributor

@stefsmeets stefsmeets commented Dec 17, 2020

Hi everyone, this PR implements an api to load and run recipes in an interactive jupyter notebook.

This PR is mostly complete in terms of what it is supposed to do. The thing that is missing is to have good test. I'm thinking we should have some very basic test recipes that we can run to test the API.

Also implements bugfix that closes #953

To do

Tasks

  • Create an issue to discuss what you are going to do, if you haven't done so already (and add the link at the bottom)
  • This pull request has a descriptive title that can be used in a changelog
  • Add unit tests
  • Public functions should have a numpy-style docstring so they appear properly in the API documentation. For all other functions a one line docstring is sufficient.
  • Circle/CI tests pass. Status can be seen below your pull request. If the tests are failing, click the link to find out why.
  • Codacy code quality checks pass. Status can be seen below your pull request. If there is an error, click the link to find out why. If you suspect Codacy may be wrong, please ask by commenting.

If you need help with any of the tasks above, please do not hesitate to ask by commenting in the issue or pull request.


Follows up on #901 and #868
For more discussion, see issue #498
Documentation: https://esmvaltool--907.org.readthedocs.build/projects/ESMValCore/en/907/api/esmvalcore.api.html
Demo notebook: https://gist.github.com/stefsmeets/1163eeea765906550f772c15b69e866e

@stefsmeets stefsmeets changed the title Api run recipe2 Add loading and running recipes to the notebook API Dec 17, 2020
@stefsmeets stefsmeets self-assigned this Jan 6, 2021
@stefsmeets
Copy link
Contributor Author

Hi @nielsdrost and @Peter9192 , this PR is ready for review. Could you have a look?

There is still a small issue with the tests on CircleCI that I will have a look at, but I think other than that the PR can be reviewed. The tests are running fine locally.

@stefsmeets stefsmeets marked this pull request as ready for review January 7, 2021 10:20
@stefsmeets
Copy link
Contributor Author

This test fail seems to be completely random on CircleCI (sometime it passes, sometimes it fails), unrelated to any changed made in this PR, and I cannot reproduce it on my own machine.

self = <tests.unit.preprocessor._regrid.test_regrid.Test testMethod=test_regrid__cell_specification>

    def test_regrid__cell_specification(self):
        specs = ['1x1', '2x2', '3x3', '4x4', '5x5']
        scheme = 'linear'
        for spec in specs:
            result = regrid(self.src_cube, spec, scheme)
            self.assertEqual(result, self.regridded_cube)
>           self._check(spec, scheme, spec=True)

tests/unit/preprocessor/_regrid/test_regrid.py:107: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/unit/preprocessor/_regrid/test_regrid.py:23: in _check
    self.assertEqual(_CACHE[spec], self.tgt_grid)
E   AssertionError: <iris 'Cube' of unknown / (unknown) (latitude: 180; longitude: 360)> != <Mock spec='Cube' id='140365561280592'>

Copy link
Member

@bouweandela bouweandela left a comment

Choose a reason for hiding this comment

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

Code looks good, though I did not try using it.

Could you have a look at the question about representing CheckLevels in a YAML file? I think this should not be needed, because CheckLevels should not leak to the diagnostic script through the YAML interface, this is supposed to be used by the CMOR checker and nothing else.

Would it be possible to solve the import outside toplevel Codacy issue?

stefsmeets and others added 2 commits January 18, 2021 14:00
Co-authored-by: Bouwe Andela <b.andela@esciencecenter.nl>
Co-authored-by: Bouwe Andela <b.andela@esciencecenter.nl>
@stefsmeets
Copy link
Contributor Author

Would it be possible to solve the import outside toplevel Codacy issue?

Yeah, it can be solved, but I think it is clearer where it is now.

@bouweandela
Copy link
Member

Yeah, it can be solved, but I think it is clearer where it is now.

If would be great if you could follow the style guide if there is no technical reason for deviating from it. If everyone starts making up their own style the code will become harder to read for everyone.

@stefsmeets
Copy link
Contributor Author

Yeah, it can be solved, but I think it is clearer where it is now.

If would be great if you could follow the style guide if there is no technical reason for deviating from it. If everyone starts making up their own style the code will become harder to read for everyone.

I don't consider this error be a 'hard' fail from Codacy, sometimes the code reads much better if the import is not at the top of the file. Besides that, Codacy and yapf sometimes conflict as well, so it is unclear what style to use.

@stefsmeets
Copy link
Contributor Author

stefsmeets commented Jan 19, 2021

@bouweandela This PR is ready to be merged. I worked around the test failure by clearing the cache before the regrid tests, but a better implementation is needed. For more info see #953.

@stefsmeets
Copy link
Contributor Author

stefsmeets commented Jan 20, 2021

Shoot, now I merged the wrong branch here...

Merge branch 'api_run_output' into api_run_recipe2 🤐

EDIT: all good!

Copy link
Member

@nielsdrost nielsdrost left a comment

Choose a reason for hiding this comment

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

Did a scan of the code (especially changes outside of experimental). Looks good to me.

@nielsdrost nielsdrost dismissed bouweandela’s stale review January 21, 2021 09:43

Changes implemented as requested.

@nielsdrost nielsdrost merged commit a285ee6 into master Jan 21, 2021
@nielsdrost nielsdrost deleted the api_run_recipe2 branch January 21, 2021 09:44
@jvegreg jvegreg added the api Notebook API label Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Notebook API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ambiguous cache retrieval in regrid preprocessor
5 participants