diff --git a/Project.toml b/Project.toml index 98ce1b0f..fc805cc5 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,6 @@ authors = ["Climate Modeling Alliance"] version = "0.0.5" [deps] -ClusterManagers = "34f1f09b-3a8b-5176-ab39-66d58a4d544e" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" EnsembleKalmanProcesses = "aa8a2aa5-91d8-4396-bcef-d4f2ec43552d" @@ -21,7 +20,6 @@ CESExt = "CalibrateEmulateSample" [compat] CalibrateEmulateSample = "0.5" -ClusterManagers = "0.4.6" Distributed = "1" Distributions = "0.25" EnsembleKalmanProcesses = "1, 2" diff --git a/experiments/surface_fluxes_perfect_model/generate_data.jl b/experiments/surface_fluxes_perfect_model/generate_data.jl index a35659ac..2127dd04 100644 --- a/experiments/surface_fluxes_perfect_model/generate_data.jl +++ b/experiments/surface_fluxes_perfect_model/generate_data.jl @@ -124,4 +124,5 @@ JLD2.save_object( ustar = JLD2.load_object(joinpath(data_path, "synthetic_ustar_array_noisy.jld2")) (; observation, variance) = process_member_data(ustar; output_variance = true) -nothing +JLD2.save_object(joinpath(data_path, "obs_mean.jld2"), observation) +JLD2.save_object(joinpath(data_path, "obs_noise_cov.jld2"), variance) diff --git a/experiments/surface_fluxes_perfect_model/postprocessing.jl b/experiments/surface_fluxes_perfect_model/postprocessing.jl index 58be06f6..7680b484 100644 --- a/experiments/surface_fluxes_perfect_model/postprocessing.jl +++ b/experiments/surface_fluxes_perfect_model/postprocessing.jl @@ -97,6 +97,7 @@ function convergence_plot( Makie.hlines!(ax, [theta_star], color = :red, linestyle = :dash) Makie.save(joinpath(output_dir, "convergence_$param_name.png"), f) + println(joinpath(output_dir, "convergence_$param_name.png")) end end @@ -181,3 +182,4 @@ Makie.lines!( ) Makie.save(joinpath(output_dir, "scatter_iter.png"), f) +println(joinpath(output_dir, "scatter_iter.png")) diff --git a/test/hpc_backend_e2e.jl b/test/hpc_backend_e2e.jl index 03a24d6d..c93aa2d4 100644 --- a/test/hpc_backend_e2e.jl +++ b/test/hpc_backend_e2e.jl @@ -33,7 +33,7 @@ function test_sf_calibration_output(eki, prior) spread = map(var, params) # Spread should be heavily decreased as particles have converged - @test last(spread) / first(spread) < 0.20 + @test last(spread) / first(spread) < 0.15 forward_model_output = get_g_mean_final(eki) @show forward_model_output @@ -41,13 +41,13 @@ function test_sf_calibration_output(eki, prior) end end -@assert get_backend() <: HPCBackend -hpc_kwargs = kwargs(time = 5, ntasks = 1, cpus_per_task = 1) -if get_backend() == DerechoBackend - hpc_kwargs[:queue] = "develop" -end -eki = calibrate(experiment_dir; model_interface, hpc_kwargs, verbose = true) -test_sf_calibration_output(eki, prior) +# @assert get_backend() <: HPCBackend +# hpc_kwargs = kwargs(time = 5, ntasks = 1, cpus_per_task = 1) +# if get_backend() == DerechoBackend +# hpc_kwargs[:queue] = "develop" +# end +# eki = calibrate(experiment_dir; model_interface, hpc_kwargs, verbose = true) +# test_sf_calibration_output(eki, prior) # Pure Julia calibration, this should run anywhere eki = calibrate(JuliaBackend, experiment_dir) diff --git a/test/pure_julia_e2e.jl b/test/pure_julia_e2e.jl index e714d63d..3b9cfec2 100644 --- a/test/pure_julia_e2e.jl +++ b/test/pure_julia_e2e.jl @@ -22,7 +22,7 @@ n_iterations = 1 ensemble_size = 20 observations = [20.0] noise = [0.01;;] -output_dir = joinpath("test", "e2e_test_output") +output_dir = mktempdir() experiment_config = ExperimentConfig( n_iterations, @@ -37,21 +37,11 @@ experiment_config = ExperimentConfig( # This "model" just samples parameters and returns them, we are checking that the # results are reproducible. function forward_model(iteration, member) - experiment_config = ExperimentConfig(project_dir()) - model_config = Dict() - output_dir = (experiment_config.output_dir) member_path = path_to_ensemble_member(output_dir, iteration, member) - model_config["output_dir"] = member_path parameter_path = joinpath(member_path, "parameters.toml") - model_config["toml"] = parameter_path - return model_config -end - -function run_forward_model(config) - toml_dict = CP.create_toml_dict(Float64; override_file = config["toml"]) + toml_dict = CP.create_toml_dict(Float64; override_file = parameter_path) (; test_param) = CP.get_parameter_values(toml_dict, "test_param") - output = test_param - JLD2.save_object(joinpath(config["output_dir"], output_file), output) + JLD2.save_object(joinpath(member_path, output_file), test_param) end function observation_map(iteration) @@ -77,4 +67,3 @@ ekp = calibrate(JuliaBackend, experiment_config) @test parameter_values[end][1] ≈ 11.852161842745355 rtol = 0.01 end -rm(output_dir; recursive = true) diff --git a/test/slurm_unit_tests.jl b/test/slurm_unit_tests.jl index aff292e7..48a3c40d 100644 --- a/test/slurm_unit_tests.jl +++ b/test/slurm_unit_tests.jl @@ -55,12 +55,13 @@ iteration = 1; member = 1 model_interface = "model_interface.jl"; include(model_interface) experiment_dir = "exp/dir" -CAL.forward_model(member, iteration, experiment_dir))' +CAL.forward_model(iteration, member)' exit 0 """ for (generated_str, test_str) in zip(split(sbatch_file, "\n"), split(expected_sbatch_contents, "\n")) + # Test one line at a time to see discrepancies @test generated_str == test_str end @@ -77,15 +78,15 @@ end # Test job lifecycle test_cmd = """ #!/bin/bash -#SBATCH --time=00:00:10 -sleep 10 +#SBATCH --time=00:00:02 +sleep 1 """ jobid = submit_cmd_helper(test_cmd) @test CAL.job_status(jobid) == :RUNNING @test CAL.job_running(CAL.job_status(jobid)) -sleep(180) # Ensure job finishes. To debug, lower sleep time or comment out the code block +sleep(60) # Ensure job finishes. To debug, lower sleep time or comment out the code block @test CAL.job_status(jobid) == :COMPLETED @test CAL.job_completed(CAL.job_status(jobid)) @test CAL.job_success(CAL.job_status(jobid))