Skip to content

Commit

Permalink
fix(export): allow export for zipped outputs (#2253)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle authored Nov 28, 2024
1 parent 0054f6c commit 45e356a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion antarest/study/storage/abstract_storage_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def export_output(self, metadata: T, output_id: str, target: Path) -> None:
logger.info(f"Exporting output {output_id} from study {metadata.id}")

path_output = Path(metadata.path) / "output" / output_id
path_output_zip = Path(metadata.path) / "output" / f"{output_id}.{ArchiveFormat.ZIP}"
path_output_zip = Path(metadata.path) / "output" / f"{output_id}{ArchiveFormat.ZIP}"

if path_output_zip.exists():
shutil.copyfile(path_output_zip, target)
Expand Down
7 changes: 7 additions & 0 deletions tests/storage/business/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from py7zr import SevenZipFile

from antarest.core.config import Config, StorageConfig
from antarest.core.utils.archives import ArchiveFormat, archive_dir
from antarest.study.model import DEFAULT_WORKSPACE_NAME, RawStudy
from antarest.study.storage.rawstudy.raw_study_service import RawStudyService

Expand Down Expand Up @@ -162,3 +163,9 @@ def test_export_output(tmp_path: Path):
zipf = ZipFile(export_path)

assert "file_output.txt" in zipf.namelist()

# asserts exporting a zipped output doesn't raise an error
output_path = root / "output" / output_id
target_path = root / "output" / f"{output_id}.zip"
archive_dir(output_path, target_path, True, ArchiveFormat.ZIP)
study_service.export_output(study, output_id, export_path)

0 comments on commit 45e356a

Please sign in to comment.