Skip to content

Commit a5e1f33

Browse files
Fix error: update enumeration instantiator logic
1 parent 8642428 commit a5e1f33

File tree

4 files changed

+12
-23
lines changed

4 files changed

+12
-23
lines changed

core/esmf-aspect-meta-model-python/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,3 @@ poetry run tox -e pep8
218218
# run tests
219219
poetry run tox -e py310
220220
```
221-
222-
## GitHub actions
223-
224-
There are two actions on the GitHub repo:
225-
- [Check New Pull Request](../../.github/workflows/push_request_check.yml)
226-
- [Build release](../../.github/workflows/tagged_release.yml)
227-
228-
### Check New Pull Request
229-
This action run after creation or updating a pull request and run all automation tests with tox command.
230-
231-
### Build release
232-
Prepare and publish a new release for the `esmf-aspect-model-loader` to the PyPi:
233-
[esmf-aspect-model-loader](https://pypi.org/project/esmf-aspect-model-loader/.)
234-
235-
A list of the available releases on the GitHub:
236-
[Releases](https://github.com/eclipse-esmf/esmf-sdk-py-aspect-model-loader/releases).

core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/instantiator/enumeration_instantiator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ def __to_enum_node_value(self, value_node: Node) -> typing.Dict:
7373
return value
7474

7575
else:
76-
# illegal node type for enumeration value (e.g., Blank Node)
77-
raise TypeError(
78-
f"Every value of an enumeration must either be a Literal (string, int, etc.) or "
79-
f"a URI reference to a ComplexType. Values of type {type(value_node).__name__} are not allowed"
80-
)
76+
if not isinstance(value_node, rdflib.term.BNode) or value_node == rdflib.namespace.RDF.nil:
77+
# illegal node type for enumeration value (e.g., Blank Node)
78+
raise TypeError(
79+
f"Every value of an enumeration must either be a Literal (string, int, etc.) or "
80+
f"a URI reference to a ComplexType. Values of type {type(value_node).__name__} are not allowed"
81+
)
8182

8283
def __is_collection_value(self, property_subject: str) -> bool:
8384
characteristic = self._aspect_graph.value( # type: ignore

core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/samm_graph.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ def to_python(self, aspect_urn: URIRef | str = "") -> List[Aspect]:
107107
"""Convert SAMM graph to Python objects."""
108108
base_nodes = self.get_base_nodes(aspect_urn)
109109
if not base_nodes:
110-
raise ValueError(f"Could not found Aspect node by the URN {aspect_urn}.")
110+
error_message = f"Could not found Aspect node in the model"
111+
if aspect_urn:
112+
error_message += f" by the URN {aspect_urn}"
113+
114+
raise ValueError(error_message)
111115

112116
model_element_factory = ModelElementFactory(self._samm_version, self._graph, self._cache)
113117
aspect_elements = model_element_factory.create_all_graph_elements(base_nodes)

core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _validate_samm_version(samm_version: str):
7676
"""
7777
if not samm_version:
7878
raise ValueError("SAMM version not found in the Graph.")
79-
elif samm_version != SammUnitsGraph.SAMM_VERSION:
79+
elif samm_version > SammUnitsGraph.SAMM_VERSION:
8080
raise ValueError(f"{samm_version} is not supported SAMM version.")
8181

8282
def _get_samm_version_from_graph(self):

0 commit comments

Comments
 (0)