From c6abd001eebbf7f3cf6f49ce27e718f2d758a633 Mon Sep 17 00:00:00 2001 From: belthlemar Date: Tue, 21 Jan 2025 17:16:05 +0100 Subject: [PATCH] fix update link code --- .../storage/variantstudy/model/command/update_link.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/antarest/study/storage/variantstudy/model/command/update_link.py b/antarest/study/storage/variantstudy/model/command/update_link.py index bda512b264..41cc5473ac 100644 --- a/antarest/study/storage/variantstudy/model/command/update_link.py +++ b/antarest/study/storage/variantstudy/model/command/update_link.py @@ -14,8 +14,8 @@ from typing_extensions import override from antarest.core.utils.fastapi_sqlalchemy import db -from antarest.study.business.model.link_model import LinkInternal, LinkTsGeneration -from antarest.study.model import LinksParametersTsGeneration +from antarest.study.business.model.link_model import Area, LinkInternal, LinkTsGeneration +from antarest.study.model import STUDY_VERSION_8_2, LinksParametersTsGeneration from antarest.study.storage.rawstudy.model.filesystem.config.model import FileStudyTreeConfig from antarest.study.storage.rawstudy.model.filesystem.factory import FileStudy from antarest.study.storage.variantstudy.model.command.common import CommandName, CommandOutput @@ -55,7 +55,10 @@ def _apply(self, study_data: FileStudy, listener: t.Optional[ICommandListener] = internal_link = LinkInternal.model_validate(self.parameters) # Updates ini properties - new_ini_properties = internal_link.model_dump(include=self.parameters, by_alias=True) + to_exclude = set(Area.model_fields.keys() & LinkTsGeneration.model_fields.keys()) + if version < STUDY_VERSION_8_2: + to_exclude.update("filter-synthesis", "filter-year-by-year") + new_ini_properties = internal_link.model_dump(by_alias=True, exclude=to_exclude) properties.update(new_ini_properties) study_data.tree.save(properties, ["input", "links", self.area1, "properties", self.area2])