# scripts/sysimage_warmup.jl # --------------------------------------------------------------------------- # Precompile warm-up workload for the JuliaMSI MCP server sysimage. # # This file is executed by PackageCompiler (scripts/build_sysimage.jl) inside a # subprocess that already has `JuliaMSI_MCP` baked in. It exercises every # engine/MCP code path the server uses, so the resulting system image contains # native code for them instead of paying JIT on first use. # --------------------------------------------------------------------------- using JuliaMSI_MCP const J = JuliaMSI_MCP tmp = mktempdir() ENV["JULIA_MSI_MCP_ARTIFACTS"] = joinpath(tmp, "artifacts") include(joinpath(@__DIR__, "..", "test", "synthetic.jl")) imzml_path = write_synthetic_imzml(tmp; width=3, height=3) # Persistent session + metadata. J.open_dataset(imzml_path; precompute_analytics=true) # Random-access spectrum query. mz, intensity = J.MSI_src.GetSpectrum(J.require_data(), 1) # Ion image (sync execution path). J._run_ion_image( J._sync_runspec(:ion_image, Dict( "mass" => 300.0, "tolerance" => 0.5, "mask_path" => nothing, "include_matrix" => true, "preview_max_dim" => 32, "output_name" => "warm")), J._sync_task(:ion_image), J.require_data()) # Multiple slices (hierarchy inversion). J._run_multiple_slices( J._sync_runspec(:multiple_slices, Dict( "masses" => [100.0, 300.0, 500.0], "tolerance" => 0.5, "mask_path" => nothing, "include_matrix" => false, "preview_max_dim" => 32, "output_name" => "warm")), J._sync_task(:multiple_slices), J.require_data()) # Streaming preprocessing (Sprint 2). J._run_streaming_pipeline( J._sync_runspec(:streaming_pipeline, Dict( "steps" => [ Dict("name" => "smoothing", "params" => Dict("method" => "savitzky_golay", "window" => 5, "order" => 2)), Dict("name" => "normalization", "params" => Dict("method" => "tic")), Dict("name" => "peak_picking", "params" => Dict("method" => "profile", "snr_threshold" => 3.0)), ], "num_bins" => 50, "min_peaks_per_bin" => 1, "frequency_threshold" => 0.0, "reference_peaks" => Float64[], "mask_path" => nothing, "include_matrix" => false, "output_name" => "warm")), J._sync_task(:streaming_pipeline), J.require_data()) J.close_dataset() # Register tools/resources/prompts so the schema builders are compiled too. J.build_server() println("sysimage warmup complete")