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"
42fuse_env = ENV [" FUSE_ENVIRONMENT" ]
53env_dir = joinpath (ENV [" FUSE_HOME" ], " environments" , fuse_env)
@@ -37,6 +35,7 @@ println("### Setup new environment")
3735Pkg. activate (env_dir)
3836Pkg. add ([[" FUSE" , " Plots" , " IJulia" , " WebIO" , " Interact" , " EFIT" , " ArgParse" ]; packages])
3937Pkg. build (" IJulia" )
38+ Pkg. build (" WebIO" )
4039
4140println ()
4241println (" ### Freeze Project and Manifest to read only" )
@@ -47,25 +46,79 @@ println()
4746println (" ### Create precompile script" )
4847precompile_execution_file = joinpath (env_dir, " precompile_script.jl" )
4948precompile_cmds = """
49+ using WebIO
5050using FUSE, EFIT, $pkgs_using
5151include(joinpath(pkgdir(FUSE), "docs", "src", "tutorial.jl"))
5252include(joinpath(pkgdir(FUSE), "test", "runtests.jl"))
53+ include(joinpath(pkgdir(FUSE), "deploy", "omega", "time_dependent_d3d.jl")
5354"""
5455write (precompile_execution_file, precompile_cmds)
5556chmod (precompile_execution_file, 0o444 )
5657
5758println ()
5859println (" ### Precompile FUSE sys image" )
5960sysimage_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+
6167chmod (sysimage_path, 0o555 )
6268
6369println ()
64- println (" ### Create IJulia kernels (10 threads for login, 40 for worker) " )
70+ println (" ### Create IJulia kernels" )
6571import 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
70123println ()
71124println (" ### Create fuse executable" )
0 commit comments