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

[BUG] The import/export of JSON in PE is not working when using JSON serialization/deserialization with the basyx-python-sdk. #254

Open
JS-Aibel opened this issue Oct 1, 2024 · 4 comments
Labels
bug Something isn't working Needs: Author Feedback Waiting for information/ feeadback from issue's author

Comments

@JS-Aibel
Copy link

JS-Aibel commented Oct 1, 2024

Describe the bug
When using the methods in the basyx-python-sdk to serialize a submodel to a JSON file, the file can not be imported in the Package Explorer with the use of Import Submodel from JSON.

To Reproduce
By using the basyx-python-sdk do the following.

  1. Create a submodel
  2. Serialize the submodel to a JSON file
  3. Code to reproduce:
#!/usr/bin/env python3
from basyx.aas import model
import basyx.aas.adapter.json

identifier = 'https://acplt.org/Simple_Submodel'
submodel = model.Submodel(id_=identifier)

obj_store: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
obj_store.add(submodel)

with open('data.json', "w") as file:
    basyx.aas.adapter.json.write_aas_json_file(file, obj_store)
  1. Open an AAS with the Package Explorer
  2. In Package Explorer go toFile -> Import -> Import Submodel from JSONand select the JSON file
  3. Error message in Package Explorer occurs: Submodel Read: No valid Submodel, Env, source file selected
  4. An error still occurs after trying the workaround in Import Submodel as JSON · Issue #30 · eclipse-aaspe/package-explorer (github.com)
    Error: Submodel Read: Can not read SubModel.: Unexpected property

Expected behavior
Import/export in PE should work with the sdk's serialization/deserialization.

Additional context
Deserialization of a file from Package Explorer Export Submodel from JSON into basyx-python-sdk does not work either.

@StenGruener
Copy link

+1

@JS-Aibel
Copy link
Author

JS-Aibel commented Oct 3, 2024

It seems like the sdk serialization starts with a key ‘submodels’, which is an array of submodels. While the Package Explorer is serializing as a submodel key/value pair, except for it missing the attribute modelType, it looks like an element in the submodels array from the serialization.

  • Removing the array from the sdk serialization endpoint makes Package Explorer able to import the JSON file.
  • Adding an array of type ‘submodels’ to the file created with Package Explorer Export Submodel from JSON made the deserialization with the basyx-python-sdk work.

I guess the question is whether the SDK or the Package Explorer needs to be changed to improve their interoperability?

@juileetikekar
Copy link
Contributor

Hi @JS-Aibel,

Could you please share the JSON file that can be used to reproduce this issue at AASPE end?

@juileetikekar juileetikekar added the Needs: Author Feedback Waiting for information/ feeadback from issue's author label Oct 14, 2024
@JS-Aibel
Copy link
Author

Thank you for the reply, @juileetikekar.

JSON form basyx-python-sdk

{
    "submodels": [
        {
            "modelType": "Submodel",
            "id": "https://acplt.org/Simple_Submodel"
        }
    ]
}

By removing the submodels array, leaving only the single element, Package Explorer is able to import the submodel. Could it be possible that when Package Explorer encounters a "submodels" array, it should import each element within that array?

Modified Version of JSON with ‘Submodels’ Array Removed

{
    "modelType": "Submodel",
    "id": "https://acplt.org/Simple_Submodel"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Needs: Author Feedback Waiting for information/ feeadback from issue's author
Projects
None yet
Development

No branches or pull requests

3 participants