Skip to content

Commit 06f3c30

Browse files
Merge pull request #165 from CliMA/ne/hotfix
Fix failure_rate kwarg in WorkerBackend, improve error message
2 parents e040d67 + 17443d0 commit 06f3c30

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClimaCalibrate"
22
uuid = "4347a170-ebd6-470c-89d3-5c705c0cacc2"
33
authors = ["Climate Modeling Alliance"]
4-
version = "0.0.14"
4+
version = "0.0.15"
55

66
[deps]
77
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"

docs/literate_example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ end
111111
# for the ensemble update step. The observation map just takes in the iteration number,
112112
# and always outputs an array.
113113
# For observation map output `G_ensemble`, `G_ensemble[:, m]` must the output of ensemble member `m`.
114-
# This is needed for compatability with EnsembleKalmanProcesses.jl.
114+
# This is needed for compatibility with EnsembleKalmanProcesses.jl.
115115
const days = 86_400
116116
function CAL.observation_map(iteration)
117117
single_member_dims = (1,)

experiments/surface_fluxes_perfect_model/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ weakdeps = ["SparseArrays"]
202202
deps = ["Distributed", "Distributions", "EnsembleKalmanProcesses", "JLD2", "Logging", "Random", "TOML", "YAML"]
203203
path = "../.."
204204
uuid = "4347a170-ebd6-470c-89d3-5c705c0cacc2"
205-
version = "0.0.13"
205+
version = "0.0.14"
206206

207207
[deps.ClimaCalibrate.extensions]
208208
CESExt = "CalibrateEmulateSample"

src/backends.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ const DEFAULT_FAILURE_RATE = 0.5
237237
Run a full calibration on the given backend.
238238
239239
If the EKP struct is not given, it will be constructed upon initialization.
240-
The experiment configuration (ensemble size, prior, observations, etc) can be
240+
While EKP keyword arguments are passed through to the EKP constructor, if using
241+
many keywords it is recommended to construct the EKP object and pass it into `calibrate`.
242+
243+
The experiment configuration (ensemble size, prior, observations, etc) can be
241244
wrapped in an ExperimentConfig or passed in as arguments to the function.
242245
243246
Available Backends: WorkerBackend, CaltechHPCBackend, ClimaGPUBackend, DerechoBackend, JuliaBackend
@@ -286,14 +289,22 @@ function calibrate(
286289
worker_pool = default_worker_pool(),
287290
ekp_kwargs...,
288291
)
289-
eki = ekp_constructor(
292+
ekp = ekp_constructor(
290293
ensemble_size,
291294
prior,
292295
observations,
293296
noise;
294297
ekp_kwargs...,
295298
)
296-
return calibrate(b, eki, n_iterations, prior, output_dir; worker_pool)
299+
return calibrate(
300+
b,
301+
ekp,
302+
n_iterations,
303+
prior,
304+
output_dir;
305+
failure_rate,
306+
worker_pool,
307+
)
297308
end
298309

299310
function calibrate(

src/workers.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ function run_worker_iteration(
1717
worker_pool = default_worker_pool(),
1818
failure_rate = DEFAULT_FAILURE_RATE,
1919
)
20-
# Create a channel to collect results
21-
results = Channel{Any}(ensemble_size)
2220
nfailures = 0
2321
@sync begin
2422
for m in 1:(ensemble_size)
@@ -39,8 +37,10 @@ function run_worker_iteration(
3937
end
4038
iter_failure_rate = nfailures / ensemble_size
4139
if iter_failure_rate > failure_rate
42-
error(
43-
"Ensemble for iter $iter had a $(iter_failure_rate * 100)% failure rate",
40+
throw(
41+
ErrorException(
42+
"Execution halted: Iteration $iter had a $(round(iter_failure_rate * 100; digits=2))% failure rate, exceeding the maximum allowed threshold of $(failure_rate * 100)%.",
43+
),
4444
)
4545
end
4646
end

0 commit comments

Comments
 (0)