Skip to content

Commit 46636c7

Browse files
committed
Read/write everest results directly from/to files
1 parent 0c5f260 commit 46636c7

File tree

3 files changed

+228
-137
lines changed

3 files changed

+228
-137
lines changed

src/everest/api/everest_data_api.py

+3
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ def pivot_gradient(df: pl.DataFrame) -> pl.DataFrame:
312312
)
313313

314314
for batch in self._ever_storage.data.batches:
315+
if not batch.has_data:
316+
continue
317+
315318
try_append_perturbation_dfs(
316319
batch.batch_id,
317320
batch.perturbation_objectives,

src/everest/bin/config_branch_script.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ def opt_controls_by_batch(optimization_dir: str, batch: int) -> dict[str, Any] |
5151
assert storage.data is not None
5252
assert storage.data.controls is not None
5353
control_names = storage.data.controls["control_name"]
54-
batch_data = next((b for b in storage.data.batches if b.batch_id == batch), None)
54+
batch_data = next(
55+
(
56+
b
57+
for b in storage.data.batches
58+
if b.batch_id == batch and b.realization_controls is not None
59+
),
60+
None,
61+
)
5562

5663
if batch_data:
5764
# It is currently assumed that the batch provided is not a perturbation-only
5865
# batch.
5966
# All geo-realizations should have the same unperturbed control values per batch
6067
# hence it does not matter which realization we select the controls for
68+
assert batch_data.realization_controls is not None
6169
return batch_data.realization_controls.select(
6270
control_names.to_list()
6371
).to_dicts()[0]

0 commit comments

Comments
 (0)