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 committed Aug 1, 2023
1 parent 38f61eb commit 8d4dd66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 42 deletions.
27 changes: 0 additions & 27 deletions antarest/study/common/studystorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,30 +271,3 @@ 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()
33 changes: 18 additions & 15 deletions antarest/study/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,15 +1091,15 @@ def export_study(
def export_task(notifier: TaskUpdateNotifier) -> TaskResult:
try:
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:
self.storage_service.get_storage(
target_study
).unarchive(target_study)
storage.unarchive(target_study)
try:
self.storage_service.get_storage(
target_study
).export_study(target_study, export_path, outputs)
storage.export_study(
target_study, export_path, outputs
)
finally:
if target_study.archived:
shutil.rmtree(target_study.path)
Expand Down Expand Up @@ -1220,6 +1220,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 @@ -1233,15 +1234,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
Expand Down

0 comments on commit 8d4dd66

Please sign in to comment.