Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/algjulia-service/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions packages/algjulia-service/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 14 additions & 3 deletions packages/algjulia-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
13 changes: 13 additions & 0 deletions packages/algjulia-service/jupyter_server.sh
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 23 additions & 0 deletions packages/algjulia-service/make_sysimage.jl
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 2 additions & 0 deletions packages/algjulia-service/sysimage_precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import AlgebraicJuliaService
include(joinpath(pkgdir(AlgebraicJuliaService), "test", "runtests.jl"))
9 changes: 7 additions & 2 deletions packages/frontend/src/stdlib/analyses/jupyter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment on my own code: clearly this isn't ideal, but since in practice the only way to launch a Jupyter server that won't reject the frontend on cross-origin grounds is to run our script, this shouldn't be any less reliable than before, and it has the advantage of not baking the Julia version into the bundled JS.

});
}

Expand Down
Loading