You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, if a user were to only look at the initialization parameters, and wanted to add a ConceptDictionary later, after initalization, they could theoretically assume, they could set it like this:
This would have terrible results when iterating over ObjectStores containing these objects, since suddenly, we'd get the (not very helpful) error:
AttributeError: 'list' object has no attribute 'update_nss_from'
This obviously points nowhere in the right direction.
I have the suspicion, that this is not the only time, where such a problem may arise. How can we restrrict the user from making such a mistake in the first place? Should we write getter and setter functions for these kinds of attributes? On the other hand, maybe this is something to be checked by the ObjectStore, when adding an item to it?
The text was updated successfully, but these errors were encountered:
A typechecker will catch the error of assigning a list where a NamespaceSet is expected. So if the user uses a typechecker (which they should), this won't be an issue. If the user on the other hand assigns a different NamespaceSet to the attribute, I think they should know how to use a NamespaceSet correctly, which is described by the docstring.
We could provide a setter function for the attributes where a NamespaceSet is expected just for usability reasons (I've done that for the OrderedNamespaceSet of SubmodelElementList for example).
You're right, a type-checker would have caught that.
Nevertheless, I'm all for your suggestion of writing setter-functions on attributes where a NamespaceSet is expected. I'll adapt the issue accordingly.
s-heppner
changed the title
Confusion when adding ConceptDescription after instantiation of AssetAdministrationShell
Add setter-functions for object attributes that consist of NamespaceSets
Apr 18, 2023
When instantiating an
AssetAdministrationShell
-object, we hand overConceptDictionary
s in any kind ofIterable
(See here)However, internally, we create a
NamespaceSet
containing theseConceptDictionary
s in order to be able to resolve them later:Now, if a user were to only look at the initialization parameters, and wanted to add a
ConceptDictionary
later, after initalization, they could theoretically assume, they could set it like this:This would have terrible results when iterating over
ObjectStore
s containing these objects, since suddenly, we'd get the (not very helpful) error:This obviously points nowhere in the right direction.
I have the suspicion, that this is not the only time, where such a problem may arise. How can we restrrict the user from making such a mistake in the first place? Should we write getter and setter functions for these kinds of attributes? On the other hand, maybe this is something to be checked by the
ObjectStore
, when adding an item to it?The text was updated successfully, but these errors were encountered: