Skip to content

Commit b3649ff

Browse files
committed
[ModelicaSystemDoE] replace pathlib by OMCPath
1 parent e7480e3 commit b3649ff

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

18301830
def __init__(
18311831
self,
1832-
fileName: Optional[str | os.PathLike | pathlib.Path] = None,
1832+
fileName: Optional[str | os.PathLike] = None,
18331833
modelName: Optional[str] = None,
18341834
lmodel: Optional[list[str | tuple[str, str]]] = None,
18351835
commandLineOptions: Optional[list[str]] = None,
18361836
variableFilter: Optional[str] = None,
1837-
customBuildDirectory: Optional[str | os.PathLike | pathlib.Path] = None,
1837+
customBuildDirectory: Optional[str | os.PathLike] = None,
18381838
omhome: Optional[str] = None,
18391839

18401840
simargs: Optional[dict[str, Optional[str | dict[str, str] | numbers.Number]]] = None,
18411841
timeout: Optional[int] = None,
18421842

1843-
resultpath: Optional[pathlib.Path] = None,
1843+
resultpath: Optional[str | os.PathLike] = None,
18441844
parameters: Optional[dict[str, list[str] | list[int] | list[float]]] = None,
18451845
) -> None:
18461846
"""
@@ -1871,10 +1871,13 @@ def __init__(
18711871
self._simargs = simargs
18721872
self._timeout = timeout
18731873

1874-
if isinstance(resultpath, pathlib.Path):
1875-
self._resultpath = resultpath
1874+
if resultpath is not None:
1875+
self._resultpath = self._mod._getconn.omcpath(resultpath)
18761876
else:
1877-
self._resultpath = pathlib.Path('.')
1877+
self._resultpath = self._mod._getconn.omcpath_tempdir()
1878+
1879+
if not self._resultpath.is_dir():
1880+
raise ModelicaSystemError(f"Resultpath {self._resultpath.as_posix()} does not exists!")
18781881

18791882
if isinstance(parameters, dict):
18801883
self._parameters = parameters
@@ -2025,7 +2028,7 @@ def worker(worker_id, task_queue):
20252028
raise ModelicaSystemError("Missing simulation definition!")
20262029

20272030
resultfile = mscmd.arg_get(key='r')
2028-
resultpath = pathlib.Path(resultfile)
2031+
resultpath = self._mod._getconn.omcpath(resultfile)
20292032

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

@@ -2063,7 +2066,7 @@ def worker(worker_id, task_queue):
20632066
# include check for an empty (=> 0B) result file which indicates a crash of the model executable
20642067
# see: https://github.com/OpenModelica/OMPython/issues/261
20652068
# https://github.com/OpenModelica/OpenModelica/issues/13829
2066-
if resultfile.is_file() and resultfile.stat().st_size > 0:
2069+
if resultfile.is_file() and resultfile.size() > 0:
20672070
self._sim_dict[resultfilename][self.DICT_RESULT_AVAILABLE] = True
20682071
sim_dict_done += 1
20692072

0 commit comments

Comments
 (0)