Skip to content

Commit

Permalink
fix Pbm generation to work with plain dir or zipped archive
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Aug 24, 2023
1 parent a2a43d6 commit 6932230
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/python/antares_xpansion/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def _set_last_simulation_name(self):
"""
return last simulation name
"""
self._last_study = self.last_modified_study(self.antares_output())
self._last_study = self.last_modified_study(Path(self.antares_output()))

self._set_xpansion_simulation_name()

Expand All @@ -527,14 +527,14 @@ def update_last_study_with_sensitivity_results(self):
if(os.path.exists(self._xpansion_simulation_name)):
shutil.rmtree(self._xpansion_simulation_name)

def is_antares_study_output(self, study):
def is_antares_study_output(self, study: Path):
_, ext = os.path.splitext(study)
return ext == ".zip" or os.path.isdir(study)
return ext == ".zip" or os.path.isdir(study) and '-Xpansion' not in study.name

def last_modified_study(self, root_dir)-> Path:
def last_modified_study(self, root_dir:Path)-> Path:
list_dir = os.listdir(root_dir)
list_of_studies = filter(
lambda x: self.is_antares_study_output(os.path.join(root_dir, x)), list_dir
lambda x: self.is_antares_study_output(root_dir / x), list_dir
)
# Sort list of files based on last modification time in ascending order
sort_studies = sorted(
Expand Down

0 comments on commit 6932230

Please sign in to comment.