Skip to content

Commit

Permalink
[Pb Gen] deal with last study not being a zip (#756)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Maréchal <[email protected]>
  • Loading branch information
a-zakir and JasonMarechal25 authored Feb 22, 2024
1 parent d0df707 commit 7eb996e
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 7eb996e

Please sign in to comment.