Skip to content

Commit

Permalink
Update to aas-core-meta, codegen, testgen 0b256cc, a8a510e, e6db7e83 (#6
Browse files Browse the repository at this point in the history
)

We update the development requirements to and re-generate everything
with:
* [aas-core-meta 0b256cc],
* [aas-core-codegen a8a510e] and
* [aas-core3.0-testgen e6db7e83].

Notably, we:

* Fix the dev. script for updates as it omitted
  the test data directory `Xml`,
* Report better errors in xmlization unit tests since we could not
  figure out what went wrong, and
* Fix documentation snippets to excludes ID-shorts due to fixes in
  aas-core-meta.

[aas-core-meta 0b256cc]: aas-core-works/aas-core-meta@0b256cc
[aas-core-codegen a8a510e]: aas-core-works/aas-core-codegen@a8a510e
[aas-core3.0-testgen e6db7e83]: aas-core-works/aas-core3.0-testgen@e6db7e83
  • Loading branch information
mristin authored Mar 22, 2023
1 parent 84a9932 commit 7001e48
Show file tree
Hide file tree
Showing 8,345 changed files with 546 additions and 8,512 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion aas_core3/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
aas_types.KeyTypes.SUBMODEL_ELEMENT_LIST,
}

#: Enumeration of referables.
#: Enumeration of referables. We need this to check that model references refer to a Referable. For example, the observed attribute of the Basic Event Element object must be a model reference to a Referable.
AAS_REFERABLES: Set[aas_types.KeyTypes] = {
aas_types.KeyTypes.ASSET_ADMINISTRATION_SHELL,
aas_types.KeyTypes.CONCEPT_DESCRIPTION,
Expand Down
24 changes: 9 additions & 15 deletions aas_core3/jsonization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,6 @@ def asset_administration_shell_from_jsonable(
exception.path._prepend(PropertySegment(jsonable_value, key))
raise exception

if setter.id_short is None:
raise DeserializationException("The required property 'idShort' is missing")

if setter.id is None:
raise DeserializationException("The required property 'id' is missing")

Expand All @@ -1078,11 +1075,11 @@ def asset_administration_shell_from_jsonable(
)

return aas_types.AssetAdministrationShell(
setter.id_short,
setter.id,
setter.asset_information,
setter.extensions,
setter.category,
setter.id_short,
setter.display_name,
setter.description,
setter.administration,
Expand Down Expand Up @@ -1655,17 +1652,14 @@ def submodel_from_jsonable(jsonable: Jsonable) -> aas_types.Submodel:
exception.path._prepend(PropertySegment(jsonable_value, key))
raise exception

if setter.id_short is None:
raise DeserializationException("The required property 'idShort' is missing")

if setter.id is None:
raise DeserializationException("The required property 'id' is missing")

return aas_types.Submodel(
setter.id_short,
setter.id,
setter.extensions,
setter.category,
setter.id_short,
setter.display_name,
setter.description,
setter.administration,
Expand Down Expand Up @@ -5999,17 +5993,14 @@ def concept_description_from_jsonable(
exception.path._prepend(PropertySegment(jsonable_value, key))
raise exception

if setter.id_short is None:
raise DeserializationException("The required property 'idShort' is missing")

if setter.id is None:
raise DeserializationException("The required property 'id' is missing")

return aas_types.ConceptDescription(
setter.id_short,
setter.id,
setter.extensions,
setter.category,
setter.id_short,
setter.display_name,
setter.description,
setter.administration,
Expand Down Expand Up @@ -8125,7 +8116,8 @@ def transform_asset_administration_shell(
if that.category is not None:
jsonable["category"] = that.category

jsonable["idShort"] = that.id_short
if that.id_short is not None:
jsonable["idShort"] = that.id_short

if that.display_name is not None:
jsonable["displayName"] = [
Expand Down Expand Up @@ -8228,7 +8220,8 @@ def transform_submodel(self, that: aas_types.Submodel) -> MutableJsonable:
if that.category is not None:
jsonable["category"] = that.category

jsonable["idShort"] = that.id_short
if that.id_short is not None:
jsonable["idShort"] = that.id_short

if that.display_name is not None:
jsonable["displayName"] = [
Expand Down Expand Up @@ -9056,7 +9049,8 @@ def transform_concept_description(
if that.category is not None:
jsonable["category"] = that.category

jsonable["idShort"] = that.id_short
if that.id_short is not None:
jsonable["idShort"] = that.id_short

if that.display_name is not None:
jsonable["displayName"] = [
Expand Down
114 changes: 51 additions & 63 deletions aas_core3/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@
be formalized as part of the core library, but affects external components such as
AAS registry or AAS server:
* :ref:`Constraint AASd-022 <constraint_AASd-022>`
We did not implement the following constraints since they depend on registry and
de-referencing, so we can not formalize them with formalizing such external
dependencies:
de-referencing of :py:class:`Reference` objects:
* :ref:`Constraint AASd-006 <constraint_AASd-006>`
* :ref:`Constraint AASd-007 <constraint_AASd-007>`
* :ref:`Constraint AASc-3a-003 <constraint_AASc-3a-003>`
Some constraints are not enforceable as they depend on the wider context
such as language understanding, so we could not formalize them:
* :ref:`Constraint AASd-012 <constraint_AASd-012>`
* :ref:`Constraint AASd-012 <constraint_AASd-012>`: This constraint requires that the texts inside
``Multi_language_property`` shall have the same meanings in the separate languages.
This cannot be tested.
* :ref:`Constraint AASd-116 <constraint_AASd-116>`: In the book, :ref:`Constraint AASd-116 <constraint_AASd-116>` imposes a
case-insensitive equality against ``globalAssetId``. This is culturally-dependent,
and depends on the system settings. For example, the case-folding
Expand All @@ -38,10 +42,10 @@
between the properties and the sets is defined through invariants. This causes
the following divergences:
* We decided therefore to remove the enumerations ``DataTypeDef`` and ``DataTypeDefRDF``
* We decided therefore to remove the enumeration ``DataTypeDefRDF``
and keep only :py:class:`DataTypeDefXSD` as enumeration. Otherwise, we would have
to write redundant invariants all over the meta-model because ``DataTypeDef`` and
``DataTypeDefRDF`` are actually never used in any type definition.
to write redundant invariants all over the meta-model because ``DataTypeDefRDF``
is actually never used in any type definition.
* The enumeration :py:class:`AASSubmodelElements` is used in two different contexts.
One context is the definition of key types in a reference. Another context is
the definition of element types in a :py:class:`SubmodelElementList`.
Expand All @@ -51,19 +55,37 @@
represent the first context (key type in a reference).
Secondly, the enumeration :py:class:`AASSubmodelElements` is kept as designator
for :py:attr:`SubmodelElementList.type_value_list_element`.
* The specification introduces several types of ``Lang_string_set``.
These types differ between the allowed length of their text inside the singular
``Lang_string`` objects. Since the native representation of ``Lang_string_set`` as
``List`` of ``Lang_string`` is required by specification, it is impossible to
introduce separate ``Lang_string_set`` types. Therefore, the distinction is drawn here
between the ``Lang_string`` types.
``DefinitionTypeIEC61360`` is represented as a
``List`` of :py:class:`LangStringDefinitionTypeIEC61360`
``MultiLanguageNameType`` is represented as a
``List`` of :py:class:`LangStringNameType`
``PreferredNameTypeIEC61360`` is represented as a
``List`` of :py:class:`LangStringPreferredNameTypeIEC61360`
``ShortNameTypeIEC61360`` is represented as a
``List`` of :py:class:`LangStringShortNameTypeIEC61360`
``MultiLanguageTextType`` is represented as a
``List`` of :py:class:`LangStringTextType`
Furthermore, since ``Lang_string`` is not used anywhere, we rename it to
:py:class:`AbstractLangString`.
Concerning the data specifications, we embed them within
:py:class:`HasDataSpecification` instead of referencing them *via* a global reference.
:py:class:`HasDataSpecification` instead of referencing them *via* an external reference.
The working group decided to change the rules for serialization *after* the book was
published. The data specifications are critical in applications, but there is no
possibility to access them through a data channel as they are not part of
an environment.
:constraint AASd-022:
.. _constraint_AASd-022:
:py:attr:`Referable.id_short` of non-identifiable referables
within the same name space shall be unique (case-sensitive).
"""


Expand Down Expand Up @@ -326,6 +348,12 @@ class Referable(HasExtensions):
This ID is not globally unique.
This ID is unique within the name space of the element.
:constraint AASd-022:
.. _constraint_AASd-022:
:py:attr:`id_short` of non-identifiable referables
within the same name space shall be unique (case-sensitive).
"""

#: The category is a value that gives further meta information
Expand Down Expand Up @@ -397,37 +425,6 @@ def __init__(
class Identifiable(Referable):
"""An element that has a globally unique identifier."""

#: In case of identifiables this attribute is a short name of the element.
#: In case of referable this ID is an identifying string of the element within
#: its name space.
#:
#: .. note::
#:
#: In case the element is a property and the property has a semantic definition
#: (:py:attr:`HasSemantics.semantic_id`) conformant to IEC61360
#: the :py:attr:`id_short` is typically identical to the short name in English.
#:
#: :py:attr:`id_short` is strengthened to required in this class,
#: see :ref:`Constraint AASd-117 <constraint_AASd-117>`.
id_short: str

# region Strengthening of id_short
@property # type: ignore
def id_short(self) -> str:
# pylint: disable=missing-function-docstring
return self._id_short

@id_short.setter
def id_short(self, new_id_short: Optional[str]) -> None:
if new_id_short is None:
raise ValueError(
"Unexpected None id_short assigned to an instance of Identifiable"
)

self._id_short = new_id_short

# endregion

#: Administrative information of an identifiable element.
#:
#: .. note::
Expand All @@ -441,10 +438,10 @@ def id_short(self, new_id_short: Optional[str]) -> None:

def __init__(
self,
id_short: str,
id: str,
extensions: Optional[List["Extension"]] = None,
category: Optional[str] = None,
id_short: Optional[str] = None,
display_name: Optional[List["LangStringNameType"]] = None,
description: Optional[List["LangStringTextType"]] = None,
administration: Optional["AdministrativeInformation"] = None,
Expand All @@ -455,9 +452,6 @@ def __init__(
)
self.id = id
self.administration = administration
# region Strengthening
self._id_short = id_short
# endregion


class ModellingKind(enum.Enum):
Expand Down Expand Up @@ -965,11 +959,11 @@ def transform_with_context(

def __init__(
self,
id_short: str,
id: str,
asset_information: "AssetInformation",
extensions: Optional[List["Extension"]] = None,
category: Optional[str] = None,
id_short: Optional[str] = None,
display_name: Optional[List["LangStringNameType"]] = None,
description: Optional[List["LangStringTextType"]] = None,
administration: Optional["AdministrativeInformation"] = None,
Expand All @@ -982,10 +976,10 @@ def __init__(
"""Initialize with the given values."""
Identifiable.__init__(
self,
id_short,
id,
extensions,
category,
id_short,
display_name,
description,
administration,
Expand All @@ -994,9 +988,6 @@ def __init__(
self.derived_from = derived_from
self.asset_information = asset_information
self.submodels = submodels
# region Strengthening
self._id_short = id_short
# endregion


class AssetInformation(Class):
Expand Down Expand Up @@ -1485,10 +1476,10 @@ def transform_with_context(

def __init__(
self,
id_short: str,
id: str,
extensions: Optional[List["Extension"]] = None,
category: Optional[str] = None,
id_short: Optional[str] = None,
display_name: Optional[List["LangStringNameType"]] = None,
description: Optional[List["LangStringTextType"]] = None,
administration: Optional["AdministrativeInformation"] = None,
Expand All @@ -1504,10 +1495,10 @@ def __init__(
"""Initialize with the given values."""
Identifiable.__init__(
self,
id_short,
id,
extensions,
category,
id_short,
display_name,
description,
administration,
Expand All @@ -1517,9 +1508,6 @@ def __init__(
Qualifiable.__init__(self, qualifiers)
HasDataSpecification.__init__(self, embedded_data_specifications)
self.submodel_elements = submodel_elements
# region Strengthening
self._id_short = id_short
# endregion


class SubmodelElement(Referable, HasSemantics, Qualifiable, HasDataSpecification):
Expand Down Expand Up @@ -4539,10 +4527,10 @@ def transform_with_context(

def __init__(
self,
id_short: str,
id: str,
extensions: Optional[List["Extension"]] = None,
category: Optional[str] = None,
id_short: Optional[str] = None,
display_name: Optional[List["LangStringNameType"]] = None,
description: Optional[List["LangStringTextType"]] = None,
administration: Optional["AdministrativeInformation"] = None,
Expand All @@ -4554,19 +4542,16 @@ def __init__(
"""Initialize with the given values."""
Identifiable.__init__(
self,
id_short,
id,
extensions,
category,
id_short,
display_name,
description,
administration,
)
HasDataSpecification.__init__(self, embedded_data_specifications)
self.is_case_of = is_case_of
# region Strengthening
self._id_short = id_short
# endregion


class ReferenceTypes(enum.Enum):
Expand Down Expand Up @@ -4761,6 +4746,9 @@ class Key(Class):

#: Denotes which kind of entity is referenced.
#:
#: In case :py:attr:`type` = :py:attr:`KeyTypes.GLOBAL_REFERENCE`,
#: the key represents a reference to a source that can be globally identified.
#:
#: In case :py:attr:`type` = :py:attr:`KeyTypes.FRAGMENT_REFERENCE` the key represents
#: a bookmark or a similar local identifier within its parent element as specified
#: by the key that precedes this key.
Expand Down
Loading

0 comments on commit 7001e48

Please sign in to comment.