-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwarmup.jl
38 lines (27 loc) · 1.08 KB
/
warmup.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# https://www.youtube.com/watch?v=m2DvmHusyk4
import Pluto
session = Pluto.ServerSession()
session.options.server.port = 40404
session.options.security.require_secret_for_access = false
path = tempname()
original = joinpath(pathof(Pluto) |> dirname |> dirname, "sample", "Tower of Hanoi.jl")
# so that we don't overwrite the file:
Pluto.readwrite(original, path)
@info "Loading notebook"
nb = Pluto.load_notebook(Pluto.tamepath(path));
session.notebooks[nb.notebook_id] = nb;
@info "Loading notebook"
nb = Pluto.load_notebook(Pluto.tamepath(path));
session.notebooks[nb.notebook_id] = nb;
@info "Running notebook"
Pluto.update_save_run!(session, nb, nb.cells; run_async=false, prerender_text=true)
# nice! we ran the notebook, so we already precompiled a lot
@info "Starting HTTP server"
# next, we'll run the HTTP server which needs a bit of nasty code
t = @async Pluto.run(session)
sleep(5)
download("http://localhost:40404/")
# this is async because it blocks for some reason
@async Base.throwto(t, InterruptException())
sleep(2) # i am pulling these numbers out of thin air
@info "Warmup done"