Skip to content

Commit

Permalink
refactor(service): simplify implementation of retrieve_output_path
Browse files Browse the repository at this point in the history
…function
  • Loading branch information
laurent-laporte-pro committed Dec 19, 2023
1 parent 9e98ea3 commit 8d966b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions antarest/launcher/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,9 @@ def _import_output(
study_id = job_result.study_id
job_launch_params = LauncherParametersDTO.parse_raw(job_result.launcher_params or "{}")

# this now can be a zip file instead of a directory !
# this now can be a zip file instead of a directory!
output_true_path = retrieve_output_path(output_path)
output_is_zipped = is_zip(output_true_path)
output_is_zipped = output_true_path.suffix.lower() == ".zip"
output_suffix = cast(
Optional[str],
getattr(
Expand Down
13 changes: 8 additions & 5 deletions antarest/study/storage/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,17 @@ def fix_study_root(study_path: Path) -> None:


def retrieve_output_path(job_path: Path) -> Path:
inside_study_output_path = job_path / "output"
output_already_zipped_path = job_path.with_suffix(".zip")
if output_already_zipped_path.exists():
return output_already_zipped_path
elif inside_study_output_path.exists() and len(os.listdir(inside_study_output_path)) == 1:
return inside_study_output_path / os.listdir(str(inside_study_output_path))[0]
else:
return Path()

output_inside_study = job_path / "output"
if output_inside_study.is_dir():
output_folders = os.listdir(output_inside_study)
if len(output_folders) == 1:
return output_inside_study / output_folders[0]

return Path()


def extract_output_name(path_output: Path, new_suffix_name: t.Optional[str] = None) -> str:
Expand Down

0 comments on commit 8d966b9

Please sign in to comment.