diff --git a/antarest/launcher/adapters/slurm_launcher/slurm_launcher.py b/antarest/launcher/adapters/slurm_launcher/slurm_launcher.py index f6e55a3cdf..c3fac99b15 100644 --- a/antarest/launcher/adapters/slurm_launcher/slurm_launcher.py +++ b/antarest/launcher/adapters/slurm_launcher/slurm_launcher.py @@ -235,7 +235,7 @@ def _import_study_output( # `antarest.launcher.service.LauncherService._import_output` return self.callbacks.import_output( job_id, - self.local_workspace / STUDIES_OUTPUT_DIR_NAME / job_id / "output", + self.local_workspace / STUDIES_OUTPUT_DIR_NAME / job_id, launcher_logs, ) diff --git a/antarest/launcher/service.py b/antarest/launcher/service.py index 25a777ef5a..a3dde31182 100644 --- a/antarest/launcher/service.py +++ b/antarest/launcher/service.py @@ -39,7 +39,7 @@ ) from antarest.launcher.repository import JobResultRepository from antarest.study.service import StudyService -from antarest.study.storage.utils import assert_permission, extract_output_name, find_single_output_path +from antarest.study.storage.utils import assert_permission, extract_output_name, retrieve_output_path logger = logging.getLogger(__name__) @@ -498,7 +498,7 @@ def _import_output( job_launch_params = LauncherParametersDTO.parse_raw(job_result.launcher_params or "{}") # this now can be a zip file instead of a directory ! - output_true_path = find_single_output_path(output_path) + output_true_path = retrieve_output_path(output_path) output_is_zipped = is_zip(output_true_path) output_suffix = cast( Optional[str], diff --git a/antarest/study/storage/utils.py b/antarest/study/storage/utils.py index b8edba14d4..438f685097 100644 --- a/antarest/study/storage/utils.py +++ b/antarest/study/storage/utils.py @@ -114,15 +114,6 @@ def fix_study_root(study_path: Path) -> None: shutil.rmtree(sub_root_path) -def find_single_output_path(all_output_path: Path) -> Path: - children = os.listdir(all_output_path) - if len(children) == 1: - if children[0].endswith(".zip"): - return all_output_path / children[0] - return find_single_output_path(all_output_path / children[0]) - return all_output_path - - def retrieve_output_path(job_path: Path) -> Path: inside_study_output_path = job_path / "output" if job_path.exists() and len([file for file in os.listdir(str(job_path)) if ".zip" in file]) == 1: diff --git a/tests/launcher/test_service.py b/tests/launcher/test_service.py index a8e20283c8..01611ade1d 100644 --- a/tests/launcher/test_service.py +++ b/tests/launcher/test_service.py @@ -757,9 +757,9 @@ def test_manage_output(self, tmp_path: Path) -> None: ), ] with pytest.raises(JobNotFound): - launcher_service._import_output(job_id, output_path, {"out.log": [additional_log]}) + launcher_service._import_output(job_id, tmp_path, {"out.log": [additional_log]}) - launcher_service._import_output(job_id, output_path, {"out.log": [additional_log]}) + launcher_service._import_output(job_id, tmp_path, {"out.log": [additional_log]}) assert not launcher_service._get_job_output_fallback_path(job_id).exists() launcher_service.study_service.import_output.assert_called() @@ -788,10 +788,10 @@ def test_manage_output(self, tmp_path: Path) -> None: StudyNotFoundError(""), ] - assert launcher_service._import_output(job_id, output_path, {"out.log": [additional_log]}) is None + assert launcher_service._import_output(job_id, tmp_path, {"out.log": [additional_log]}) is None (new_output_path / "info.antares-output").write_text(f"[general]\nmode=eco\nname=foo\ntimestamp={time.time()}") - output_name = launcher_service._import_output(job_id, output_path, {"out.log": [additional_log]}) + output_name = launcher_service._import_output(job_id, tmp_path, {"out.log": [additional_log]}) assert output_name is not None assert output_name.endswith("-hello") assert launcher_service._get_job_output_fallback_path(job_id).exists()