Skip to content

Commit 4ec425c

Browse files
author
Lancelot the Brave
committed
Migrate from jupyter notebooks to py:percent format
1 parent 6ba71bc commit 4ec425c

File tree

161 files changed

+20300
-39147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+20300
-39147
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ ROOT=""
55
PANDOCARGS=-t revealjs -s -V theme=night --css=http://lab.hakim.se/reveal-js/css/theme/night.css \
66
--css=$(ROOT)/css/ucl_reveal.css --css=$(ROOT)/site-styles/reveal.css \
77
--default-image-extension=png --highlight-style=zenburn --mathjax -V revealjs-url=http://lab.hakim.se/reveal-js
8-
8+
PRENOTEBOOKS=$(wildcard ch*/*.ipynb.py)
9+
NOTEBOOKS_DONE=$(PRENOTEBOOKS:.ipynb.py=.ipynb)
910
NOTEBOOKS=$(filter-out %.v2.ipynb %.nbconvert.ipynb,$(sort $(wildcard ch*/*.ipynb)))
1011
SVGS=$(wildcard ch*/*.svg)
1112

12-
HTMLS=$(NOTEBOOKS:.ipynb=.html)
13+
HTMLS=$(PRENOTEBOOKS:.ipynb.py=.html)
1314

1415
EXECUTED=$(NOTEBOOKS:.ipynb=.nbconvert.ipynb)
1516
PNGS=$(SVGS:.svg=.png)
@@ -41,6 +42,9 @@ default: _site
4142
%.v2.ipynb: %.nbconvert.ipynb
4243
jupyter nbconvert --to notebook --nbformat 2 --stdout $< > $@
4344

45+
%.ipynb: %.ipynb.py
46+
jupytext --to ipynb $< -o - > $@
47+
4448
%.nbconvert.ipynb: %.ipynb
4549
jupyter nbconvert --to notebook --allow-errors --ExecutePreprocessor.timeout=120 --execute --stdout $< > $@
4650

@@ -72,10 +76,14 @@ _site: ready
7276
preview: ready
7377
jekyll serve --verbose
7478

79+
worked: $(NOTEBOOKS_DONE)
80+
find ./ -iname '*ipynb'
81+
7582
clean:
7683
rm -f ch*/generated/*.png
7784
rm -rf ch*/*.html
7885
rm -f ch*/*.pyc
86+
rm -f ch*/*.ipynb
7987
rm -f index.html
8088
rm -rf _site
8189
rm -rf images js css _includes _layouts favicon* master.zip indigo-jekyll-master

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,16 @@ $ docker run --rm --volume="$PWD:/srv/jekyll" --volume="$PWD/vendor/bundle:/usr/
7878

7979
and open http://localhost:4000/rsd-engineeringcourse (or the link provided).
8080
Note that this is mounting the `bundle` directory where `act` will create them.
81+
82+
# Migration from jupyter notebooks to py:percent
83+
84+
Using `jupytext` we've converted all the jupyter notebooks into plain text python files (py:percent) with:
85+
86+
```bash
87+
# First cleaned all outputs and commited it
88+
nbstripout --extra-keys metadata.kernelspec ch*/*ipynb
89+
# convert them
90+
find ./ -iname '*ipynb' -exec jupytext --opt notebook_metadata_filter="kernelspec,jupytext,jekyll" --to py:percent {} -o {}.py \;
91+
# then deleted the ipynb
92+
find ./ -iname '*ipynb' -delete
93+
```

0 commit comments

Comments
 (0)