Skip to content

Commit 9d66032

Browse files
fix(upgrader): issue with v9.3 and in general (#49)
1 parent 29ebc84 commit 9d66032

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/antares/study/version/upgrade_app/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,21 @@ def __call__(self) -> None:
115115
try:
116116
# Perform the upgrade
117117
for meth in self.upgrade_methods:
118-
meth.upgrade(self.study_dir)
118+
meth.upgrade(tmp_path)
119119

120120
# Update the 'study.antares' file
121121
self.study_antares.version = self.version
122-
self.study_antares.to_ini_file(self.study_dir)
122+
self.study_antares.to_ini_file(tmp_path)
123123

124124
except Exception:
125-
# If an error occurs, restore the original files
126-
self._safely_replace_original_files(files_to_retrieve, tmp_path)
125+
# If an error occurs, removes the tmp_path
126+
shutil.rmtree(tmp_path)
127127
raise
128128

129+
else:
130+
# Everything went well, replace the original files with the upgraded ones
131+
self._safely_replace_original_files(files_to_retrieve, tmp_path)
132+
129133
def _copies_only_necessary_files(self, files_to_upgrade: t.Collection[str], tmp_path: Path) -> list[str]:
130134
"""
131135
Copies files concerned by the version upgrader into a temporary directory.

src/antares/study/version/upgrade_app/upgrader_0900.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class UpgradeTo0900(UpgradeMethod):
1212

1313
old = StudyVersion(8, 8)
1414
new = StudyVersion(9, 0)
15-
files = ["study.antares"]
1615

1716
@classmethod
1817
def upgrade(cls, study_dir: Path) -> None:

src/antares/study/version/upgrade_app/upgrader_0903.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from antares.study.version.model.study_version import StudyVersion
44

55
from .upgrade_method import UpgradeMethod
6-
from ..model.general_data import GeneralData
6+
from ..model.general_data import GeneralData, GENERAL_DATA_PATH
77

88

99
def upgrade_thematic_trimming(data: GeneralData) -> None:
@@ -75,6 +75,7 @@ class UpgradeTo0903(UpgradeMethod):
7575

7676
old = StudyVersion(9, 2)
7777
new = StudyVersion(9, 3)
78+
files = [GENERAL_DATA_PATH]
7879

7980
@staticmethod
8081
def _upgrade_general_data(study_dir: Path) -> None:

0 commit comments

Comments
 (0)