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 committed Jul 27, 2023
1 parent b85bfdc commit f2afc37
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 @@ -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,
Expand All @@ -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,
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 @@ -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,
Expand All @@ -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).
Expand Down Expand Up @@ -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__(
Expand Down Expand Up @@ -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(
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 @@ -846,6 +846,7 @@ def _generate(
export_study_flat(
snapshot_path,
dst_path,
parent_study,
outputs=False,
output_src_path=output_src_path,
)
Expand All @@ -857,6 +858,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 f2afc37

Please sign in to comment.