Skip to content

Commit 27a0895

Browse files
committed
Avoid raising runtime error when calling get_opt_status and no objectives and controls are stored in everest storage
1 parent 8025e0b commit 27a0895

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/everest/detached/__init__.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,15 @@ def get_opt_status(output_folder: str) -> dict[str, Any]:
161161
objective_names = storage.data.objective_functions["objective_name"].to_list()
162162
control_names = storage.data.controls["control_name"].to_list()
163163

164-
expected_objectives = pl.concat(
165-
[
166-
b.batch_objectives.select(objective_names)
167-
for b in storage.data.batches
168-
if b.batch_objectives is not None
169-
]
170-
).to_dict(as_series=False)
164+
objectives = [
165+
b.batch_objectives.select(objective_names)
166+
for b in storage.data.batches
167+
if b.batch_objectives is not None
168+
]
169+
170+
expected_objectives = (
171+
{} if not objectives else pl.concat(objectives).to_dict(as_series=False)
172+
)
171173

172174
expected_total_objective = [
173175
b.batch_objectives["total_objective_value"].item()
@@ -191,16 +193,18 @@ def get_opt_status(output_folder: str) -> dict[str, Any]:
191193
"objective_value": expected_total_objective,
192194
"expected_objectives": expected_objectives,
193195
}
196+
controls = [
197+
b.realization_controls.select(control_names)
198+
for b in storage.data.batches
199+
if b.realization_controls is not None
200+
]
201+
control_history = (
202+
{} if not controls else pl.concat(controls).to_dict(as_series=False)
203+
)
194204

195205
return {
196206
"objective_history": expected_total_objective,
197-
"control_history": pl.concat(
198-
[
199-
b.realization_controls.select(control_names)
200-
for b in storage.data.batches
201-
if b.realization_controls is not None
202-
]
203-
).to_dict(as_series=False),
207+
"control_history": control_history,
204208
"objectives_history": expected_objectives,
205209
"accepted_control_indices": improvement_batches,
206210
"cli_monitor_data": cli_monitor_data,

0 commit comments

Comments
 (0)