Skip to content

Commit be9842a

Browse files
committed
[ModelicaSystemDoE] replace pathlib by OMCPath
1 parent 94d0413 commit be9842a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

OMPython/ModelicaSystem.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,18 +1866,18 @@ def run_doe():
18661866

18671867
def __init__(
18681868
self,
1869-
fileName: Optional[str | os.PathLike | pathlib.Path] = None,
1869+
fileName: Optional[str | os.PathLike] = None,
18701870
modelName: Optional[str] = None,
18711871
lmodel: Optional[list[str | tuple[str, str]]] = None,
18721872
commandLineOptions: Optional[list[str]] = None,
18731873
variableFilter: Optional[str] = None,
1874-
customBuildDirectory: Optional[str | os.PathLike | pathlib.Path] = None,
1874+
customBuildDirectory: Optional[str | os.PathLike] = None,
18751875
omhome: Optional[str] = None,
18761876

18771877
simargs: Optional[dict[str, Optional[str | dict[str, str] | numbers.Number]]] = None,
18781878
timeout: Optional[int] = None,
18791879

1880-
resultpath: Optional[pathlib.Path] = None,
1880+
resultpath: Optional[str | os.PathLike] = None,
18811881
parameters: Optional[dict[str, list[str] | list[int] | list[float]]] = None,
18821882
) -> None:
18831883
"""
@@ -1908,10 +1908,13 @@ def __init__(
19081908
self._simargs = simargs
19091909
self._timeout = timeout
19101910

1911-
if isinstance(resultpath, pathlib.Path):
1912-
self._resultpath = resultpath
1911+
if resultpath is not None:
1912+
self._resultpath = self._mod._getconn.omcpath(resultpath)
19131913
else:
1914-
self._resultpath = pathlib.Path('.')
1914+
self._resultpath = self._mod._getconn.omcpath_tempdir()
1915+
1916+
if not self._resultpath.is_dir():
1917+
raise ModelicaSystemError(f"Resultpath {self._resultpath.as_posix()} does not exists!")
19151918

19161919
if isinstance(parameters, dict):
19171920
self._parameters = parameters
@@ -2062,7 +2065,7 @@ def worker(worker_id, task_queue):
20622065
raise ModelicaSystemError("Missing simulation definition!")
20632066

20642067
resultfile = mscmd.arg_get(key='r')
2065-
resultpath = pathlib.Path(resultfile)
2068+
resultpath = self._mod._getconn.omcpath(resultfile)
20662069

20672070
logger.info(f"[Worker {worker_id}] Performing task: {resultpath.name}")
20682071

@@ -2100,7 +2103,7 @@ def worker(worker_id, task_queue):
21002103
# include check for an empty (=> 0B) result file which indicates a crash of the model executable
21012104
# see: https://github.com/OpenModelica/OMPython/issues/261
21022105
# https://github.com/OpenModelica/OpenModelica/issues/13829
2103-
if resultfile.is_file() and resultfile.stat().st_size > 0:
2106+
if resultfile.is_file() and resultfile.size() > 0:
21042107
self._sim_dict[resultfilename][self.DICT_RESULT_AVAILABLE] = True
21052108
sim_dict_done += 1
21062109

0 commit comments

Comments
 (0)