From f2afc373fa1eafcda5631b6c8de59fc774fbb29d Mon Sep 17 00:00:00 2001 From: TLAIDI Date: Thu, 27 Jul 2023 19:33:31 +0200 Subject: [PATCH] fix(api): add missing denormalized rules in refactor export_study_flat (#1646) --- antarest/study/service.py | 2 ++ antarest/study/storage/abstract_storage_service.py | 12 +++++++++++- .../storage/variantstudy/variant_study_service.py | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/antarest/study/service.py b/antarest/study/service.py index d09a169c6a..44d82cd551 100644 --- a/antarest/study/service.py +++ b/antarest/study/service.py @@ -1224,6 +1224,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, @@ -1235,6 +1236,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, diff --git a/antarest/study/storage/abstract_storage_service.py b/antarest/study/storage/abstract_storage_service.py index 7fd85d52a5..7be294fd1d 100644 --- a/antarest/study/storage/abstract_storage_service.py +++ b/antarest/study/storage/abstract_storage_service.py @@ -57,6 +57,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, @@ -67,6 +68,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). @@ -107,6 +109,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__( @@ -336,11 +343,14 @@ def export_study( 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( diff --git a/antarest/study/storage/variantstudy/variant_study_service.py b/antarest/study/storage/variantstudy/variant_study_service.py index 9d8ea14dfe..c32119c56f 100644 --- a/antarest/study/storage/variantstudy/variant_study_service.py +++ b/antarest/study/storage/variantstudy/variant_study_service.py @@ -846,6 +846,7 @@ def _generate( export_study_flat( snapshot_path, dst_path, + parent_study, outputs=False, output_src_path=output_src_path, ) @@ -857,6 +858,7 @@ def _generate( export_study_flat( path_study=path_study, dest=dst_path, + study_factory=parent_study, outputs=False, ) finally: