Skip to content

Commit

Permalink
fix(api): add missing denormalized rules in refactor export_study_flat (
Browse files Browse the repository at this point in the history
  • Loading branch information
TLAIDI authored and laurent-laporte-pro committed Sep 12, 2023
1 parent 73ebae0 commit ed3f6bf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions antarest/study/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ def export_study_flat(
try:
return export_study_flat(
path_study=path_study,
study_factory=study,
dest=dest,
outputs=len(output_list or []) > 0,
output_list_filter=output_list,
Expand All @@ -1050,6 +1051,7 @@ def export_study_flat(
output_src_path = path_study / "output"
export_study_flat(
path_study=snapshot_path,
study_factory=study,
dest=dest,
outputs=len(output_list or []) > 0,
output_list_filter=output_list,
Expand Down
12 changes: 11 additions & 1 deletion antarest/study/storage/abstract_storage_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
def export_study_flat(
path_study: Path,
dest: Path,
study_factory: StudyFactory,
outputs: bool = True,
output_list_filter: Optional[List[str]] = None,
output_src_path: Optional[Path] = None,
Expand All @@ -49,6 +50,7 @@ def export_study_flat(
Args:
path_study: Study source path
dest: Destination path.
study_factory: StudyFactory,
outputs: List of outputs to keep.
output_list_filter: List of outputs to keep (None indicate all outputs).
output_src_path: Denormalize the study (replace matrix links by real matrices).
Expand Down Expand Up @@ -89,6 +91,11 @@ def export_study_flat(
duration = "{:.3f}".format(stop_time - start_time)
logger.info(f"Study {path_study} exported (flat mode) in {duration}s")

study = study_factory.create_from_fs(dest, "", use_cache=False)
study.tree.denormalize()
duration = "{:.3f}".format(time.time() - stop_time)
logger.info(f"Study {path_study} denormalized in {duration}s")


class AbstractStorageService(IStudyStorageService[T], ABC):
def __init__(
Expand Down Expand Up @@ -293,11 +300,14 @@ def export_study(self, metadata: T, target: Path, outputs: bool = True) -> Path:
output_src_path = path_study / "output"
export_study_flat(
path_study=snapshot_path,
study_factory=self.study_factory,
dest=tmp_study_path,
outputs=outputs,
output_src_path=output_src_path,
)
export_study_flat(path_study, tmp_study_path, outputs)
export_study_flat(
path_study, tmp_study_path, self.study_factory, outputs
)
stopwatch = StopWatch()
zip_dir(tmp_study_path, target)
stopwatch.log_elapsed(lambda x: logger.info(f"Study {path_study} exported (zipped mode) in {x}s"))
Expand Down
2 changes: 2 additions & 0 deletions antarest/study/storage/variantstudy/variant_study_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ def _generate(
export_study_flat(
snapshot_path,
dst_path,
parent_study,
outputs=False,
output_src_path=output_src_path,
)
Expand All @@ -737,6 +738,7 @@ def _generate(
export_study_flat(
path_study=path_study,
dest=dst_path,
study_factory=parent_study,
outputs=False,
)
finally:
Expand Down

0 comments on commit ed3f6bf

Please sign in to comment.