-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d81eda0
commit ece5f0e
Showing
5 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
antarest/study/storage/variantstudy/model/command/update_link.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright (c) 2024, RTE (https://www.rte-france.com) | ||
# | ||
# See AUTHORS.txt | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
# | ||
# This file is part of the Antares project. | ||
import typing as t | ||
|
||
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 CommandOutput, CommandName | ||
|
||
from antarest.study.storage.variantstudy.model.command.icommand import ICommand, OutputTuple, MATCH_SIGNATURE_SEPARATOR | ||
from antarest.study.storage.variantstudy.model.model import CommandDTO | ||
|
||
|
||
class UpdateLink(ICommand): | ||
""" | ||
Command used to create a link between two areas. | ||
""" | ||
|
||
# Overloaded metadata | ||
# =================== | ||
|
||
command_name: CommandName = CommandName.UPDATE_LINK | ||
version: int = 1 | ||
|
||
# Command parameters | ||
# ================== | ||
area1: str | ||
area2: str | ||
parameters: t.Optional[t.Dict[str, t.Any]] = None | ||
|
||
def _apply_config(self, study_data: FileStudyTreeConfig) -> OutputTuple: | ||
area_from, area_to = sorted([self.area1, self.area2]) | ||
|
||
return ( | ||
CommandOutput( | ||
status=True, | ||
message=f"Link between '{self.area1}' and '{self.area2}' updated", | ||
), | ||
{"area_from": area_from, "area_to": area_to}, | ||
) | ||
|
||
def _apply(self, study_data: FileStudy) -> CommandOutput: | ||
area_from, area_to = sorted([self.area1, self.area2]) | ||
study_data.tree.save(self.parameters, ["input", "links", area_from, "properties", area_to]) | ||
output, _ = self._apply_config(study_data.config) | ||
return output | ||
|
||
def to_dto(self) -> CommandDTO: | ||
args = { | ||
"area1": self.area1, | ||
"area2": self.area2, | ||
"parameters": self.parameters, | ||
} | ||
return CommandDTO( | ||
action=CommandName.UPDATE_LINK.value, | ||
args=args, | ||
) | ||
|
||
def match_signature(self) -> str: | ||
return str(self.command_name.value + MATCH_SIGNATURE_SEPARATOR + self.area1 + MATCH_SIGNATURE_SEPARATOR + self.area2) | ||
|
||
def _create_diff(self, other: "ICommand") -> t.List["ICommand"]: | ||
pass | ||
|
||
def get_inner_matrices(self) -> t.List[str]: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters