Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/1646 refactoring request for study function #1669

Merged
merged 13 commits into from
Jul 26, 2023
Merged
Prev Previous commit
Next Next commit
Refactor(export): clean code by removing comments and duplicate code
TLAIDI committed Jul 21, 2023
commit 10e08cd879afae4e9566f45e209de16c3d04e461
13 changes: 0 additions & 13 deletions antarest/study/service.py
Original file line number Diff line number Diff line change
@@ -1090,19 +1090,6 @@ def export_study(
def export_task(notifier: TaskUpdateNotifier) -> TaskResult:
try:
target_study = self.get_study(uuid)
# if study.type == 'rawstudy':
# path_study = Path(study.path)
# if study.archived:
# self.storage_service.get_storage(study).unarchive(study)
# try:
# return self.storage_service.get_storage(study).export_study_flat(path_study,
# dest,
# len(output_list or []) > 0,
# output_list
# )
# finally:
# if study.archived:
# shutil.rmtree(study.path)
if target_study.type == "ramstudy":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant rawstudy. To avoid this type of confusion, we usually do this in the code :
if isinstance(target_study, RawStudy):

if target_study.archived:
self.storage_service.get_storage(
9 changes: 2 additions & 7 deletions antarest/study/storage/abstract_storage_service.py
Original file line number Diff line number Diff line change
@@ -276,14 +276,9 @@ def export_study(
logger.info(f"Exporting study {metadata.id} to tmp path {tmpdir}")
assert_this(target.name.endswith(".zip"))
tmp_study_path = Path(tmpdir) / "tmp_copy"
if metadata.type == "":
snapshot_path = path_study / ""
if metadata.type != "ramstudy":
snapshot_path = path_study / "snapshot"
output_src_path = path_study / "output"
self.export_study_flat(
snapshot_path,
tmp_study_path,
outputs,
)
self.export_study_flat(
path_study=snapshot_path,
dest=tmp_study_path,