Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions modelon/impact/client/entities/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions modelon/impact/client/sal/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down