Skip to content

Commit 39582f7

Browse files
yuvipandapre-commit-ci[bot]mathbunnyru
authored
Install Pluto.jl and jupyter-pluto-proxy (#1929)
* Install Pluto.jl and jupyter-pluto-proxy [Pluto.jl](https://plutojl.org/) is an alternative reactive notebook frontend focused specifically on Julia. I think shipping this by default in the julia-enabled images helps serve the Julia community better, particularly when used with JupyterHub. For context, I am working with the Julia users of the [Jupyter Meets the Earth](https://jupytearth.org/) project, and trying to understand how to best serve their needs on a JupyterHub. We currently maintain a massive image that 'has everything', but I'm trying to instead work upstream wherever possible so everyone working in these subfields can benefit. Meeting Julia users where they are at seems a useful path forward here. * Add note about Pluto.jl to selecting.md * Default to replacing - with _ in package imports * Add jupyter-pluto-proxy to package import mapping * Add Pluto.jl to datascience-notebook image * Add test for pluto proxy starting correctly * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_packages.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
1 parent 127004a commit 39582f7

File tree

5 files changed

+77
-1
lines changed

5 files changed

+77
-1
lines changed

docs/using/selecting.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ It contains:
118118
- Everything in `jupyter/minimal-notebook` and its ancestor images
119119
- The [Julia Programming Language](https://julialang.org/)
120120
- [IJulia](https://github.com/JuliaLang/IJulia.jl) to support Julia code in Jupyter notebook
121+
- [Pluto.jl](https://plutojl.org/) reactive Julia notebook interface, made accessible with [jupyter-pluto-proxy](https://github.com/yuvipanda/jupyter-pluto-proxy)
122+
- [HDF5](https://github.com/JuliaIO/HDF5.jl) package
121123

122124
### jupyter/scipy-notebook
123125

@@ -188,6 +190,7 @@ communities.
188190
- [rpy2](https://rpy2.github.io/doc/latest/html/index.html) package
189191
- The [Julia](https://julialang.org/) compiler and base environment
190192
- [IJulia](https://github.com/JuliaLang/IJulia.jl) to support Julia code in Jupyter notebooks
193+
- [Pluto.jl](https://plutojl.org/) reactive Julia notebook interface, made accessible with [jupyter-pluto-proxy](https://github.com/yuvipanda/jupyter-pluto-proxy)
191194
- [HDF5](https://github.com/JuliaIO/HDF5.jl) package
192195

193196
### jupyter/pyspark-notebook

minimal-notebook/setup-scripts/setup-julia-packages.bash

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import Pkg;
1111
Pkg.update();
1212
Pkg.add([
1313
"HDF5",
14-
"IJulia"
14+
"IJulia",
15+
"Pluto"
1516
]);
1617
Pkg.precompile();
1718
'
@@ -23,3 +24,10 @@ mv "${HOME}/.local/share/jupyter/kernels/julia"* "${CONDA_DIR}/share/jupyter/ker
2324
chmod -R go+rx "${CONDA_DIR}/share/jupyter"
2425
rm -rf "${HOME}/.local"
2526
fix-permissions "${JULIA_PKGDIR}" "${CONDA_DIR}/share/jupyter"
27+
28+
# Install jupyter-pluto-proxy to get Pluto to work on JupyterHub
29+
mamba install --yes \
30+
'jupyter-pluto-proxy' && \
31+
mamba clean --all -f -y && \
32+
fix-permissions "${CONDA_DIR}" && \
33+
fix-permissions "/home/${NB_USER}"

tests/base-notebook/test_packages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
PACKAGE_MAPPING = {
5353
# Python
5454
"beautifulsoup4": "bs4",
55+
"jupyter-pluto-proxy": "jupyter_pluto_proxy",
5556
"matplotlib-base": "matplotlib",
5657
"pytables": "tables",
5758
"scikit-image": "skimage",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import logging
2+
import secrets
3+
import time
4+
5+
import requests
6+
7+
from tests.conftest import TrackedContainer, find_free_port
8+
9+
LOGGER = logging.getLogger(__name__)
10+
11+
12+
def test_pluto_proxy(
13+
container: TrackedContainer, http_client: requests.Session
14+
) -> None:
15+
"""Pluto proxy starts Pluto correctly"""
16+
host_port = find_free_port()
17+
token = secrets.token_hex()
18+
container.run_detached(
19+
command=[
20+
"start.sh",
21+
"jupyter",
22+
"lab",
23+
"--port=8888",
24+
f"--LabApp.token={token}",
25+
],
26+
ports={"8888/tcp": host_port},
27+
)
28+
# Give the server a bit of time to start
29+
time.sleep(3)
30+
resp = http_client.get(f"http://localhost:{host_port}/pluto?token={token}")
31+
resp.raise_for_status()
32+
assert "Pluto.jl notebooks" in resp.text, "Pluto.jl text not found in /pluto page"

tests/julia-notebook/test_pluto.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import logging
2+
import secrets
3+
import time
4+
5+
import requests
6+
7+
from tests.conftest import TrackedContainer, find_free_port
8+
9+
LOGGER = logging.getLogger(__name__)
10+
11+
12+
def test_pluto_proxy(
13+
container: TrackedContainer, http_client: requests.Session
14+
) -> None:
15+
"""Pluto proxy starts Pluto correctly"""
16+
host_port = find_free_port()
17+
token = secrets.token_hex()
18+
container.run_detached(
19+
command=[
20+
"start.sh",
21+
"jupyter",
22+
"lab",
23+
"--port=8888",
24+
f"--LabApp.token={token}",
25+
],
26+
ports={"8888/tcp": host_port},
27+
)
28+
# Give the server a bit of time to start
29+
time.sleep(3)
30+
resp = http_client.get(f"http://localhost:{host_port}/pluto?token={token}")
31+
resp.raise_for_status()
32+
assert "Pluto.jl notebooks" in resp.text, "Pluto.jl text not found in /pluto page"

0 commit comments

Comments
 (0)