Skip to content

Commit 5a9f2a3

Browse files
quffaroepatters
andcommitted
Script to build sys image for AlgebraicJulia service (#289)
* wip need to make sure jupyter server starts with sysimage * 9s startup versus 21s startup. adding helper script * added test precompilation statements * removed kernel checking conditional * Delete packages/sysimages/Manifest.toml * CLEANUP: Move sys image scripts to main Julia dir. Also, frontend now uses the default kernel set in the Jupyter server. --------- Co-authored-by: Evan Patterson <evan@epatters.org>
1 parent eec27cd commit 5a9f2a3

File tree

7 files changed

+63
-5
lines changed

7 files changed

+63
-5
lines changed

packages/algjulia-service/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ docs/site/
2222
# committed for packages, but should be committed for applications that require a static
2323
# environment.
2424
Manifest.toml
25+
26+
# Julia sys images
27+
*.so

packages/algjulia-service/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Decapodes = "0.5.6"
2929
DiagrammaticEquations = "0.1.7"
3030
Distributions = "0.25"
3131
GeometryBasics = "0.4"
32+
IJulia = "1.26.0"
3233
JSON3 = "1"
3334
LinearAlgebra = "1"
3435
MLStyle = "0.4"

packages/algjulia-service/README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,22 @@ julia --project -e 'import Pkg; Pkg.instantiate()'
2525

2626
## Usage
2727

28-
Navigate to this directory and run:
28+
Navigate to this directory and launch the Jupyter serving by running:
2929

3030
```sh
31-
jupyter server --IdentityProvider.token="" --ServerApp.disable_check_xsrf=True --ServerApp.allow_origin="http://localhost:5173"
31+
./jupyter_server.sh
3232
```
3333

3434
While the Jupyter server is running, the AlgebraicJulia service will be usable
35-
by CatColab served locally.
35+
by CatColab when served locally.
36+
37+
## Compiling a Sysimage
38+
39+
Precompiling dependencies like `CairoMakie.jl` and `OrdinaryDiffEq.jl` can be
40+
time-consuming. A **sysimage** is a file that stores precompilation statements,
41+
making future invocations of `AlgebraicJuliaService` and its dependencies
42+
immediate.
43+
44+
To build a sysimage, run the Julia program `./make_sysimage.jl` as a script.
45+
This process may take upwards of five minutes or longer, depending on your
46+
machine.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
KERNEL_NAME="julia-1.11"
4+
#KERNEL_NAME="julia-ajaas-1.11"
5+
6+
ORIGIN="http://localhost:5173"
7+
8+
jupyter server \
9+
--IdentityProvider.token="" \
10+
--ServerApp.disable_check_xsrf=True \
11+
--ServerApp.allow_origin="$ORIGIN" \
12+
--ServerApp.allow_credentials=True \
13+
--MultiKernelManager.default_kernel_name="$KERNEL_NAME"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env julia
2+
3+
@info "Verifying PackageCompiler is installed globally"
4+
using Pkg; Pkg.activate(); Pkg.add("PackageCompiler")
5+
using PackageCompiler
6+
7+
@info "Activating sysimage environment"
8+
Pkg.activate(@__DIR__)
9+
10+
@info "Creating the sysimage. This may take a while..."
11+
sysimg="AlgebraicJuliaService.so"
12+
create_sysimage(["AlgebraicJuliaService"], sysimage_path=sysimg,
13+
precompile_execution_file="sysimage_precompile.jl")
14+
sysimg_path=joinpath(@__DIR__, sysimg);
15+
16+
@info "Adding $sysimg_path to IJulia kernel"
17+
Pkg.activate(); Pkg.add("IJulia")
18+
using IJulia
19+
20+
installkernel("Julia AJaaS", "--project=@.", "--sysimage=$sysimg_path")
21+
22+
@info "Done!"
23+
exit()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import AlgebraicJuliaService
2+
include(joinpath(pkgdir(AlgebraicJuliaService), "test", "runtests.jl"))

packages/frontend/src/stdlib/analyses/jupyter.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ export function createKernel(
3939

4040
/** Create a Julia kernel in a reactive context. */
4141
export function createJuliaKernel(serverOptions: ServerSettings) {
42+
// XXX: How do we know...
43+
// - which Julia version to use?
44+
// - whether to use the standard kernel or one with our custom sys image?
45+
// For now, we are omitting the kernel name completely and thus assuming
46+
// that the correct default kernel has been set on the Jupyter server.
47+
// Obviously this approach will not extend to multiple languages.
4248
return createKernel(serverOptions, {
43-
// XXX: Do I have to specify the Julia version?
44-
name: "julia-1.11",
49+
//name: "julia-1.11",
4550
});
4651
}
4752

0 commit comments

Comments
 (0)