From 1c17faa80fc256170c3d4001a0d9d56680cec534 Mon Sep 17 00:00:00 2001 From: Nmichele29 Date: Wed, 7 May 2025 18:22:46 +0200 Subject: [PATCH 1/4] Update ModelicaSystem.py Adds the build argument to ModelicaSystem constructor --- OMPython/ModelicaSystem.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 97dc844cc..249496b97 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -118,6 +118,7 @@ def __init__( customBuildDirectory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, session: Optional[OMCSessionBase] = None + build: Optional[bool] = True ): """Initialize, load and build a model. @@ -146,6 +147,9 @@ def __init__( session. session: OMC session to be used. If unspecified, a new session will be created. + build: Boolean controlling whether or not the model should be + built when constructor is called. If False, the constructor + simply loads the model without compiling. Examples: mod = ModelicaSystem("ModelicaModel.mo", "modelName") @@ -216,8 +220,9 @@ def __init__( # allow directly loading models from MSL without fileName elif fileName is None and modelName is not None: self.loadLibrary(lmodel=self.lmodel) - - self.buildModel(variableFilter) + + if build : + self.buildModel(variableFilter) def setCommandLineOptions(self, commandLineOptions: str): # set commandLineOptions if provided by users From d9ad5fb6ba042927f5fbfc77200c364c3ab0d6d0 Mon Sep 17 00:00:00 2001 From: Nmichele29 Date: Thu, 8 May 2025 09:52:44 +0200 Subject: [PATCH 2/4] Update ModelicaSystem.py --- OMPython/ModelicaSystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 249496b97..5a35de74c 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -117,7 +117,7 @@ def __init__( variableFilter: Optional[str] = None, customBuildDirectory: Optional[str | os.PathLike] = None, omhome: Optional[str] = None, - session: Optional[OMCSessionBase] = None + session: Optional[OMCSessionBase] = None, build: Optional[bool] = True ): """Initialize, load and build a model. From b9a6f662138b5ba388933c45afcac35a8c53f841 Mon Sep 17 00:00:00 2001 From: arun3688 Date: Thu, 8 May 2025 10:46:39 +0200 Subject: [PATCH 3/4] fix typos --- OMPython/ModelicaSystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 5a35de74c..bb579bff2 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -221,7 +221,7 @@ def __init__( elif fileName is None and modelName is not None: self.loadLibrary(lmodel=self.lmodel) - if build : + if build: self.buildModel(variableFilter) def setCommandLineOptions(self, commandLineOptions: str): From 59eb5683aa9ece27c2565dd809c5347924404e3c Mon Sep 17 00:00:00 2001 From: Nmichele29 Date: Thu, 8 May 2025 11:37:17 +0200 Subject: [PATCH 4/4] Remove trailing spaces --- OMPython/ModelicaSystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index bb579bff2..1ee8b9930 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -148,7 +148,7 @@ def __init__( session: OMC session to be used. If unspecified, a new session will be created. build: Boolean controlling whether or not the model should be - built when constructor is called. If False, the constructor + built when constructor is called. If False, the constructor simply loads the model without compiling. Examples: @@ -220,7 +220,7 @@ def __init__( # allow directly loading models from MSL without fileName elif fileName is None and modelName is not None: self.loadLibrary(lmodel=self.lmodel) - + if build: self.buildModel(variableFilter)