Skip to content

[ModelicaSystem] only local omc process allowed #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

syntron
Copy link
Contributor

@syntron syntron commented Jun 17, 2025

ModelicaSystem relies on read access to files and the possibility to execute the compiled model; thus, it only works if OMC is started locally

Use OMCProcessLocal to ensure that this requirement is defined

Based on PR #295

@syntron syntron changed the title [ModelicaSystem] only omc process local [ModelicaSystem] only local omc process allowed Jun 17, 2025
@syntron syntron force-pushed the ModelicaSystem_only_OMCProcessLocal branch 2 times, most recently from 21aaab8 to c40bc06 Compare June 23, 2025 17:02
@adeas31
Copy link
Member

adeas31 commented Jun 26, 2025

Does this mean we can't use docker and wsl instances with ModelicaSystem? Is this just because if I/O permission issues?

@syntron
Copy link
Contributor Author

syntron commented Jun 26, 2025

Does this mean we can't use docker and wsl instances with ModelicaSystem? Is this just because if I/O permission issues?

@adeas31 no, the reason is that ModelicaSystem accesses the file system directly without using OMC (create csv file; read result data, etc.). Due to this, the class can only used locally ...

@syntron
Copy link
Contributor Author

syntron commented Jun 26, 2025

Here some more analyses:

ModelicaSystem(Cmd) are using Python functions to access files from the OMC model; if this code is replaced by calls to OMC, the ModelicaSystem classes would be completly independent from the use OMCSessionZMQ(OMCProcess) version used.

However, it would also mean, that some simple functionality is replaced by code which has to go through OMC in the case of a local usage - but it should be possible to abstract the access to the local filesystem! Thus, ModelicaSystem can be used for all systems for which OMCSessionZMQ is defined.

Use cases (line numbers based on master):

@syntron
Copy link
Contributor Author

syntron commented Jun 26, 2025

Another big issue is the call to the executable in simulate() and linearize() using ModelicaSystemCmd(). A solution for this case is also needed - how to call / run the executable from the host within docker / wsl and also local?

@syntron
Copy link
Contributor Author

syntron commented Jun 27, 2025

Another point: if the model executeable is used, the evaluation of the library paths is done for Windows (using *.bat file). However, I never tested this part for linux (docker, wsl). How can we ensure, that the needed (external) libraries are found in this case?

@syntron syntron force-pushed the ModelicaSystem_only_OMCProcessLocal branch from c40bc06 to fdd63e8 Compare June 28, 2025 19:26
@syntron syntron mentioned this pull request Jun 28, 2025
@adeas31
Copy link
Member

adeas31 commented Jul 1, 2025

All of this filesystem access is needed because we are running the executable directly instead of using simulate api. This was an intentional change a while back to keep the control in OMPython. OMC might crash/hang during simulation so to have the control over the simulation we run the executable directly from OMPython.

The batch file is only needed in Windows to set the executable PATH so it can find all the dependencies. I think we don't need this in linux as it is handled automatically using rpath.

@syntron
Copy link
Contributor Author

syntron commented Jul 1, 2025

I think this is a quite good descission as it allows to run control the execution of the model in more detail; see also the possibility of running DoEs (see PR #312).

However, it also limits the usability of the class ModelicaSystem if it is not run locally, i.e. in docker or WSL. I do not know the history - was ModelicaSystem in the past useable via docker?

The linux case still needs to be tested (including external C libraries like SDF) ... currently I'm only able to run OMC in docker or on Windows.

@syntron syntron force-pushed the ModelicaSystem_only_OMCProcessLocal branch from fdd63e8 to eb14d85 Compare July 2, 2025 20:00
@adeas31
Copy link
Member

adeas31 commented Jul 4, 2025

However, it also limits the usability of the class ModelicaSystem if it is not run locally, i.e. in docker or WSL. I do not know the history - was ModelicaSystem in the past useable via docker?

@arun3688 can you please comment on this? Is ModelicaSystem useable via docker?

Saw that docker test is skipped so I enabled it in PR #319. However, the test is very basic. We should try to enhance it to see if we can test model simulation using docker.

@syntron I am assuming that ModelicaSystem is always used locally, @arun3688 will confirm it, so this PR makes sense to restrict it to local process. For now I will review this PR as it is and we will see if we can fix #315 in future.

Copy link
Member

@adeas31 adeas31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

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.

2 participants