aas-core-works / aas-core3.0-python

Manipulate, verify and de/serialize asset administration shells in Python.
Other
5 stars 1 forks source link

ValueOnly serialization in json #29

Open matgnt opened 7 months ago

matgnt commented 7 months ago

Hi,

I'm starting to use this library because I like to have those things generated from the specs! Good approach I think!

One question or feature request I had is about the serialization.

I'm following the example here:

https://aas-core30-python.readthedocs.io/en/latest/getting_started/jsonize.html

but what I would require in my project is a ValueOnly serialization as described here:

https://industrialdigitaltwin.org/wp-content/uploads/2023/04/IDTA-01002-3-0_SpecificationAssetAdministrationShell_Part2_API.pdf#%5B%7B%22num%22%3A254%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C54%2C788%2C0%5D

My expectation would be to just use the same function

jsonable = aas_jsonization.to_jsonable(environment)

but probably pass in an additional parameter to indicate the desired meta data for serialization, e.g.

jsonable = aas_jsonization.to_jsonable(environment, value_only=True)

Any thoughts on this? Thanks,

-- Matthias Binzer

mristin commented 7 months ago

@matgnt the ValueOnly serialization has a broken design -- so we didn't include it in the library. For example, what happens if your Property has its type set to a xs:double and the value is NaN etc.

Moreover, ValueOnly serialization can not be automatically generated. There are specific rules for each class, and these rules change between the versions of the meta-model. The logic is thus complicated and would require a substantial effort if we want to transpile it.

I think the easiest is to implement the meta-only and value-only serializations by hand. I wouldn't bother patching the original code of this SDK, but instead have parallel de/serialization functions which use the SDK to structure the inputs and the outputs, respectively.

matgnt commented 7 months ago

Hi @mristin thanks for the details. This is very unfortunate. But I can understand the reasoning. Since in Catena-X [1] and its open source community [2] we currently use the ValueOnly serialization, this limits the benefit for us very much, I guess.

Is it possible to add this limitation to the Readme / Documentation?

[1] https://catena-x.net/ [2] https://github.com/eclipse-tractusx/

mristin commented 7 months ago

@matgnt we could add it as a manually-written module to the SDK. Would you be interested to help me with the implementation?