From c6662c1b72e6b581921aff2ddd2e4896d2710787 Mon Sep 17 00:00:00 2001 From: abhilash-kumar-nair Date: Thu, 25 Jun 2026 15:58:05 +0530 Subject: [PATCH] feat: add get_experiment_annotations to Model entity --- modelon/impact/client/entities/model.py | 21 +++++++++++++++++++++ modelon/impact/client/sal/modeling.py | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/modelon/impact/client/entities/model.py b/modelon/impact/client/entities/model.py index 6c2efbc5..8a5f2ffe 100644 --- a/modelon/impact/client/entities/model.py +++ b/modelon/impact/client/entities/model.py @@ -534,6 +534,27 @@ def get_extends_clauses(self) -> List[ExtendsClause]: for name in modeling_sal().get_extends_clauses(self._class_name) ] + @Experimental + def get_experiment_annotations(self) -> Dict[str, str]: + """Returns the experiment annotation key-value pairs for this model's class. + + Only keys explicitly set in the model's experiment annotation block are + returned. Keys use the raw Modelica annotation names as they appear in the + source (e.g. ``StartTime``, ``StopTime``, ``Tolerance``, + ``__Dymola_Algorithm``). Returns an empty dict if no experiment keywords + are set. + + Example:: + + with workspace.new_modeling_session() as session: + model = session.get_model("LibA.Model") + annotations = model.get_experiment_annotations() + # e.g. {"StartTime": "0", "StopTime": "10", "Tolerance": "1e-6"} + + """ + modeling_sal = self._require_modeling_session("get_experiment_annotations") + return modeling_sal().get_experiment_annotations(self._class_name) + @classmethod def from_operation(cls, operation: BaseOperation[Model], **kwargs: Any) -> Model: assert isinstance(operation, FMUImportOperation) diff --git a/modelon/impact/client/sal/modeling.py b/modelon/impact/client/sal/modeling.py index 439e9c08..49640a89 100644 --- a/modelon/impact/client/sal/modeling.py +++ b/modelon/impact/client/sal/modeling.py @@ -24,6 +24,12 @@ def get_model_parameters(self, modelica_path: str) -> List[str]: def get_extends_clauses(self, class_path: str) -> List[str]: return self._ws_client.get_json_response("impact/getExtends", class_path) + def get_experiment_annotations(self, class_path: str) -> Dict[str, str]: + params = {"className": class_path} + return self._ws_client.get_json_response( + "impact/getExperimentAnnotation", params + ) + def get_model_source(self, class_path: str) -> str: params = {"className": class_path} return self._ws_client.get_json_response("impact/getSource", params)