Skip to content

Commit

Permalink
Merge pull request #253 from UCL/saransh/jupyterlite
Browse files Browse the repository at this point in the history
feat: JupyterLite integration
  • Loading branch information
dpshelio authored Sep 11, 2024
2 parents 8361974 + 89435d5 commit c9ab2db
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build_site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ jobs:
bundle install
- name: Build website
run: bundle exec jekyll build
- name: Build the JupyterLite site
run: |
find . -type d -name .pytest_cache -o -name .ruff_cache -o -name .doctrees | xargs rm -rf
mkdir contents
mkdir _site/jupyter-lite
find ch*/ -type f -name '*.ipynb' ! -name '*.nbconvert.ipynb' -exec rsync -R {} contents/ \;
jupyter lite build --contents contents --output-dir _site/jupyter-lite
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ session04/greetings/scripts/
Gemfile.lock
.env/
polynomials.svg
contents/
.jupyterlite.doit.db
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ clean:
rm -f ch07dry/datasource*.yaml
rm -f ch07dry/example.yaml
rm -f notebooks.zip
rm -rf contents
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ exclude:
- "*/*.v2.ipynb"
- "combined_files"
- "combined.ipynb"
- jupyter-lite

keep_files:
- jupyter-lite
5 changes: 5 additions & 0 deletions ch00git/01Intro.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
# %% [markdown]
# Commands you can type will look like this, using the %%bash "magic" for the notebook.

# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook


# %% attributes={"classes": [" Bash"], "id": ""} jupyter={"outputs_hidden": false} language="bash"
# echo some output

Expand Down
5 changes: 5 additions & 0 deletions ch00git/02Solo.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# %% [markdown]
# ## Solo work with Git

# %% [markdown]
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook

# %% [markdown]
# So, we're in our git working directory:

Expand Down
5 changes: 5 additions & 0 deletions ch00git/03Mistakes.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# %% [markdown]
# ## Fixing mistakes

# %% [markdown]
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook

# %% [markdown]
# We're still in our git working directory:

Expand Down
5 changes: 5 additions & 0 deletions ch00git/04Publishing.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# %% [markdown]
# ## Publishing

# %% [markdown]
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook

# %% [markdown]
# We're still in our working directory:

Expand Down
7 changes: 6 additions & 1 deletion ch00git/05Collaboration.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@

# %% [markdown]
# ## Collaboration
#

# %% [markdown]
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook
#
# ### Form a team

# %% [markdown]
Expand Down
6 changes: 5 additions & 1 deletion ch00git/10Branches.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

# %% [markdown]
# ## Branches
#
#
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook
#
# Branches are incredibly important to why `git` is cool and powerful.
#
# They are an easy and cheap way of making a second version of your software, which you work on in parallel,
Expand Down
5 changes: 5 additions & 0 deletions ch00git/11Miscellany.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# %% [markdown]
# ## Git Stash

# %% [markdown]
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook

# %% [markdown]
# Before you can `git pull`, you need to have committed any changes you have made. If you find you want to pull, but you're not ready to commit, you have to temporarily "put aside" your uncommitted changes.
# For this, you can use the `git stash` command, like in the following example:
Expand Down
6 changes: 5 additions & 1 deletion ch00git/12Remotes.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

# %% [markdown]
# ## Working with multiple remotes
#
#
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook
#
# ### Distributed versus centralised
#
# Older version control systems (cvs, svn) were "centralised"; the history was kept only on a server,
Expand Down
6 changes: 5 additions & 1 deletion ch00git/14Bisect.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

# %% [markdown]
# ## Debugging With Git Bisect
#
#
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook
#
# You can use
#
# ``` bash
Expand Down
1 change: 1 addition & 0 deletions ch01python/00pythons.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def make_figure():
# `make_figure` function defined in the module.

# %%
# restart kernel on jupyterlite (browser) before running this
import draw_eight # Load the library
fig = draw_eight.make_figure()

Expand Down
6 changes: 6 additions & 0 deletions ch01python/010exemplar.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
# By combining them we can feel really powerful but doing minimum work ourselves. The python syntax to import someone else's library is "import".

# %%
# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook

# install geopy if it is not already installed
%pip install geopy

import geopy # A python library for investigating geographic information.
# https://pypi.org/project/geopy/

Expand Down
2 changes: 2 additions & 0 deletions ch02data/061internet.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
# The Python [Requests](http://docs.python-requests.org/en/latest/) library can help us manipulate URLs and requesting the content associated with them. It is easier to use than the `urllib` library that is part of the standard library, and is included with Anaconda and Canopy. It sorts out escaping, parameter encoding, and so on for us.

# %%
# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook
import requests

# %% [markdown]
Expand Down
2 changes: 2 additions & 0 deletions ch02data/063tabular.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# We can request the CSV file text from the URL we used previously:

# %%
# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook
import requests
# Request sunspots data from URL and extract response content as text
sunspots_csv_text = requests.get('http://www.sidc.be/silso/INFO/snmtotcsv.php').text
Expand Down
2 changes: 2 additions & 0 deletions ch02data/066QuakeExercise.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# We can use the [`requests` Python library](https://docs.python-requests.org/en/latest/) to simplify constructing the appropriate query string to add to the <abbr title="Uniform Resource Locator">URL</abbr> and to deal with sending the <abbr title="Hypertext Transfer Protocol">HTTP</abbr> request.

# %% jupyter={"outputs_hidden": false}
# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook
import requests

# %% [markdown]
Expand Down
2 changes: 2 additions & 0 deletions ch02data/068QuakesSolution.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# %% jupyter={"outputs_hidden": false}
import math

# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook
import requests
import IPython
from IPython.display import Image
Expand Down
10 changes: 10 additions & 0 deletions ch02data/110Capstone.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@

# %%
# %%writefile greengraph/graph.py

# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook

# install geopy if it is not already installed
%pip install geopy

import numpy as np
import geopy
from matplotlib import pyplot as plt
Expand Down Expand Up @@ -87,6 +94,9 @@ def plot_green_between(self, steps):

import numpy as np
import imageio.v3 as iio

# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook
import requests

class Map(object):
Expand Down
6 changes: 5 additions & 1 deletion ch03tests/03pytest.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

# %% [markdown]
# ## Testing frameworks
#
#
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
# thread/process restriction), and the cells below might error out on the browser
# (jupyterlite) version of this notebook
#
# ### Why use testing frameworks?

# %% [markdown]
Expand Down
2 changes: 2 additions & 0 deletions ch03tests/05Mocks.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
# For example, consider the following code that downloads a map from the internet:

# %%
# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook
import requests

def map_at(lat, long, satellite=False, zoom=12,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
# Now, close the Jupyter notebook if you have it open, and reopen it. Check your new library is installed with:

# %%
# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook

# install geopy if it is not already installed
%pip install geopy

import geopy
geocoder = geopy.geocoders.Nominatim(user_agent="mphy0021")

Expand Down
2 changes: 1 addition & 1 deletion ch04packaging/04documentation.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
#
# In writing Greeter, we used the [docstring conventions from NumPy](https://numpy.org/doc/stable/docs/howto_document.html).
# So we use the [`numpydoc`](https://numpydoc.readthedocs.io/en/latest/) sphinx extension to
# support these (Note: you will need to install this extension for the later examples to work).
# support these (**NOTE:** you will need to install this extension for the later examples to work).

# %% [markdown]
# ```python
Expand Down
2 changes: 2 additions & 0 deletions ch05construction/08objects.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def move(self, delta_t):
# Here's how we can use Python code to get an image back from YUML:

# %%
# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook
import requests
from IPython.display import Image

Expand Down
3 changes: 3 additions & 0 deletions ch05construction/09patterns.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def yuml(model):
from numpy.fft import rfft,fft,fftfreq
from scipy.interpolate import UnivariateSpline
from scipy.signal import lombscargle

# sending requests to the web is not fully supported on jupyterlite yet, and the
# cells below might error out on the browser (jupyterlite) version of this notebook
import requests


Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ dask
mimesis
dask-expr
graphviz
jupyterlite-core
jupyterlab
notebook
jupyterlite-pyodide-kernel

0 comments on commit c9ab2db

Please sign in to comment.