Skip to content

Commit f2ecc3a

Browse files
authored
F002 - rename classes (#468)
* rename classes * ModelExecutionData => ModelExecutionRun * ModelExecutionCmd => ModelExecutionConfig * update of docstrings for ModelExecutionRun and ModelExecutionConfig
1 parent 20ec8c4 commit f2ecc3a

6 files changed

Lines changed: 28 additions & 28 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import numpy as np
1313

1414
from OMPython.model_execution import (
15-
ModelExecutionCmd,
15+
ModelExecutionConfig,
1616
ModelExecutionException,
1717
)
1818
from OMPython.om_session_omc import (
@@ -176,7 +176,7 @@ class ModelicaSystemDoE(ModelicaDoEOMC):
176176
"""
177177

178178

179-
class ModelicaSystemCmd(ModelExecutionCmd):
179+
class ModelicaSystemCmd(ModelExecutionConfig):
180180
"""
181181
Compatibility class; in the new version it is renamed as ModelExecutionCmd.
182182
"""

OMPython/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"""
1313

1414
from OMPython.model_execution import (
15-
ModelExecutionCmd,
16-
ModelExecutionData,
15+
ModelExecutionConfig,
16+
ModelExecutionRun,
1717
ModelExecutionException,
1818
)
1919
from OMPython.om_session_abc import (
@@ -81,8 +81,8 @@
8181

8282
'LinearizationResult',
8383

84-
'ModelExecutionCmd',
85-
'ModelExecutionData',
84+
'ModelExecutionConfig',
85+
'ModelExecutionRun',
8686
'ModelExecutionException',
8787

8888
'ModelicaDoEABC',

OMPython/model_execution.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ class ModelExecutionException(Exception):
2727

2828

2929
@dataclasses.dataclass
30-
class ModelExecutionData:
30+
class ModelExecutionRun:
3131
"""
32-
Data class to store the command line data for running a model executable in the OMC environment.
32+
Data class to store the command line data for running a model executable. This definition is independent of the OMC
33+
environment as only the executable is needed.
3334
34-
All data should be defined for the environment, where OMC is running (local, docker or WSL)
35-
36-
To use this as a definition of an OMC simulation run, it has to be processed within
37-
OMCProcess*.self_update(). This defines the attribute cmd_model_executable.
35+
All data should be defined for the environment, where the executable was defined / is located. This is especially
36+
important if OMPython and the executable are defined in different environments (docker or WSL).
3837
"""
3938
# cmd_path is the expected working directory
4039
cmd_path: str
@@ -105,11 +104,12 @@ def run(self) -> int:
105104
return returncode
106105

107106

108-
class ModelExecutionCmd:
107+
class ModelExecutionConfig:
109108
"""
110-
All information about a compiled model executable. This should include data about all structured parameters, i.e.
111-
parameters which need a recompilation of the model. All non-structured parameters can be easily changed without
112-
the need for recompilation.
109+
This class collects all information about a compiled model executable. This includes data about all structured
110+
parameters, i.e. parameters which need a recompilation of the model. All non-structured parameters can be easily
111+
changed without the need for recompilation. The final result is an instance of class ModelExecutionRun - a
112+
definition to run one simulation based on the compiled model executable.
113113
"""
114114

115115
def __init__(
@@ -261,7 +261,7 @@ def get_cmd_args(self) -> list[str]:
261261

262262
return cmdl
263263

264-
def definition(self) -> ModelExecutionData:
264+
def definition(self) -> ModelExecutionRun:
265265
"""
266266
Define all needed data to run the model executable. The data is stored in an OMCSessionRunData object.
267267
"""
@@ -301,7 +301,7 @@ def definition(self) -> ModelExecutionData:
301301
if self._cmd_local:
302302
cmd_cwd_local = cmd_path.as_posix()
303303

304-
omc_run_data = ModelExecutionData(
304+
omc_run_data = ModelExecutionRun(
305305
cmd_path=cmd_path.as_posix(),
306306
cmd_model_name=self._model_name,
307307
cmd_args=self.get_cmd_args(),

OMPython/modelica_doe_abc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from typing import Any, cast, Optional, Tuple
1414

1515
from OMPython.model_execution import (
16-
ModelExecutionData,
16+
ModelExecutionRun,
1717
)
1818
from OMPython.om_session_abc import (
1919
OMPathABC,
@@ -138,7 +138,7 @@ def __init__(
138138
self._parameters = {}
139139

140140
self._doe_def: Optional[dict[str, dict[str, Any]]] = None
141-
self._doe_cmd: Optional[dict[str, ModelExecutionData]] = None
141+
self._doe_cmd: Optional[dict[str, ModelExecutionRun]] = None
142142

143143
def get_session(self) -> OMSessionABC:
144144
"""
@@ -255,7 +255,7 @@ def get_doe_definition(self) -> Optional[dict[str, dict[str, Any]]]:
255255
"""
256256
return self._doe_def
257257

258-
def get_doe_command(self) -> Optional[dict[str, ModelExecutionData]]:
258+
def get_doe_command(self) -> Optional[dict[str, ModelExecutionRun]]:
259259
"""
260260
Get the definitions of simulations commands to run for this DoE.
261261
"""

OMPython/modelica_system_abc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import numpy as np
1818

1919
from OMPython.model_execution import (
20-
ModelExecutionCmd,
20+
ModelExecutionConfig,
2121
)
2222
from OMPython.om_session_abc import (
2323
OMPathABC,
@@ -189,7 +189,7 @@ def check_model_executable(self):
189189
Check if the model executable is working
190190
"""
191191
# check if the executable exists ...
192-
om_cmd = ModelExecutionCmd(
192+
om_cmd = ModelExecutionConfig(
193193
runpath=self.getWorkDirectory(),
194194
cmd_local=self._session.model_execution_local,
195195
cmd_windows=self._session.model_execution_windows,
@@ -579,7 +579,7 @@ def _parse_om_version(version: str) -> tuple[int, int, int]:
579579

580580
def _process_override_data(
581581
self,
582-
om_cmd: ModelExecutionCmd,
582+
om_cmd: ModelExecutionConfig,
583583
override_file: OMPathABC,
584584
override_var: dict[str, str],
585585
override_sim: dict[str, str],
@@ -619,7 +619,7 @@ def simulate_cmd(
619619
result_file: OMPathABC,
620620
simflags: Optional[str] = None,
621621
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
622-
) -> ModelExecutionCmd:
622+
) -> ModelExecutionConfig:
623623
"""
624624
This method prepares the simulates model according to the simulation options. It returns an instance of
625625
ModelicaSystemCmd which can be used to run the simulation.
@@ -641,7 +641,7 @@ def simulate_cmd(
641641
An instance if ModelicaSystemCmd to run the requested simulation.
642642
"""
643643

644-
om_cmd = ModelExecutionCmd(
644+
om_cmd = ModelExecutionConfig(
645645
runpath=self.getWorkDirectory(),
646646
cmd_local=self._session.model_execution_local,
647647
cmd_windows=self._session.model_execution_windows,
@@ -1134,7 +1134,7 @@ def linearize(
11341134
"use ModelicaSystemOMC() to build the model first"
11351135
)
11361136

1137-
om_cmd = ModelExecutionCmd(
1137+
om_cmd = ModelExecutionConfig(
11381138
runpath=self.getWorkDirectory(),
11391139
cmd_local=self._session.model_execution_local,
11401140
cmd_windows=self._session.model_execution_windows,

tests/test_ModelExecutionCmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def mscmd_firstorder(model_firstorder):
2424
model_name="M",
2525
)
2626

27-
mscmd = OMPython.ModelExecutionCmd(
27+
mscmd = OMPython.ModelExecutionConfig(
2828
runpath=mod.getWorkDirectory(),
2929
cmd_local=mod.get_session().model_execution_local,
3030
cmd_windows=mod.get_session().model_execution_windows,

0 commit comments

Comments
 (0)