Skip to content

Commit 7e61a90

Browse files
committed
[ModelicaSystemDoE] replace pathlib by OMCPath
1 parent 36784d2 commit 7e61a90

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
@@ -1850,18 +1850,18 @@ def run_doe():
18501850

18511851
def __init__(
18521852
self,
1853-
fileName: Optional[str | os.PathLike | pathlib.Path] = None,
1853+
fileName: Optional[str | os.PathLike] = None,
18541854
modelName: Optional[str] = None,
18551855
lmodel: Optional[list[str | tuple[str, str]]] = None,
18561856
commandLineOptions: Optional[list[str]] = None,
18571857
variableFilter: Optional[str] = None,
1858-
customBuildDirectory: Optional[str | os.PathLike | pathlib.Path] = None,
1858+
customBuildDirectory: Optional[str | os.PathLike] = None,
18591859
omhome: Optional[str] = None,
18601860

18611861
simargs: Optional[dict[str, Optional[str | dict[str, str] | numbers.Number]]] = None,
18621862
timeout: Optional[int] = None,
18631863

1864-
resultpath: Optional[pathlib.Path] = None,
1864+
resultpath: Optional[str | os.PathLike] = None,
18651865
parameters: Optional[dict[str, list[str] | list[int] | list[float]]] = None,
18661866
) -> None:
18671867
"""
@@ -1892,10 +1892,13 @@ def __init__(
18921892
self._simargs = simargs
18931893
self._timeout = timeout
18941894

1895-
if isinstance(resultpath, pathlib.Path):
1896-
self._resultpath = resultpath
1895+
if resultpath is not None:
1896+
self._resultpath = self._mod._getconn.omcpath(resultpath)
18971897
else:
1898-
self._resultpath = pathlib.Path('.')
1898+
self._resultpath = self._mod._getconn.omcpath_tempdir()
1899+
1900+
if not self._resultpath.is_dir():
1901+
raise ModelicaSystemError(f"Resultpath {self._resultpath.as_posix()} does not exists!")
18991902

19001903
if isinstance(parameters, dict):
19011904
self._parameters = parameters
@@ -2046,7 +2049,7 @@ def worker(worker_id, task_queue):
20462049
raise ModelicaSystemError("Missing simulation definition!")
20472050

20482051
resultfile = mscmd.arg_get(key='r')
2049-
resultpath = pathlib.Path(resultfile)
2052+
resultpath = self._mod._getconn.omcpath(resultfile)
20502053

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

@@ -2084,7 +2087,7 @@ def worker(worker_id, task_queue):
20842087
# include check for an empty (=> 0B) result file which indicates a crash of the model executable
20852088
# see: https://github.com/OpenModelica/OMPython/issues/261
20862089
# https://github.com/OpenModelica/OpenModelica/issues/13829
2087-
if resultfile.is_file() and resultfile.stat().st_size > 0:
2090+
if resultfile.is_file() and resultfile.size() > 0:
20882091
self._sim_dict[resultfilename][self.DICT_RESULT_AVAILABLE] = True
20892092
sim_dict_done += 1
20902093

0 commit comments

Comments
 (0)