Skip to content

Commit

Permalink
deal with last study not being a zip
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Feb 13, 2024
1 parent b195dd8 commit 1e07018
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/python/antares_xpansion/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,27 @@ class NotAnXpansionOutputDir(Exception):


def _set_xpansion_simulation_name(self):
xpansion_dir_suffix ="-Xpansion"
if self.step() in ["resume", "sensitivity"] :
self._xpansion_simulation_name = self._last_study
if self.is_zip(self._last_study):
self._xpansion_simulation_name = self._last_study.parent / self._last_study.stem
with zipfile.ZipFile(self._last_study, 'r') as output_zip:
output_zip.extractall(self._xpansion_simulation_name)
elif self.step() == "benders":
if(not self._last_study.name.endswith("-Xpansion")):
if(not self._last_study.name.endswith(xpansion_dir_suffix)):
raise ConfigLoader.NotAnXpansionOutputDir(f"Error! {self._last_study} is not an Xpansion output directory")
self._xpansion_simulation_name = self._last_study


elif self.step() == "problem_generation":
if not self.is_zip(self._last_study):
if(not self._last_study.name.endswith(xpansion_dir_suffix)):
raise ConfigLoader.NotAnXpansionOutputDir(f"Error! {self._last_study} is not an Xpansion output directory")
else:
self._xpansion_simulation_name = self._last_study
self._last_study =self._last_study.parent / (self._last_study.stem[:-len(xpansion_dir_suffix)]+".zip")


else:
self._xpansion_simulation_name = self._last_study.parent / \
(self._last_study.stem+"-Xpansion")
Expand Down

0 comments on commit 1e07018

Please sign in to comment.