Skip to content

Commit

Permalink
Migrate v5 storages again
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Apr 26, 2024
1 parent 46397f3 commit 22a7131
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ert/storage/local_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def _migrate(self, ignore_migration_check: bool) -> None:
ert_kind,
experiment_id,
gen_kw,
metadata,
observations,
response_info,
update_params,
Expand Down Expand Up @@ -347,6 +348,11 @@ def _migrate(self, ignore_migration_check: bool) -> None:
update_params.migrate(self.path)
empty_summary.migrate(self.path)
self._add_migration_information(4, "experiment_id")
elif version == 5:
# Should usually not need to migrate here, but
# there was a bug on a stable release, which left
# some storage partially migrated
metadata.migrate(self.path)
except Exception as err: # pylint: disable=broad-exception-caught
logger.error(f"Migrating storage at {self.path} failed with {err}")

Expand Down
14 changes: 14 additions & 0 deletions src/ert/storage/migration/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from __future__ import annotations

import json
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pathlib import Path


def migrate(path: Path) -> None:
for experiment in path.glob("experiments/*"):
if not (experiment / "metadata.json").exists():
with open(experiment / "metadata.json", "w", encoding="utf-8") as fout:
fout.write(json.dumps({}))

0 comments on commit 22a7131

Please sign in to comment.