OverviewTeaching: 10 min
Exercises: 0 minQuestions
- How can I share notebooks with colleagues and the community?
- See what platforms and services exist to share Jupyter notebooks
- Have a final discussion on notebooks in research.
nbviewerand view a rendered Jupyter notebook
jupyter nbconverttool can convert a (
.ipynb) notebook file to:
Note: the Google, Microsoft and CoCalc platforms are free but have paid subscriptions for faster access to cloud resources
Exercise: Making your notebooks reproducible by anyone via Binder
- Create a
requirements.txtfile in your notebook repository, e.g.:
ipywidgets==7.4.2 numpy==1.16.4 matplotlib==3.1.0
- Commit and push.
- Visit https://mybinder.org, and paste in the URL of your notebook repository.
- Click on the arrow next to the “Copy the text below …” to expand it.
- Copy the markdown line which begins with
[![Binder](https://mybinder.org/badge_logo.svg)], and paste it into a README.md file for your notebook repository. Commit and push it.
- Check that your notebook repository now has a “launch binder” button in your README file on GitHub
- Try clicking the button and see how your repository in launched on Binder. Your notebooks can now be expored and executed in the cloud.
- Enjoy being fully reproducible!
- As a side note you can also run RStudio directly on Binder (example).
(Optional) Exercise: what happens without requirements.txt?
- Start the repository in Binder
fig3/fig3bc.ipynbis a Python notebook, so works in Binder. Most others are in R, which also works in Binder. But how? Try to run the notebook - can you make it work?
- Install the missing requirements with
pip. Does it work now? Why or why not?
- How would this be better?
You can do that using Markdown. This produces a nice overview for longer notebooks. Example: https://stackoverflow.com/a/39817243
It is possible to hide all the code and only show the output. This can be nice for notebook readers who don’t need/want to see the code:
But Notebooks have some pitfalls: