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 inferring metrics notebook #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

miniufo
Copy link

@miniufo miniufo commented Jan 11, 2021

Hi @jbusecke, I am now sending the inferring metrics notebook in this PR. If this is OK, I'll close xgcm/xgcm#196.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jbusecke
Copy link
Collaborator

jbusecke commented Jan 12, 2021

Thank you very much for migrating this. The tests are failing, because the data you are using is not stored in the repository itself anymore. I uploaded it to zenodo. You can simply copy the code to load it from there into the notebook:

# download the data
import urllib.request
import shutil

url = 'https://zenodo.org/record/4421428/files/'
file_name = 'mitgcm_example_dataset_v2.nc'
with urllib.request.urlopen(url + file_name) as response, open(file_name, 'wb') as out_file:
    shutil.copyfileobj(response, out_file)
    
# open the data
ds = xr.open_dataset(file_name)
ds

It should be pretty much the same as in 02_mitgcm.ipynb. Once the CI is fixed I will give it another good read, and then we can merge this. This will be a great addition!

@miniufo
Copy link
Author

miniufo commented Jan 13, 2021

I think I am getting used to this work flow. After I change the file from zenodo, checks still failed. But this time it is on purpose so that one can see where the error was thrown if the metrics are not provided correctly. So how to resolve this? @jbusecke

@jbusecke
Copy link
Collaborator

I see. That is a very good question indeed.

Looping in @rabernat here. @miniufo has created this nice notebook, which illustrates some examples that produce failing cells (something that I also often do), but since these cells prevent the notebook to be executed in one go, binderbot is failing. Do you have a recommended workaround for this?

My only idea would be to wrap both the code and the error in Markdown and make them 'non-interactive' but maybe there is a better way?

@miniufo
Copy link
Author

miniufo commented Jan 25, 2021

I guess we don't have any better way right now? So I'll wrap them in Markdown. If there is a better way, I may send another commit.

@rabernat
Copy link

Do you have a recommended workaround for this?

Yes! You use the expectexception package, as in this notebook:

https://github.com/xarray-contrib/xarray-tutorial/blob/master/scipy-tutorial/03_computation_with_xarray.ipynb

@miniufo
Copy link
Author

miniufo commented Jan 26, 2021

I tried this package, installed it, and typed the example. But I cannot get any difference with or without the magic.
image

@jbusecke
Copy link
Collaborator

Hi @miniufo thanks for persisting on this. From what I understand you shouldnt see any difference, except that you should be able to have a code cell underneath the failing one, and would still be able to run the full notebook. I think this magic basically just prevents the notebook execution from stopping when it hits an error.

Can you try to put %%expectexception ... in all the failing cells and those changes to the branch? We might have to add the package to the binder environment but lets try this first.

@jbusecke
Copy link
Collaborator

Ok as suspected we need to provide the module to the binder environment. Let me check how to do that...
@rabernat quick question: This has so far been working with the pangeo-gallery/default-binder, but we need to add a custom package. Do you recommend to make a whole new repo for that (seems excessive), or is there a way to use the xgcm environments? Or provide the environment in this repo?

Just trying to figure out what the least messy way to do this is.

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.

3 participants