-
Notifications
You must be signed in to change notification settings - Fork 65
Fix: Correct override file generation and improve OMC message parsing #399
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
base: master
Are you sure you want to change the base?
Fix: Correct override file generation and improve OMC message parsing #399
Conversation
|
I investigated the CI failure in I ran this test locally on Windows and it passed successfully. Since my PR does not modify the core |
|
@syntron can you please check these changes. |
Perhaps in the case of empty override an extra newline is added which is causing the simulation to fail. |
Thanks for the hint! You were right about the newline issue. I investigated ModelicaSystem.py and found that when I've added a |
|
It still fails. Maybe you can run the tests locally. This allows better debugging. |
|
Could this be OM specific? Just from the latest run the results for tests/test_ModelicaSystem.py::test_getSolutions (only Ubuntu results): Python 3.10 / stable => OK |
|
#400 should fix the failing tests. Update your PR accordingly once its merged. Unfortunately I can't merge it yet until we make a new stable release of OM. The new stable release is supposed to have the new runtime flags but we made beta1 without it. So we need to wait until a new release is available. |
1. Correct override file generation
Related Issues
Purpose
In
ModelicaSystem.py: Fixed a bug whereoverride_variablesandsimulate_options_overridewere concatenated without a newline separator. This had caused invalid syntax in the generated override file, where two parameters were merged into a single line, thereby makingsetSimulationOptions()ineffective.I found this bug when i trying the example of BouncingBall and changing the stop time of simulation to 2 seconds using
mod.setSimulationOptions({"stopTime": "2.0"}), but the change is never effective.The generated
BouncingBall_res_override.txtbefore fix is like:causes the override using
mod.setSimulationOptions({"stopTime": "2.0"})ineffect.Approach
A newline separator is added between these two group of override parameters, the generated override file is like:
and the overrided simualte options are working now.
2.Improve OMC message parsing
Related Issues
Purpose
In
OMCSession.py, updated the regular expression for parsing ErrorMessage records. The old patternr"\s*message = \"(.*?)\",\n"of lazy mapping cannot handle correctly escaped double quotes within the message string. Besides, the pattern ofidcannot handle the potential negative id. This causes error messages cannot be properly parsed inOMPython.OMCSession.sendExpression.I found this bug when I execute following code but with some errors occured:
This bug results in a
TypeError: 'NoneType' object is not subscriptablebeing thrown (because the result of optimizeris None) rather then the expectedOMPython.OMCSession.OMCSessionException.Approach
The pattern of Regular expression for
messageandidare corrected, by using greedy mode formessage, and adding handling of negative signs forid.