Skip to content

Commit

Permalink
fix(archive-outputs): correct code errors and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mabw-rte committed Oct 24, 2024
1 parent 4a9cf5f commit fc6ba45
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
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 @@ -263,7 +263,7 @@ def import_output(
stopwatch.log_elapsed(lambda elapsed_time: logger.info(f"Copied output for {study_id} in {elapsed_time}s"))
fix_study_root(path_output)
output_full_name = extract_output_name(path_output, output_name)
extension = f"{ArchiveFormat.ZIP}" if is_zipped else ""
extension = f"{ArchiveFormat.SEVEN_ZIP}" if is_archived else ""
path_output = path_output.rename(Path(path_output.parent, output_full_name + extension))

data = self.get(metadata, f"output/{output_full_name}", 1, use_cache=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@

from antarest.core.model import JSON
from antarest.core.serialization import from_json
from antarest.core.utils.archives import (
extract_lines_from_archive,
is_archive_format,
read_file_from_archive,
)
from antarest.core.utils.archives import extract_lines_from_archive, is_archive_format, read_file_from_archive
from antarest.study.model import STUDY_VERSION_8_1, STUDY_VERSION_8_6
from antarest.study.storage.rawstudy.ini_reader import IniReader
from antarest.study.storage.rawstudy.model.filesystem.config.binding_constraint import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def __init__(
def next_file(self, name: str, is_output: bool = False) -> "FileStudyTreeConfig":
if is_output and name in self.outputs and self.outputs[name].archived:
locations = [self.path / f"{name}.7z", self.path / f"{name}.zip"]
archive_path = next((p for p in locations if p.exists()))
archive_path: t.Optional[Path] = next((p for p in locations if p.exists()))
else:
archive_path = self.archive_path

Expand Down
2 changes: 1 addition & 1 deletion antarest/study/storage/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def extract_output_name(path_output: Path, new_suffix_name: t.Optional[str] = No
if new_suffix_name:
suffix_name = new_suffix_name
general_info["name"] = suffix_name
if not archived:
if not is_output_archived:
ini_writer = IniWriter()
ini_writer.write(info_antares_output, path_output / info_filename)
else:
Expand Down
1 change: 1 addition & 0 deletions tests/core/utils/test_extract_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from antarest.core.exceptions import BadArchiveContent
from antarest.core.utils.archives import extract_archive


class TestExtractArchive:
"""
Test the `extract_zip` function.
Expand Down

0 comments on commit fc6ba45

Please sign in to comment.