Skip to content

Commit c2ee773

Browse files
feat(binder): implement Pluto server setup and configuration scripts
1 parent d69a6df commit c2ee773

10 files changed

Lines changed: 232 additions & 135 deletions

File tree

binder/pluto_server_config.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(
2+
# Julia Compiler options:
3+
# This makes Julia's precompilation less optimized for repeated package loads, and more optimized for single package loads. Precompilation will be faster, package loads will be slower. But in total, startup times will be faster, see https://discourse.julialang.org/t/first-pluto-notebook-launches-are-slower-on-julia-1-9-beta-3/93429/
4+
pkgimages="no",
5+
# This makes Julia compile faster, and run slightly slower.
6+
optimize=1,
7+
8+
# Pluto security options:
9+
# Disable authentication – jupyter/binder already does its own auth, no need to add more.
10+
require_secret_for_open_links=false,
11+
require_secret_for_access=false,
12+
# Disable the warning message about running code from unknown sources when exiting Safe Preview mode (https://github.com/fonsp/Pluto.jl/pull/2563)
13+
warn_about_untrusted_code=false,
14+
15+
# Pluto misc options:
16+
# Don't try to start Firefox when the server launches
17+
launch_browser=false,
18+
# Don't show the "a newer version of Pluto is available" message
19+
dismiss_update_notification=true,
20+
# Don't show the file picker at the top of the notebook (because all files stored on binder will be lost). Instead, just show a big download button so users can store the .jl file locally.
21+
show_file_system=false,
22+
)

binder/plutoserver.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def setup_plutoserver():
2+
return {
3+
"command": ["sh", "start_server.sh"],
4+
"environment": {
5+
"JSP_PORT": "{port}",
6+
},
7+
"timeout": 60,
8+
"launcher_entry": {
9+
"title": "Pluto.jl",
10+
},
11+
}

binder/postBuild

100755100644
File mode changed.

binder/setup.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
name="jupyter-pluto-proxy",
5+
# py_modules rather than packages, since we only have 1 file
6+
py_modules=['plutoserver'],
7+
entry_points={
8+
'jupyter_serverproxy_servers': [
9+
# name = packagename:function_name
10+
'pluto = plutoserver:setup_plutoserver',
11+
]
12+
},
13+
install_requires=['jupyter-server-proxy @ git+http://github.com/fonsp/jupyter-server-proxy@470e13ae0f7a8961202c76ea6bcbcfd27ed07e6a'],
14+
)

binder/start

Lines changed: 0 additions & 42 deletions
This file was deleted.

binder/start_server.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Pluto
2+
3+
@assert haskey(ENV, "JSP_PORT")
4+
5+
Pluto.run(;
6+
host="0.0.0.0",
7+
port=parse(Int64, get(ENV, "JSP_PORT", nothing)),
8+
9+
include("pluto_server_config.jl")...,
10+
)

binder/start_server.sh

100755100644
File mode changed.

binder/warmup_server.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@info("instantiate from setup.py")
2+
import Pkg
3+
Pkg.instantiate()
4+
5+
@info("import Pluto from setup.py")
6+
import Pluto
7+
8+
@info("starting new notebook from setup.py")
9+
sesh = Pluto.ServerSession(options=Pluto.Configuration.from_flat_kwargs(; include("pluto_server_config.jl")...))
10+
nb = Pluto.SessionActions.new(sesh; run_async=false)
11+
12+
13+
@info("shutting down notebook from setup.py")
14+
Pluto.SessionActions.shutdown(sesh, nb; async=false)
15+
@info("setup.py done");

0 commit comments

Comments
 (0)