Skip to content

Problems with OMPython and packages stored as a directory #489

Closed

Description

@Ulfsen

Description

When using ModelicaSystem in a package with multiple files (i.e. when the models are in different (sub)folders) the loading with OMCSession fails.

Steps to Reproduce

load the attached file, unpack it and try in a python console (with ompython installed of course) the following code:

from OMPython import ModelicaSystem
mod=ModelicaSystem("BouncingBalls/package.mo","BouncingBalls.Tests.StableBouncingBall")

-> Error:

[OMC log for 'sendExpression(expr=loadFile("/tmp/bfd53f62-ef57-4907-a983-b78f12dbd88a/package.mo"), parsed=True)']: [scripting:error:236] Expected the package to have name bfd53f62-ef57-4907-a983-b78f12dbd88a, but got BouncingBalls.
....
00: [scripting:error:236] [/tmp/bfd53f62-ef57-4907-a983-b78f12dbd88a/package.mo:false:2:1:18:18] Expected the package to have name bfd53f62-ef57-4907-a983-b78f12dbd88a, but got BouncingBalls.
01: [scripting:error:184] [:false:0:0:0:0] Failed to load package bfd53f62-ef57-4907-a983-b78f12dbd88a () using OPENMODELICALIBRARY (MODELICAPATH in the language specification) /tmp.

Expected Behavior

The model should load

Version and OS

OpenModelica 1.28.0~dev-744-ged53351
WSL (Ubuntu or Debian) on Windows 11

Additional Context

BouncingBalls.zip

OMPython seems under heavy development (OMCSessionZMQ deprecated, undocumented OMCSession*, etc.). I could'nt find any information except in the source files. Would be nice to have this development somewhere documented and updated ;-)

Activity

  1. arun3688 commented on Oct 2, 2026

    @arun3688
    Collaborator

    @Ulfsen the issue should be fixed with this #476, please test it from the latest master, reopen the issue if you face problem

  2. sjoelund commented on Oct 9, 2026

    @sjoelund
    Member

    Note

    🤖 Automated triage by Claude (an AI model by Anthropic), posted from @sjoelund's account. I re-tested this issue against a recent OpenModelica build and it appears to be resolved. The evidence is below so that a maintainer can verify it and close the issue. I have not closed anything myself.

    Tested with: v1.28.0-dev.887+gff74690.cmake (Linux x86_64) and OMPython master 79d80ca (2026-10-05), installed with pip install git+https://github.com/OpenModelica/OMPython@master into a clean venv
    Original report: ModelicaSystem("BouncingBalls/package.mo", "BouncingBalls.Tests.StableBouncingBall") for a package stored as a directory failed. OMPython copied package.mo out of its package directory into a temporary directory, and omc then complained "Expected the package to have name , but got BouncingBalls".

    Reproduction (attached BouncingBalls.zip extracted to dl/, unchanged):

    import os
    from OMPython import ModelicaSystem
    mod = ModelicaSystem("dl/BouncingBalls/package.mo", "BouncingBalls.Tests.StableBouncingBall")
    print("loaded OK; quantities:", len(mod.getQuantities()))

    Result:

    loaded OK; quantities: 9
    exit=0
    

    Why this resolves the issue: the multi-file package loads, and the ModelicaSystem object is created with the model's quantities available. The fix is on the OMPython side: #476 ("fix loadFile for package.mo: don't copy it out of its package directory", merged 2026-10-02), as @arun3688 noted.

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