Enable the usage of a pre-built model executables by ModelicaSystemRunner#401
Enable the usage of a pre-built model executables by ModelicaSystemRunner#401joewa wants to merge 5 commits intoOpenModelica:masterfrom
Conversation
|
@joewa I think it would be possible to use |
|
Did it. Thanks for your feedback @syntron |
|
@joewa looks good to me! I'm thinking about a modification to Some comments:
|
|
Thanks for so much feedback @syntron by this PR, I'd like to enable this new OMPython workflow that is now implemented in Since we agreed that the current approach is better than having ModelicaSystemRunner standalone, I think we should rather merge this pull request earlier than later as it is already a step forward. Then we will avoid more (possibly incompatible) pull requests piling up... I find most of your recommendations plausible. Please consider them agreed if not mentioned below:
I cannot test on Windows. So I preferred to keep whatever works.
The chdir() calls are useful in case the compiled binary is placed next to the .so/.dll that it needs to run in an environment where the user has no control over the path variable.
I am not using
Probably yes. See also my chdir above.
I am currently using omcompiler v1.25 that is in conda-forge. Could you please consider rebasing these PR's to this one?
I had to review all functions before moving it to ModelicaSystemBase. Some are now split between ModelicaSystemBase and ModelicaSystem. I might have removed some comments in case I found they are now deprecated or not adding information. Maybe I was a bit too enthusiastic when cleaning up.
Some users are still at Python < 3.10, really. I'd prefer keeping the widest possible coverage rather than implementing the newest language features (unless we are not forced to do so).
Maybe. Could you draft a use case for this? (But please not within this PR) So if you agree that this PR is a step forward, I would propose to merge it and handle more improvements in future PR's. |
… PRs * OMCSession.py: rename real OMCPath* classes as privat (start with '_') * OMCSession: define OMCPathDummy and OMCSessionDummy => no OMC server * ModelExecution.py: include all code related to model execution (from OMCsession*; ModelicaSystemCmd) * ModelicaSystemDoE.py: seperate file for this class * ModelicaSystemDoE.py: use ModelicaSystem / reduce number of arguments to __init__ * ModelicaSystem(Base).py: split getOutputs() and getContinuous() to Initial and Final data * ModelicaSystem(Base).py: getOutputs*() / getContinuous*() - always return np.float64 * ModelicaSystemBase.py: define a basic version of ModelicaSystem * ModelicaSystemRunner.py: definition of a 'runner' class using ModelicaSystemBasic / OMCSessionDummy (see PR OpenModelica#401) * test_ModelicaSystemRunner.py: test case for ModelicaSystemRunner * test_*: update of test cases based on above listed changes
… PRs * OMCSession.py: rename real OMCPath* classes as privat (start with '_') * OMCSession: define OMCPathDummy and OMCSessionDummy => no OMC server * OMCSession: remove OMCSessionCmd * ModelExecution.py: include all code related to model execution (from OMCsession*; ModelicaSystemCmd) * ModelicaSystemDoE.py: seperate file for this class * ModelicaSystemDoE.py: use ModelicaSystem / reduce number of arguments to __init__ * ModelicaSystem(Base).py: split getOutputs() and getContinuous() to Initial and Final data * ModelicaSystem(Base).py: getOutputs*() / getContinuous*() - always return np.float64 * ModelicaSystemBase.py: define a basic version of ModelicaSystem * ModelicaSystemRunner.py: definition of a 'runner' class using ModelicaSystemBasic / OMCSessionDummy (see PR OpenModelica#401) * test_ModelicaSystemRunner.py: test case for ModelicaSystemRunner * test_*: update of test cases based on above listed changes
|
@joewa I was thinking a lot about this topic and work on a (bigger) update in the last days - take this / PR #404 as a draft as it is complete mess regarding the commits on my side. Thus, only a large merged blob available at the moment. The main point was to get a runner class working which uses as many code from the original |
|
I will review and test and make pull requests directly to your branch https://github.com/syntron/OMPython/tree/syntron_RFC . |
Related Issues
This pull request is a re-implementation of issue #165 because of a new library architecture @adeas31
Purpose
ModelicaSystemRunner. This will gain some efficiency e.g. when only the parameters or the input data changes between different simulation runs.OMCSession(with ZeroMQ connection).Approach
ModelicaSystemRunner will simulate pre-built models with customized parameters or inputs.
The simulation can be executed (with a customized set of output variables) like this:
The log_str contains the models output from stdout and stderr.
The Strategy: "Duck Typing" (ModelicaSystemRunner)
Instead of modifying all OMPython modules, I created a standalone class (ModelicaSystemRunner) that mimics the API of OMPython. It will run purely on standard Python libraries (xml.etree, subprocess), making it zero-dependency and perfect for efficient use in slim environments.
Idea for way forward
Create a module + class
ModelicaSystemBasethat has all functions that are common for ModelicaSystem, ModelicaSystemRunner and probably ModelicaSystemCmd but without dependency on OMCSession. This might reduce the need to duplicate code in all classes.