Skip to content

Conversation

@syntron
Copy link
Contributor

@syntron syntron commented Jan 11, 2026

Content (lots of changes / these will be splitted into several PRs if the general approach is approved):

  • 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 Enable the usage of a pre-built model executables by ModelicaSystemRunner #401)
  • test_ModelicaSystemRunner.py: test case for ModelicaSystemRunner
  • test_*: update of test cases based on above listed changes

Compared to PR #401 this solution:

  • still uses the existing OMPython requirements (dependencies of the Runner class; i.e. numpy, etc.)
  • shares nearly all code with the current definitions (by using OMCPathDummy and OMCSessionDummy)
  • uses | instead of Union

Further changes could do additional modifications such that the 3rd party packages (ZMQ) are not needed at all in the runner code path.

All tests are running without error / tested in https://github.com/syntron/OMPython/actions/runs/20865402893

Please comment!

* rename ModelicaSystemCmd => ModelExecutionCmd
* rename OMCSessionRunData => ModelExecutionData
* create class ModelExecutionException
* move some code:
  * OMCSession.omc_run_data_update() => merge into ModelExecutionCmd.define()
  * OMCSession.run_model_executable() => ModelExecutionData.run()
* this prepares a version of OMCSession which is independend of OMC as
  these functions where the last two which needed sendExpression() in
  basic ModelicaSystem functionality
* store data as numpy.float64 - allows to define None values
* split get*() function into Initial values and Final values
* test_ModelicaSystemDoE_local is tested
* test_ModelicaSystemDoE_docker should work
* test_ModelicaSystemDoE_WSL is untested
…m OMSessionABC

* needed for the compatibility layer
* add get_session()
* fix return values
* check return value from OMC
* define return value for methods
* fix return values
* additional cleanups
* move more code to OMCSessionDockerHelper
* use _docker_omc_start() to differentiate classes
* define cmd_prefix
* ModelicaSystemRunner & OMCPath
* ModelicaSystemRunner & OMPathRunnerLocal
* ModelicaSystemRunner & OMPathRunnerBash
* ModelicaSystemRunner & OMPathRunnerBash using docker
* ModelicaSystemRunner & OMPathRunnerBash using WSL (not tested!)
* OMCPath & OMCSessionZMQ
* OMCPath & OMCSessionLocal
* OMCPath & OMCSessionDocker
* OMCPath & OMCSessionWSL (not tested!)
* OMPathLocal & OMCSessionRunner
* OMPathBash & OMCSessionRunner
* OMPathBash & OMCSessionRunner in docker
* OMPathBash & OMCSessionRunner in WSL (not tested!)
@syntron
Copy link
Contributor Author

syntron commented Feb 9, 2026

Some status update on this PR - the main points are:

The code defined here updates the internal structure of OMPython such that:

  • generic code is separated in ABC classes
  • derived code exists for OMC usage and Runner usage
  • a compatibility layer exists such that the interface of OMPython 4.0.0 is (basically) supported; this is tested using the original unittests from v4.0.0

Furthermore, as OMCPath is working only for Python >= 3.12, another dimension exists. There is a dummy implementation of OMCPath for Python < 3.12 such that most of the functionality can also be used here. See PR #401 for a hint that even older Python version are used (Python 3.10 or even lower).

These changes could be the baseline for a new documentation (see https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/ompython.html). My idea was to include these changes as 4.x.0 and create a cut at the next release (or keep some kind of compatibility layer alive).

(partly from the discussion in PR #387)

@syntron
Copy link
Contributor Author

syntron commented Feb 9, 2026

The failed test is due to Windows - it runs well for v4.0.0 (see: https://github.com/syntron/OMPython/actions/runs/21842400755) and 4.x.x (see: https://github.com/syntron/OMPython/actions/runs/21841418638)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant