Skip to content

Commit

Permalink
fix(api): remove methods: (unarchive, export_study_flat) from studyst…
Browse files Browse the repository at this point in the history
…orage.py (#1646)
  • Loading branch information
TLAIDI authored and laurent-laporte-pro committed Sep 12, 2023
1 parent 2ef5bac commit 02c7f67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 36 deletions.
27 changes: 0 additions & 27 deletions antarest/study/common/studystorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,30 +253,3 @@ def archive_study_output(self, study: T, output_id: str) -> bool:
@abstractmethod
def unarchive_study_output(self, study: T, output_id: str, keep_src_zip: bool) -> bool:
raise NotImplementedError()

def unarchive(self, study: T) -> None:
"""
Unarchived a study
Args:
study: StudyFactory
"""
raise NotImplementedError()

def export_study_flat(
self,
path_study: Path,
dst_path: Path,
outputs: bool = True,
output_src_path: Optional[Path] = None,
output_list_filter: Optional[List[str]] = None,
) -> None:
"""
Export study to destination
Args:
path_study: source path.
dst_path: destination path.
outputs: list of outputs to keep.
output_src_path: list output path
output_list_filter:list of outputs to keep
"""
raise NotImplementedError()
22 changes: 13 additions & 9 deletions antarest/study/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ def export_task(notifier: TaskUpdateNotifier) -> TaskResult:
target_study = self.get_study(uuid)
storage = self.storage_service.get_storage(target_study)
if isinstance(target_study, RawStudy):
storage = cast(RawStudyService, storage)
if target_study.archived:
storage.unarchive(target_study)
try:
Expand Down Expand Up @@ -1035,6 +1036,7 @@ def export_study_flat(
path_study = Path(study.path)
storage = self.storage_service.get_storage(study)
if isinstance(study, RawStudy):
storage = cast(RawStudyService, storage)
if study.archived:
storage.unarchive(study)
try:
Expand All @@ -1048,15 +1050,17 @@ def export_study_flat(
finally:
if study.archived:
shutil.rmtree(study.path)
snapshot_path = path_study / "snapshot"
output_src_path = path_study / "output"
return storage.export_study_flat(
path_study=snapshot_path,
dst_path=dest,
outputs=len(output_list or []) > 0,
output_list_filter=output_list,
output_src_path=output_src_path,
)
else:
snapshot_path = path_study / "snapshot"
output_src_path = path_study / "output"
storage = cast(VariantStudyService, storage)
return storage.export_study_flat(
path_study=snapshot_path,
dst_path=dest,
outputs=len(output_list or []) > 0,
output_list_filter=output_list,
output_src_path=output_src_path,
)

def delete_study(self, uuid: str, children: bool, params: RequestParameters) -> None:
"""
Expand Down

0 comments on commit 02c7f67

Please sign in to comment.