Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid raising runtime error when calling get_opt_status and no objectives and controls are stored in everest storage #10156

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/everest/detached/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ def get_opt_status(output_folder: str) -> dict[str, Any]:
objective_names = storage.data.objective_functions["objective_name"].to_list()
control_names = storage.data.controls["control_name"].to_list()

expected_objectives = pl.concat(
[
b.batch_objectives.select(objective_names)
for b in storage.data.batches
if b.batch_objectives is not None
]
).to_dict(as_series=False)
objectives = [
b.batch_objectives.select(objective_names)
for b in storage.data.batches
if b.batch_objectives is not None
]

expected_objectives = (
{} if not objectives else pl.concat(objectives).to_dict(as_series=False)
)

expected_total_objective = [
b.batch_objectives["total_objective_value"].item()
Expand All @@ -191,16 +193,18 @@ def get_opt_status(output_folder: str) -> dict[str, Any]:
"objective_value": expected_total_objective,
"expected_objectives": expected_objectives,
}
controls = [
b.realization_controls.select(control_names)
for b in storage.data.batches
if b.realization_controls is not None
]
control_history = (
{} if not controls else pl.concat(controls).to_dict(as_series=False)
)

return {
"objective_history": expected_total_objective,
"control_history": pl.concat(
[
b.realization_controls.select(control_names)
for b in storage.data.batches
if b.realization_controls is not None
]
).to_dict(as_series=False),
"control_history": control_history,
"objectives_history": expected_objectives,
"accepted_control_indices": improvement_batches,
"cli_monitor_data": cli_monitor_data,
Expand Down