Skip to content

Commit 590aac5

Browse files
committed
Merge branch 'remove_depreciated_functionality' into v5.0.0-syntron7
2 parents cb93f97 + 71a4075 commit 590aac5

4 files changed

Lines changed: 6 additions & 80 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -283,44 +283,6 @@ def definition(self) -> OMCSessionRunData:
283283

284284
return omc_run_data_updated
285285

286-
@staticmethod
287-
def parse_simflags(simflags: str) -> dict[str, Optional[str | dict[str, Any] | numbers.Number]]:
288-
"""
289-
Parse a simflag definition; this is deprecated!
290-
291-
The return data can be used as input for self.args_set().
292-
"""
293-
warnings.warn("The argument 'simflags' is depreciated and will be removed in future versions; "
294-
"please use 'simargs' instead", DeprecationWarning, stacklevel=2)
295-
296-
simargs: dict[str, Optional[str | dict[str, Any] | numbers.Number]] = {}
297-
298-
args = [s for s in simflags.split(' ') if s]
299-
for arg in args:
300-
if arg[0] != '-':
301-
raise ModelicaSystemError(f"Invalid simulation flag: {arg}")
302-
arg = arg[1:]
303-
parts = arg.split('=')
304-
if len(parts) == 1:
305-
simargs[parts[0]] = None
306-
elif parts[0] == 'override':
307-
override = '='.join(parts[1:])
308-
309-
override_dict = {}
310-
for item in override.split(','):
311-
kv = item.split('=')
312-
if not 0 < len(kv) < 3:
313-
raise ModelicaSystemError(f"Invalid value for '-override': {override}")
314-
if kv[0]:
315-
try:
316-
override_dict[kv[0]] = kv[1]
317-
except (KeyError, IndexError) as ex:
318-
raise ModelicaSystemError(f"Invalid value for '-override': {override}") from ex
319-
320-
simargs[parts[0]] = override_dict
321-
322-
return simargs
323-
324286

325287
class ModelicaSystem:
326288
"""
@@ -1052,7 +1014,6 @@ def getOptimizationOptions(
10521014
def simulate_cmd(
10531015
self,
10541016
result_file: OMCPath,
1055-
simflags: Optional[str] = None,
10561017
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
10571018
timeout: Optional[float] = None,
10581019
) -> ModelicaSystemCmd:
@@ -1066,13 +1027,6 @@ def simulate_cmd(
10661027
However, if only non-structural parameters are used, it is possible to reuse an existing instance of
10671028
ModelicaSystem to create several version ModelicaSystemCmd to run the model using different settings.
10681029
1069-
Parameters
1070-
----------
1071-
result_file
1072-
simflags
1073-
simargs
1074-
timeout
1075-
10761030
Returns
10771031
-------
10781032
An instance if ModelicaSystemCmd to run the requested simulation.
@@ -1088,11 +1042,7 @@ def simulate_cmd(
10881042
# always define the result file to use
10891043
om_cmd.arg_set(key="r", val=result_file.as_posix())
10901044

1091-
# allow runtime simulation flags from user input
1092-
if simflags is not None:
1093-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1094-
1095-
if simargs:
1045+
if simargs is not None:
10961046
om_cmd.args_set(args=simargs)
10971047

10981048
if self._override_variables or self._simulate_options_override:
@@ -1130,7 +1080,6 @@ def simulate_cmd(
11301080
def simulate(
11311081
self,
11321082
resultfile: Optional[str | os.PathLike] = None,
1133-
simflags: Optional[str] = None,
11341083
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
11351084
timeout: Optional[float] = None,
11361085
) -> None:
@@ -1140,8 +1089,6 @@ def simulate(
11401089
11411090
Args:
11421091
resultfile: Path to a custom result file
1143-
simflags: String of extra command line flags for the model binary.
1144-
This argument is deprecated, use simargs instead.
11451092
simargs: Dict with simulation runtime flags.
11461093
timeout: Maximum execution time in seconds.
11471094
@@ -1169,7 +1116,6 @@ def simulate(
11691116

11701117
om_cmd = self.simulate_cmd(
11711118
result_file=self._result_file,
1172-
simflags=simflags,
11731119
simargs=simargs,
11741120
timeout=timeout,
11751121
)
@@ -1681,7 +1627,6 @@ def optimize(self) -> dict[str, Any]:
16811627
def linearize(
16821628
self,
16831629
lintime: Optional[float] = None,
1684-
simflags: Optional[str] = None,
16851630
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
16861631
timeout: Optional[float] = None,
16871632
) -> LinearizationResult:
@@ -1691,8 +1636,6 @@ def linearize(
16911636
16921637
Args:
16931638
lintime: Override "stopTime" value.
1694-
simflags: String of extra command line flags for the model binary.
1695-
This argument is deprecated, use simargs instead.
16961639
simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
16971640
timeout: Maximum execution time in seconds.
16981641
@@ -1740,11 +1683,7 @@ def linearize(
17401683

17411684
om_cmd.arg_set(key="l", val=str(lintime or self._linearization_options["stopTime"]))
17421685

1743-
# allow runtime simulation flags from user input
1744-
if simflags is not None:
1745-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1746-
1747-
if simargs:
1686+
if simargs is not None:
17481687
om_cmd.args_set(args=simargs)
17491688

17501689
# the file create by the model executable which contains the matrix and linear inputs, outputs and states

OMPython/OMCSession.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import time
5252
from typing import Any, Optional, Tuple
5353
import uuid
54-
import warnings
5554
import zmq
5655

5756
import psutil
@@ -623,12 +622,6 @@ def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
623622

624623
return returncode
625624

626-
def execute(self, command: str):
627-
warnings.warn("This function is depreciated and will be removed in future versions; "
628-
"please use sendExpression() instead", DeprecationWarning, stacklevel=2)
629-
630-
return self.sendExpression(command, parsed=False)
631-
632625
def sendExpression(self, command: str, parsed: bool = True) -> Any:
633626
"""
634627
Send an expression to the OMC server and return the result.

tests/test_ModelicaSystemCmd.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,12 @@ def test_simflags(mscmd_firstorder):
3535

3636
mscmd.args_set({
3737
"noEventEmit": None,
38-
"override": {'b': 2}
38+
"override": {'b': 2, 'a': 4},
3939
})
40-
with pytest.deprecated_call():
41-
mscmd.args_set(args=mscmd.parse_simflags(simflags="-noEventEmit -noRestart -override=a=1,x=3"))
4240

4341
assert mscmd.get_cmd_args() == [
4442
'-noEventEmit',
45-
'-noRestart',
46-
'-override=a=1,b=2,x=3',
43+
'-override=a=4,b=2',
4744
]
4845

4946
mscmd.args_set({
@@ -52,6 +49,5 @@ def test_simflags(mscmd_firstorder):
5249

5350
assert mscmd.get_cmd_args() == [
5451
'-noEventEmit',
55-
'-noRestart',
56-
'-override=a=1,x=3',
52+
'-override=a=4',
5753
]

tests/test_ZMQ.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def test_Simulate(om, model_time_str):
3636
assert om.sendExpression('res.resultFile')
3737

3838

39-
def test_execute(om):
40-
with pytest.deprecated_call():
41-
assert om.execute('"HelloWorld!"') == '"HelloWorld!"\n'
39+
def test_sendExpression(om):
4240
assert om.sendExpression('"HelloWorld!"', parsed=False) == '"HelloWorld!"\n'
4341
assert om.sendExpression('"HelloWorld!"', parsed=True) == 'HelloWorld!'
4442

0 commit comments

Comments
 (0)