DSD-DBS / py-capellambse

A Python 3 headless implementation of the Capella modeling tool.

Home Page:https://dsd-dbs.github.io/py-capellambse/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add element to model created with Capella 6.0.0 failed

AnNeub opened this issue · comments

I have a model created with Capella 6.0.0 and want to add a component.

I used the following code to do this.

model = capellambse.MelodyModel(path_to_model, jupyter_untrusted=True)
newitem = model.pa.root_component.owned_components.create(name='Test')

This leads to the following error:

ValueError: Namespace 'org.polarsys.capella.core.data.pa' already registered with URI 'http://www.polarsys.org/capella/core/pa/6.0.0'

By checking the source I found out that only the first plugin version is added to the NAMESPACES dict.
Changing the order of the versions and the script runs without any problem.

file: _namespaces.py

        "org.polarsys.capella.core.data.pa": Plugin(
            "http://www.polarsys.org/capella/core/pa/", ("6.0.0", "5.0.0")
        ),

Is there a way to define which version shall be loaded to the global NAMESPACES dict?

Regards,
Andreas

This unfortunately comes down to how capellambse handles namespaces in general, and is somewhat difficult to solve properly in place. However, we're currently working on a rewrite of the core model component, which will address this and several other issues.

#277 changed the ValueError you're seeing to a warning message, which should at least alleviate the immediate issue of it crashing. Please update with pip install -U capellambse and you should be good to go.

Thanks for the fast reply. Its working!