Skip to content

Commit 373ceb6

Browse files
authored
Improve public Omega installation (#1021)
* Allow multiple threads since PackageCompiler fixed multithreading * time_dependent_d3d script and interactive plotting in sysimage
1 parent b2b624a commit 373ceb6

File tree

2 files changed

+62
-8
lines changed

2 files changed

+62
-8
lines changed

deploy/omega/deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export FUSE_ENVIRONMENT="$fuse_env"
2121
export JULIA_DEPOT_PATH="$envdir/.julia:"
2222
export JULIA_PKG_USE_CLI_GIT=1
2323
export JULIA_CC="gcc -O3"
24-
export JULIA_NUM_THREADS=1
24+
export JULIA_NUM_THREADS=10
25+
export JULIA_NUM_PRECOMPILE_TASKS=10
2526

2627
# cascadelake for Intel login; znver2 for worker; generic fallback
2728
# remove xsaveopt since that's what julia distributions do

deploy/omega/install_fuse_environment.jl

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@assert (Threads.nthreads() == 1) "Error: Installing FUSE sysimage requires running Julia with one thread"
2-
31
@assert ("FUSE_ENVIRONMENT" in keys(ENV)) "Error: Must define FUSE_ENVIRONMENT environment variable"
42
fuse_env = ENV["FUSE_ENVIRONMENT"]
53
env_dir = joinpath(ENV["FUSE_HOME"], "environments", fuse_env)
@@ -37,6 +35,7 @@ println("### Setup new environment")
3735
Pkg.activate(env_dir)
3836
Pkg.add([["FUSE", "Plots", "IJulia", "WebIO", "Interact", "EFIT", "ArgParse"]; packages])
3937
Pkg.build("IJulia")
38+
Pkg.build("WebIO")
4039

4140
println()
4241
println("### Freeze Project and Manifest to read only")
@@ -47,25 +46,79 @@ println()
4746
println("### Create precompile script")
4847
precompile_execution_file = joinpath(env_dir, "precompile_script.jl")
4948
precompile_cmds = """
49+
using WebIO
5050
using FUSE, EFIT, $pkgs_using
5151
include(joinpath(pkgdir(FUSE), "docs", "src", "tutorial.jl"))
5252
include(joinpath(pkgdir(FUSE), "test", "runtests.jl"))
53+
include(joinpath(pkgdir(FUSE), "deploy", "omega", "time_dependent_d3d.jl")
5354
"""
5455
write(precompile_execution_file, precompile_cmds)
5556
chmod(precompile_execution_file, 0o444)
5657

5758
println()
5859
println("### Precompile FUSE sys image")
5960
sysimage_path = joinpath(env_dir, "sys_fuse.so")
60-
create_sysimage(["FUSE"]; sysimage_path, precompile_execution_file, cpu_target)
61+
create_sysimage(["FUSE", "IJulia", "WebIO", "Interact", "Plots"];
62+
project=env_dir,
63+
sysimage_path,
64+
precompile_execution_file,
65+
cpu_target)
66+
6167
chmod(sysimage_path, 0o555)
6268

6369
println()
64-
println("### Create IJulia kernels (10 threads for login, 40 for worker)")
70+
println("### Create IJulia kernels")
6571
import IJulia
66-
IJulia.installkernel("Julia+FUSE - single thread", "--sysimage=$sysimage_path"; env=Dict("JULIA_NUM_THREADS"=>"1"))
67-
IJulia.installkernel("Julia+FUSE - 16-thread (medium)", "--sysimage=$sysimage_path"; env=Dict("JULIA_NUM_THREADS"=>"16"))
68-
IJulia.installkernel("Julia+FUSE - 10-thread (long)", "--sysimage=$sysimage_path"; env=Dict("JULIA_NUM_THREADS"=>"10"))
72+
73+
#===
74+
We're putting IJulia, WebIO, and Interact into the sysimage now
75+
This causes issues with `import WebIO` not seeing jupyter
76+
when the sysimage is loaded
77+
The solution is to call `WebIO.__init__()` at the beginning of the kernel
78+
This does some fancy stuff to print warning from this to the terminal
79+
instead of inside the notebook where it may confuse users
80+
===#
81+
preload_webio_commands = """const __WEBIO_INITED__ = Ref(false)
82+
83+
try
84+
using IJulia, Logging
85+
IJulia.push_preexecute_hook(() -> begin
86+
if !__WEBIO_INITED__[]
87+
@info "WebIO automatically reinitialized for Julia+FUSE sysimage"
88+
term_logger = ConsoleLogger(IJulia.orig_stderr[], Logging.Warn)
89+
with_logger(term_logger) do
90+
# send warnings/errors to the terminal, not the notebook
91+
redirect_stderr(IJulia.orig_stderr[]) do
92+
@eval import WebIO
93+
WebIO.__init__() # re-register provider quietly for the notebook
94+
end
95+
end
96+
__WEBIO_INITED__[] = true
97+
end
98+
nothing
99+
end)
100+
catch e
101+
@warn "preload_webio failed" exception=(e, catch_backtrace())
102+
end
103+
"""
104+
preload_webio_file = joinpath(env_dir, ".jupyter", "preload_webio.jl")
105+
write(preload_webio_file, preload_webio_commands)
106+
chmod(preload_webio_file, 0o444)
107+
IJulia.installkernel("Julia+FUSE - single thread",
108+
"--project=$env_dir",
109+
"--sysimage=$sysimage_path",
110+
"--load=$preload_webio_file";
111+
env=Dict("JULIA_NUM_THREADS"=>"1"))
112+
IJulia.installkernel("Julia+FUSE - 16-thread (medium)",
113+
"--project=$env_dir",
114+
"--sysimage=$sysimage_path",
115+
"--load=$preload_webio_file";
116+
env=Dict("JULIA_NUM_THREADS"=>"16"))
117+
IJulia.installkernel("Julia+FUSE - 10-thread (long)",
118+
"--project=$env_dir",
119+
"--sysimage=$sysimage_path",
120+
"--load=$preload_webio_file";
121+
env=Dict("JULIA_NUM_THREADS"=>"10"))
69122

70123
println()
71124
println("### Create fuse executable")

0 commit comments

Comments
 (0)