Skip to content

Commit 2a39752

Browse files
committed
[ModelicaSystemDoE] replace pathlib by OMCPath
1 parent 262ceb5 commit 2a39752

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

OMPython/ModelicaSystem.py

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

18661866
def __init__(
18671867
self,
1868-
fileName: Optional[str | os.PathLike | pathlib.Path] = None,
1868+
fileName: Optional[str | os.PathLike] = None,
18691869
modelName: Optional[str] = None,
18701870
lmodel: Optional[list[str | tuple[str, str]]] = None,
18711871
commandLineOptions: Optional[list[str]] = None,
18721872
variableFilter: Optional[str] = None,
1873-
customBuildDirectory: Optional[str | os.PathLike | pathlib.Path] = None,
1873+
customBuildDirectory: Optional[str | os.PathLike] = None,
18741874
omhome: Optional[str] = None,
18751875

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

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

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

19151918
if isinstance(parameters, dict):
19161919
self._parameters = parameters
@@ -2061,7 +2064,7 @@ def worker(worker_id, task_queue):
20612064
raise ModelicaSystemError("Missing simulation definition!")
20622065

20632066
resultfile = mscmd.arg_get(key='r')
2064-
resultpath = pathlib.Path(resultfile)
2067+
resultpath = self._mod._getconn.omcpath(resultfile)
20652068

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

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

0 commit comments

Comments
 (0)