Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions src/antares/study/version/upgrade_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@ def __call__(self) -> None:
try:
# Perform the upgrade
for meth in self.upgrade_methods:
meth.upgrade(self.study_dir)
meth.upgrade(tmp_path)

# Update the 'study.antares' file
self.study_antares.version = self.version
self.study_antares.to_ini_file(self.study_dir)
self.study_antares.to_ini_file(tmp_path)

except Exception:
# If an error occurs, restore the original files
self._safely_replace_original_files(files_to_retrieve, tmp_path)
# If an error occurs, removes the tmp_path
shutil.rmtree(tmp_path)
raise

else:
# Everything went well, replace the original files with the upgraded ones
self._safely_replace_original_files(files_to_retrieve, tmp_path)

def _copies_only_necessary_files(self, files_to_upgrade: t.Collection[str], tmp_path: Path) -> list[str]:
"""
Copies files concerned by the version upgrader into a temporary directory.
Expand Down
1 change: 0 additions & 1 deletion src/antares/study/version/upgrade_app/upgrader_0900.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class UpgradeTo0900(UpgradeMethod):

old = StudyVersion(8, 8)
new = StudyVersion(9, 0)
files = ["study.antares"]

@classmethod
def upgrade(cls, study_dir: Path) -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/antares/study/version/upgrade_app/upgrader_0903.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from antares.study.version.model.study_version import StudyVersion

from .upgrade_method import UpgradeMethod
from ..model.general_data import GeneralData
from ..model.general_data import GeneralData, GENERAL_DATA_PATH


def upgrade_thematic_trimming(data: GeneralData) -> None:
Expand Down Expand Up @@ -75,6 +75,7 @@ class UpgradeTo0903(UpgradeMethod):

old = StudyVersion(9, 2)
new = StudyVersion(9, 3)
files = [GENERAL_DATA_PATH]

@staticmethod
def _upgrade_general_data(study_dir: Path) -> None:
Expand Down