Skip to content

Commit

Permalink
Ensure gen_data is migrated properly
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Oct 25, 2024
1 parent 7ef9667 commit 7079028
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/ert/storage/migration/to7.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ def _migrate_response_datasets(path: Path) -> None:
responses_obj is not None
), f"Failed to load responses.json @ {responses_file}"

gendata_keys = {
k for k, v in responses_obj.items() if v["_ert_kind"] == "GenDataConfig"
}
gendata_keys = responses_obj.get("gen_data", {}).get("keys", [])

for ens in ensembles:
with open(ens / "index.json", encoding="utf-8") as f:
Expand Down Expand Up @@ -255,7 +253,7 @@ def _migrate_responses_from_netcdf_to_parquet(path: Path) -> None:


def migrate(path: Path) -> None:
_migrate_response_datasets(path)
_migrate_response_configs(path)
_migrate_response_datasets(path)
_migrate_responses_from_netcdf_to_parquet(path)
_migrate_observations_to_grouped_parquet(path)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
realization,response_key,report_step,index,values
0,GEN,1,0,0.0
0,GEN,1,1,0.1
1,GEN,1,0,0.0
1,GEN,1,1,0.1
2,GEN,1,0,0.0
2,GEN,1,1,0.1
3,GEN,1,0,0.0
3,GEN,1,1,0.1
4,GEN,1,0,0.0
4,GEN,1,1,0.1
5,GEN,1,0,0.0
5,GEN,1,1,0.1
6,GEN,1,0,0.0
6,GEN,1,1,0.1
7,GEN,1,0,0.0
7,GEN,1,1,0.1
8,GEN,1,0,0.0
8,GEN,1,1,0.1
9,GEN,1,0,0.0
9,GEN,1,1,0.1
14 changes: 10 additions & 4 deletions tests/ert/unit_tests/storage/test_storage_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,16 @@ def test_that_storage_matches(
"observations",
)

try:
ensemble.load_responses("gen_data", tuple(range(ensemble.ensemble_size)))
except KeyError as e:
raise AssertionError("Failed to migrate gen data") from e
gen_data = ensemble.load_responses(
"gen_data", tuple(range(ensemble.ensemble_size))
)
snapshot.assert_match(
gen_data.sort(["realization", "response_key", "report_step", "index"])
.to_pandas()
.set_index(["realization", "response_key", "report_step", "index"])
.to_csv(),
"gen_data",
)

assert ensemble.get_summary_keyset() == ["FOPR"]

Expand Down

0 comments on commit 7079028

Please sign in to comment.