Binder is a really neat tool to put ipython
notebooks on the web so anyone else can see them and play with them. All you do
is put a link to a repository (most probably github but there are other
alternatives ...
However if you upload a code heavy ipython notebook you are greated by something
that looks like this: This isn't great for an interactive teaching environment,
so how do you hide the the python code but still retain it for those who are
curious. There are lots of
answers
and I tried a few before I found a reasonable result. So here is my best
solution, there is a notebooks extension called
appmode which works
really well as you can go from this
to this
however it requires some mucking about with your binder urls and converting to a
conda based code flow. So...
1. add an environment.yml to the root of your
github, it should contain trhe packages you use plus appmode, this will download
files from conda I have
1
2
3
4
5
6
7
8 | channels:
- conda-forge
dependencies:
- appmode
- numpy
- scipy
- ipywidgets
- matplotlib
|
2. Then change the format of your binder badge, I started with
1 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/varioustoxins/fft_demos/HEAD)
|
and had to alter it to
1 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/varioustoxins/fft_demos/HEAD?urlpath=apps%2Ffft_window.ipynb)
|
note how the end of the url becomes
HEAD?urlpath=apps%2Ffft_window.ipynb
rather than head
HEAD
and apps%2F is inserted between the urlpath= and the path to of your ipython notebook (fft_window.ipynb in my case)
Thats it, the
notebook I used this on
provides interactive NMR processing demos checkit out on
github. More of that another time when its finished...
No comments:
Post a Comment