Skip to content

Update Python script to OMPython 4.0.0 #243

Closed

Description

@AnHeuermann

Issue

OMPython 4 no longer has function FindBestOMCSession.

File \"/OpenModelicaLibraryTesting/testmodel.py\", line 8, in <module>
        from OMPython import FindBestOMCSession, OMCSession, OMCSessionZMQ
 ImportError: cannot import name 'FindBestOMCSession' from 'OMPython'

We need to fix OMPython to 3.6 or update the scripts to work with 4.0.

Activity

  1. self-assigned this
    on Nov 3, 2025
  2. AnHeuermann commented on Nov 3, 2025

    @AnHeuermann
    MemberAuthor

    @adpro How are Python dependencies like OMPython managed for our nightly tests?
    If #244 get's merged we need to update them.

  3. AnHeuermann commented on Nov 13, 2025

    @AnHeuermann
    MemberAuthor

    Now I need to update our servers:

    • ryzen-5950x-1
    • ryzen-5950x-2-1

    Next week I need to make sure that all LibraryTest jobs are running again and not reporting strange errors.

  4. AnHeuermann commented on Nov 13, 2025

    @AnHeuermann
    MemberAuthor

    Jenkins breaks: https://test.openmodelica.org/jenkins/blue/organizations/jenkins/LibraryTesting%2FLibraryTest/detail/LibraryTest/10187/pipeline/

    Traceback (most recent call last):
      File "/var/lib/jenkins/ws/OpenModelicaLibraryTestingWork/OpenModelicaLibraryTesting/./test.py", line 666, in <module>
        if not omc.sendExpression('loadModel(%s,%s%s)' % (lib,versions,exactMatch)):
      File "/usr/local/lib/python3.10/dist-packages/OMPython/OMCSession.py", line 410, in sendExpression
        raise OMCSessionException(msg)
    OMPython.OMCSession.OMCSessionException: [OMC log for 'sendExpression(loadModel(IDEAS,{"master"}), True)']: [syntax:error:2] No viable alternative near token: break
    Command exited with non-zero status 1
    
  5. adeas31 commented on Nov 14, 2025

    @adeas31
    Member

    This is strange. sendExpression(loadModel(IDEAS,{"master"}), True) looks perfectly fine.

    I tried the following with OMPython 4.0.0 and it worked fine.

    from OMPython import OMCSessionZMQ
    omc = OMCSessionZMQ()
    omc.sendExpression('loadModel(IDEAS,{"3.0.0"})')
    

    I used version 3.0.0 since that's what I got from package manager. With master I get,

    Traceback (most recent call last):
      File "C:\OpenModelica\OMPython\test.py", line 3, in <module>
        omc.sendExpression('loadModel(IDEAS,{"master"})')
        ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\OpenModelica\OMPython\OMPython\OMCSession.py", line 760, in sendExpression
        raise OMCSessionException(msg)
    OMPython.OMCSession.OMCSessionException: [OMC log for 'sendExpression(loadModel(IDEAS,{"master"}), True)']: [scripting:error:184] Failed to load package IDEAS (master) using MODELICAPATH C:/Users/adeas31/AppData/Roaming/.openmodelica/libraries/.
    

    Perhaps some issue with quoting of string?
    @syntron any idea?

  6. AnHeuermann commented on Nov 14, 2025

    @AnHeuermann
    MemberAuthor

    I'm trying to reproduce the error locally by running the full script:

    ./test.py --extrasimflags= --branch=master --libraries=/home/andreas/.openmodelica/libraries --jobs=0 configs/conf.json

    I think I have a fix, but at the same time the scripts print so many errors it's very hard to tell what's going on.
    I'll give it a final try to get the scripts back up and running.

    If that doesn't work I'll revert the update and changes introduced by this PR and the commits afterwards.
    We need to improve the testing scripts to be able to run more sophisticated tests so we don't break the Jenkins job each time we need to run a tiny update.

  7. AnHeuermann commented on Nov 14, 2025

    @AnHeuermann
    MemberAuthor

    The library tests seem to be huffing and puffing along: https://test.openmodelica.org/jenkins/job/LibraryTesting/job/LibraryTest/

  8. syntron commented on Nov 14, 2025

    @syntron

    This is strange. sendExpression(loadModel(IDEAS,{"master"}), True) looks perfectly fine.

    I tried the following with OMPython 4.0.0 and it worked fine.
    [...]
    I used version 3.0.0 since that's what I got from package manager. With master I get,
    [...]
    Perhaps some issue with quoting of string? @syntron any idea?

    Yes - I just tested it in OpenModelica and 3.0.0 imports well and master / 4.0.0-master fail. Thus, it is not a problem of OMPython but of the library ...

    I'm thinking about / working on an update of the error handling to show all messages of OMC on error

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions