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

Set id_short of Identifiables to optional #139

Merged
merged 6 commits into from
Oct 19, 2023

Conversation

zrgt
Copy link
Contributor

@zrgt zrgt commented Oct 16, 2023

This commit extends bffb075 and fixes #138

This PR depends on #133

jkhsjdhjs and others added 6 commits October 12, 2023 18:31
Constraint AASd-120 requires direct children of a `SubmodelElementList`
to have id_short=None. On the contrary, `SubmodelElementList` must be a
Namespace, since children of Lists must still be referable via
References, and also must be allowed to reference their parent, which
is expected to be a Namespace.
Since id_short=None must hold for all direct children, they lack
a unique identifying attribute, that can be used to refer to an
item. However, this is required for a Namespace.

Thus, we had two options for implementing this:
- Refactor a lot of the model.base module such that `SubmodelElementLists`
  are considered Namespaces
- Generate a unique id_short for every direct children of a
  `SubmodelElementList` whenever it is added.

Since the first alternative would require a distinction for
`SubmodelElementList` in all places where a `Namespace` is used, we
decided on the second alternative.

This commit implements the generation of unique id_shorts via the
`item_id_set_hook`, that was recently added to `NamespaceSet` and
`OrderedNamespaceSet`. It is called for every added SubmodelElement.
Furthermore, the `item_id_del_hook` is called for every removed
SubmodelElement and used to remove the generated id_short again.

This aside, the examples and unit tests are also adjusted such that the
id_short is removed for all direct children of `SubmodelElementList`.
Furthermore, a test for `AASd-120` is added.
The AASDataChecker is adjusted to skip the comparison of id_short for
direct children of `SubmodelElementList`, since these are generated and
thus never the same now.
For the same reason, the XML/JSON serialisation is adjusted to skip
serialising the id_short if direct children of a `SubmodelElementList`.
…ntList`

Since direct children of `SubmodelElementList` don't have an identifying
attribute anymore (AASd-120), they cannot be compared because it is
impossible to know which SubmodelElement should be compared against
which other element. Maybe this can be implemented again in the future,
when hashing is implemented for all SubmodelElements, but for now we
raise a `NotImplementedError`.

A test-case for this behavior is added and `order_relevant` is set to
`true` in all example files.
This commit applies the following changes to all test-files:
- The id_short of direct children of a `SubmodelElementList` is removed
- `SubmodelElementList.order_relevant` is set to true for all
  `SubmodelElementList`s
As default value of Submodel.id_short, ConceptDescription.id_short, AAS.id_short is set to None, test files had to be updated.
s-heppner added a commit that referenced this pull request Oct 19, 2023
In order to be able to merge #139, we need to manually adapt the
aasx test files.

This commit is yet another reason for why we should stop using
binary test files.
@s-heppner
Copy link
Contributor

Looks good to me. However I really started to dislike the binary aasx test files.

@s-heppner s-heppner merged commit 7c21edf into eclipse-basyx:improve/V30 Oct 19, 2023
@s-heppner s-heppner deleted the fix/id_short branch October 19, 2023 11:46
@s-heppner s-heppner added the v3.0 label Nov 21, 2023
Frosty2500 pushed a commit to rwth-iat/basyx-python-sdk that referenced this pull request Aug 22, 2024
In order to be able to merge eclipse-basyx#139, we need to manually adapt the
aasx test files.

This commit is yet another reason for why we should stop using
binary test files.
Frosty2500 pushed a commit to rwth-iat/basyx-python-sdk that referenced this pull request Aug 22, 2024
Set `id_short` of `Identifiables` to optional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants