Skip to content
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

Referable.update_from() doesn't update parent namespace #215

Open
jkhsjdhjs opened this issue Jan 4, 2024 · 0 comments · May be fixed by #338
Open

Referable.update_from() doesn't update parent namespace #215

jkhsjdhjs opened this issue Jan 4, 2024 · 0 comments · May be fixed by #338
Labels
bug Something isn't working sdk Something to do with the `sdk` package

Comments

@jkhsjdhjs
Copy link
Contributor

Referable.update_from() patches the self object with the other object by iterating over the attributes of the other objects using the python built-in vars(). vars() only iterates over an objects attributes, not properties e.g. getter/setter functions. The id_short attribute of Referable is a property, which performs additional checks when setting the id_short, such as checking for uniqueness within the namespace by searching the objects contained in the parent object. The actual value of the id_short is stored in the protected attribute _id_short.
Since _id_short is an attribute and id_short is a property, the vars() built-in returns the _id_short attribute instead of the id_short property, which causes update_from() to update the _id_short directly, skipping the setter function and thus the uniqueness check.
This is also the case for the semantic_id property of HasSemantics, which also checks for uniqueness.

A solution proposed by @s-heppner and Michael Thies is to add dictionaries to each class, mapping the protected attributes to the respective property. These dictionaries would then be searched by update_from(), which can then set the property instead of the attribute.

Transferred from: https://git.rwth-aachen.de/acplt/pyi40aas/-/issues/133

@jkhsjdhjs jkhsjdhjs changed the title .update_from() doesn't update parent namespace Referable.update_from() doesn't update parent namespace Jan 4, 2024
@s-heppner s-heppner added the bug Something isn't working label Jan 4, 2024
@s-heppner s-heppner added the sdk Something to do with the `sdk` package label Nov 17, 2024
@zrgt zrgt linked a pull request Nov 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sdk Something to do with the `sdk` package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants