diff --git a/packages/algjulia-service/.gitignore b/packages/algjulia-service/.gitignore index 29126e47b..7a339e682 100644 --- a/packages/algjulia-service/.gitignore +++ b/packages/algjulia-service/.gitignore @@ -22,3 +22,6 @@ docs/site/ # committed for packages, but should be committed for applications that require a static # environment. Manifest.toml + +# Julia sys images +*.so diff --git a/packages/algjulia-service/Project.toml b/packages/algjulia-service/Project.toml index 08fe06591..d3c2d4696 100644 --- a/packages/algjulia-service/Project.toml +++ b/packages/algjulia-service/Project.toml @@ -29,6 +29,7 @@ Decapodes = "0.5.6" DiagrammaticEquations = "0.1.7" Distributions = "0.25" GeometryBasics = "0.4" +IJulia = "1.26.0" JSON3 = "1" LinearAlgebra = "1" MLStyle = "0.4" diff --git a/packages/algjulia-service/README.md b/packages/algjulia-service/README.md index 859f307de..3ff764358 100644 --- a/packages/algjulia-service/README.md +++ b/packages/algjulia-service/README.md @@ -25,11 +25,22 @@ julia --project -e 'import Pkg; Pkg.instantiate()' ## Usage -Navigate to this directory and run: +Navigate to this directory and launch the Jupyter serving by running: ```sh -jupyter server --IdentityProvider.token="" --ServerApp.disable_check_xsrf=True --ServerApp.allow_origin="http://localhost:5173" +./jupyter_server.sh ``` While the Jupyter server is running, the AlgebraicJulia service will be usable -by CatColab served locally. +by CatColab when served locally. + +## Compiling a Sysimage + +Precompiling dependencies like `CairoMakie.jl` and `OrdinaryDiffEq.jl` can be +time-consuming. A **sysimage** is a file that stores precompilation statements, +making future invocations of `AlgebraicJuliaService` and its dependencies +immediate. + +To build a sysimage, run the Julia program `./make_sysimage.jl` as a script. +This process may take upwards of five minutes or longer, depending on your +machine. diff --git a/packages/algjulia-service/jupyter_server.sh b/packages/algjulia-service/jupyter_server.sh new file mode 100755 index 000000000..291f79c4a --- /dev/null +++ b/packages/algjulia-service/jupyter_server.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +KERNEL_NAME="julia-1.11" +#KERNEL_NAME="julia-ajaas-1.11" + +ORIGIN="http://localhost:5173" + +jupyter server \ + --IdentityProvider.token="" \ + --ServerApp.disable_check_xsrf=True \ + --ServerApp.allow_origin="$ORIGIN" \ + --ServerApp.allow_credentials=True \ + --MultiKernelManager.default_kernel_name="$KERNEL_NAME" diff --git a/packages/algjulia-service/make_sysimage.jl b/packages/algjulia-service/make_sysimage.jl new file mode 100755 index 000000000..58c6ba96f --- /dev/null +++ b/packages/algjulia-service/make_sysimage.jl @@ -0,0 +1,23 @@ +#!/usr/bin/env julia + +@info "Verifying PackageCompiler is installed globally" +using Pkg; Pkg.activate(); Pkg.add("PackageCompiler") +using PackageCompiler + +@info "Activating sysimage environment" +Pkg.activate(@__DIR__) + +@info "Creating the sysimage. This may take a while..." +sysimg="AlgebraicJuliaService.so" +create_sysimage(["AlgebraicJuliaService"], sysimage_path=sysimg, + precompile_execution_file="sysimage_precompile.jl") +sysimg_path=joinpath(@__DIR__, sysimg); + +@info "Adding $sysimg_path to IJulia kernel" +Pkg.activate(); Pkg.add("IJulia") +using IJulia + +installkernel("Julia AJaaS", "--project=@.", "--sysimage=$sysimg_path") + +@info "Done!" +exit() diff --git a/packages/algjulia-service/sysimage_precompile.jl b/packages/algjulia-service/sysimage_precompile.jl new file mode 100755 index 000000000..3d2770e52 --- /dev/null +++ b/packages/algjulia-service/sysimage_precompile.jl @@ -0,0 +1,2 @@ +import AlgebraicJuliaService +include(joinpath(pkgdir(AlgebraicJuliaService), "test", "runtests.jl")) diff --git a/packages/frontend/src/stdlib/analyses/jupyter.ts b/packages/frontend/src/stdlib/analyses/jupyter.ts index b085b1ed4..6e04f4f1c 100644 --- a/packages/frontend/src/stdlib/analyses/jupyter.ts +++ b/packages/frontend/src/stdlib/analyses/jupyter.ts @@ -39,9 +39,14 @@ export function createKernel( /** Create a Julia kernel in a reactive context. */ export function createJuliaKernel(serverOptions: ServerSettings) { + // XXX: How do we know... + // - which Julia version to use? + // - whether to use the standard kernel or one with our custom sys image? + // For now, we are omitting the kernel name completely and thus assuming + // that the correct default kernel has been set on the Jupyter server. + // Obviously this approach will not extend to multiple languages. return createKernel(serverOptions, { - // XXX: Do I have to specify the Julia version? - name: "julia-1.11", + //name: "julia-1.11", }); }