Skip to content

Commit 135bc61

Browse files
committed
[ModelicaSystemDoE] replace pathlib by OMCPath
1 parent 689bf34 commit 135bc61

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

18191819
def __init__(
18201820
self,
1821-
fileName: Optional[str | os.PathLike | pathlib.Path] = None,
1821+
fileName: Optional[str | os.PathLike] = None,
18221822
modelName: Optional[str] = None,
18231823
lmodel: Optional[list[str | tuple[str, str]]] = None,
18241824
commandLineOptions: Optional[list[str]] = None,
18251825
variableFilter: Optional[str] = None,
1826-
customBuildDirectory: Optional[str | os.PathLike | pathlib.Path] = None,
1826+
customBuildDirectory: Optional[str | os.PathLike] = None,
18271827
omhome: Optional[str] = None,
18281828

18291829
simargs: Optional[dict[str, Optional[str | dict[str, str] | numbers.Number]]] = None,
18301830
timeout: Optional[int] = None,
18311831

1832-
resultpath: Optional[pathlib.Path] = None,
1832+
resultpath: Optional[str | os.PathLike] = None,
18331833
parameters: Optional[dict[str, list[str] | list[int] | list[float]]] = None,
18341834
) -> None:
18351835
"""
@@ -1860,10 +1860,13 @@ def __init__(
18601860
self._simargs = simargs
18611861
self._timeout = timeout
18621862

1863-
if isinstance(resultpath, pathlib.Path):
1864-
self._resultpath = resultpath
1863+
if resultpath is not None:
1864+
self._resultpath = self._mod._getconn.omcpath(resultpath)
18651865
else:
1866-
self._resultpath = pathlib.Path('.')
1866+
self._resultpath = self._mod._getconn.omcpath_tempdir()
1867+
1868+
if not self._resultpath.is_dir():
1869+
raise ModelicaSystemError(f"Resultpath {self._resultpath.as_posix()} does not exists!")
18671870

18681871
if isinstance(parameters, dict):
18691872
self._parameters = parameters
@@ -2014,7 +2017,7 @@ def worker(worker_id, task_queue):
20142017
raise ModelicaSystemError("Missing simulation definition!")
20152018

20162019
resultfile = mscmd.arg_get(key='r')
2017-
resultpath = pathlib.Path(resultfile)
2020+
resultpath = self._mod._getconn.omcpath(resultfile)
20182021

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

@@ -2052,7 +2055,7 @@ def worker(worker_id, task_queue):
20522055
# include check for an empty (=> 0B) result file which indicates a crash of the model executable
20532056
# see: https://github.com/OpenModelica/OMPython/issues/261
20542057
# https://github.com/OpenModelica/OpenModelica/issues/13829
2055-
if resultfile.is_file() and resultfile.stat().st_size > 0:
2058+
if resultfile.is_file() and resultfile.size() > 0:
20562059
self._sim_dict[resultfilename][self.DICT_RESULT_AVAILABLE] = True
20572060
sim_dict_done += 1
20582061

0 commit comments

Comments
 (0)