eclipse-esmf / esmf-sdk-py-aspect-model-loader

Load Aspect Models in Python
https://pypi.org/project/esmf-aspect-model-loader/
Mozilla Public License 2.0
0 stars 4 forks source link

[Task] Provide more context in case model validation fails #18

Open schabdo opened 11 months ago

schabdo commented 11 months ago

Given the following model, missing a dataType within characteristic Megabyte:

:Health a samm:Aspect ;
   samm:preferredName "Device Health "@en ;
   samm:description "Health of the Device"@en ;
   samm:properties ( :memory ) ;
   samm:operations ( ) ;
   samm:events ( ) .

:memory a samm:Property ;
   samm:description "Used Memory"@en ;
   samm:characteristic :Memory ;
   samm:exampleValue "5000" .

:Memory a samm-c:Measurement ;
   samm:preferredName "Megabyte"@en ;
   samm:description "Amount of memory"@en ;
   samm-c:unit :megabyte .

:megabyte a unit:Unit ;
   samm:commonCode "MB" ;
   samm:referenceUnit unit:byte ;
   samm:symbol "MB" .

Raises the following error, without any chance to figure out which node actually is affected:

File "/esmf_aspect_meta_model_python/loader/instantiator_base.py", line 77, in get_instance
    new_instance = self._create_instance(element_node)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/esmf_aspect_meta_model_python/loader/instantiator/measurement_instantiator.py", line 28, i
    n _create_instance raise TypeError("Data type can't be None.")
TypeError: Data type can't be None.
chris-volk commented 10 months ago

I guess the first performed step was to load an aspect model?

chris-volk commented 10 months ago

For now the easiest solution for you as a user is to valide via SAMM CLI next to working with the Python SDK. An instruction to do that for loading errors shall be implemented as the thrown exception in such cases.