Skip to content

Commit 14fa606

Browse files
authored
Merge pull request #229 from UCL/jupyter-cleanup
2 parents b9a8bb9 + 49fd09d commit 14fa606

File tree

163 files changed

+20326
-248460
lines changed

Some content is hidden

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

163 files changed

+20326
-248460
lines changed

.gitignore

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,32 @@ workflow/
77
vendor/
88
.sconsign.dblite
99
html/index.html
10-
pdf
10+
*pdf
1111
*.pyc
12+
*.ipynb
1213
*.nbconvert.ipynb
1314
*.swp
15+
*.html
16+
*.mp4
1417
a.out
18+
ch00*/learning_git
19+
ch00*/somefile.md
20+
ch01*/fourteen.py
21+
ch01*/draw*
22+
ch02*/my*
23+
ch02*/maze*
24+
ch02*/*csv
25+
ch02*/*png
26+
ch02*/greengraph
27+
ch03*/DiffusionExample
28+
ch03*/commands
29+
ch03*/diffusion
30+
ch03*/saskatchewan
31+
ch03*/solutions*
32+
ch04*/greetings*
33+
ch04*/maze*
34+
ch08*/*png
35+
ch98*/*png
1536
html/reveal/.DS_Store
1637
html/reveal/assets/night-ucl-overlay.css
1738
html/reveal/assets/solarized-ucl-overlay.css

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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ You are required to bring your own laptop to the course as the classrooms we are
2929

3030
# Contributing to this repository
3131

32-
This repository contains the course notes as jupyter notebooks. This makes it a bit difficult to contribute and to review contributions. Please, only include changes in the cells modified and not other metadata that changes when running them.
32+
This repository contains the course notes as Jupyter notebooks converted into `py:percent` format. This allows to edit the files as plain text as well as jupyter notebooks. To edit them as jupyter notebooks you'll need to have installed jupytext and open the `ipynb.py` files as notebooks via right-click and select "open with" and "notebook" on the Jupyter file browser.
3333

3434
⚠ Do not run `make` locally on your computer! ⚠
3535

@@ -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)