Skip to content

Commit

Permalink
review: Stop storing result_id
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Jan 15, 2025
1 parent c3203fa commit 6bef204
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/everest/api/everest_data_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def gradient_values(self):
if not all_batch_data:
return []

all_info = polars.concat(all_batch_data).drop("result_id")
all_info = polars.concat(all_batch_data)
objective_columns = [
c
for c in all_info.drop(["batch_id", "control_name"]).columns
Expand Down
18 changes: 2 additions & 16 deletions src/everest/everest_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ def _rename_ropt_df_columns(df: polars.DataFrame) -> polars.DataFrame:
def _enforce_dtypes(df: polars.DataFrame) -> polars.DataFrame:
dtypes = {
"batch_id": polars.UInt32,
"result_id": polars.UInt32,
"perturbation": polars.UInt32,
"realization": polars.UInt32,
# -1 is used as a value in simulator cache.
Expand Down Expand Up @@ -445,7 +444,6 @@ def _store_function_results(self, results: FunctionResults) -> _EvaluationResult
select=["objectives", "evaluation_ids"],
).reset_index(),
).select(
"result_id",
"batch_id",
"realization",
"objective",
Expand All @@ -460,7 +458,6 @@ def _store_function_results(self, results: FunctionResults) -> _EvaluationResult
select=["constraints", "evaluation_ids"],
).reset_index(),
).select(
"result_id",
"batch_id",
"realization",
"evaluation_ids",
Expand All @@ -474,9 +471,7 @@ def _store_function_results(self, results: FunctionResults) -> _EvaluationResult

batch_constraints = polars.from_pandas(
results.to_dataframe("nonlinear_constraints").reset_index()
).select(
"result_id", "batch_id", "nonlinear_constraint", "values", "violations"
)
).select("batch_id", "nonlinear_constraint", "values", "violations")

batch_constraints = batch_constraints.rename(
{
Expand Down Expand Up @@ -517,16 +512,13 @@ def _store_function_results(self, results: FunctionResults) -> _EvaluationResult
"functions",
select=["objectives", "weighted_objective"],
).reset_index()
).select(
"result_id", "batch_id", "objective", "objectives", "weighted_objective"
)
).select("batch_id", "objective", "objectives", "weighted_objective")

realization_controls = polars.from_pandas(
results.to_dataframe(
"evaluations", select=["variables", "evaluation_ids"]
).reset_index()
).select(
"result_id",
"batch_id",
"variable",
"realization",
Expand Down Expand Up @@ -558,7 +550,6 @@ def _store_function_results(self, results: FunctionResults) -> _EvaluationResult
realization_objectives = realization_objectives.pivot(
values="objective_value",
index=[
"result_id",
"batch_id",
"realization",
"simulation_id",
Expand All @@ -579,7 +570,6 @@ def _store_gradient_results(self, results: GradientResults) -> _GradientResults:
results.to_dataframe("evaluations").reset_index()
).select(
[
"result_id",
"batch_id",
"variable",
"realization",
Expand All @@ -603,7 +593,6 @@ def _store_gradient_results(self, results: GradientResults) -> _GradientResults:
results.to_dataframe("gradients").reset_index()
).select(
[
"result_id",
"batch_id",
"variable",
"objective",
Expand All @@ -626,7 +615,6 @@ def _store_gradient_results(self, results: GradientResults) -> _GradientResults:
if results.evaluations.perturbed_constraints is not None:
perturbation_constraints = (
perturbation_objectives[
"result_id",
"batch_id",
"realization",
"perturbation",
Expand All @@ -644,7 +632,6 @@ def _store_gradient_results(self, results: GradientResults) -> _GradientResults:

if batch_objective_gradient is not None:
batch_constraint_gradient = batch_objective_gradient[
"result_id",
"batch_id",
"control_name",
*[
Expand Down Expand Up @@ -827,7 +814,6 @@ def find_best_batch(
batch = matching_batches[0]
controls_dict = batch.realization_controls.drop(
[
"result_id",
"batch_id",
"simulation_id",
"realization",
Expand Down

0 comments on commit 6bef204

Please sign in to comment.