DSD-DBS / py-capellambse

A Python 3 headless implementation of the Capella modeling tool.
https://dsd-dbs.github.io/py-capellambse/
Apache License 2.0
52 stars 10 forks source link

Capella model loading failure due to Duplicate UUID #414

Closed Luffy-cpu closed 5 months ago

Luffy-cpu commented 5 months ago

Hello everyone,

I'm trying to load a Capella model located in a local git repository and I get the following error message: capellambse.loader.core.CorruptModelError: Duplicate UUID 'XXXX' within fragment My_Model.aird

Can anyone help me fixing the problem, please?

Regards

Wuestengecko commented 5 months ago

Hi! That's a somewhat known bug that occasionally happens, and as long as it's only within the *.aird file it's actually safe to ignore (things change a bit when it comes up in a *.capella file). You can still load the model by setting this option:

model = capellambse.MelodyModel(
    ...,
    ignore_duplicate_uuids_and_void_all_warranties=True,
)

(Don't worry. It sounds scarier than it is, because when we first discovered it we weren't sure what would happen ourselves. ;) )

vik378 commented 5 months ago

@Luffy-cpu , Capella can mess-up models sometimes but it will not complain about it, it will just take an element and go with it (not sure though if first or last XD. If you use capellambse lib to edit models, a model with such issue is "unsafe" for modifications / can get further messed up, you should clean it up first - locate the duplicate elements in XML and choose which of those you want to keep or delete - but at the end there shall only one element remain with that UUID. However, if you are using library to simply check things / read content / produce some reports - not to modify the model - you can do what @Wuestengecko suggested above and simply ignore the duplicates. @Wuestengecko , we may want to update the docs so that it is a bit easier to get on track when you face such exception.

Luffy-cpu commented 5 months ago

Hello again, Thank you very much @Wuestengecko & @vik378. Both of your answers are very useful for me.

Luffy-cpu commented 5 months ago

Issue solved :)