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

Add support for deserializing python types #37

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

glopesdev
Copy link
Member

@glopesdev glopesdev commented Mar 10, 2024

This PR adds experimental support for deserializing data model objects from Python.NET types, i.e. from PyObject. This is done by introducing two new generated operators and a new serializer:

  • FromPython is a polymorphic operator which simply calls PyObject.As<T> where T is set to one of the data model types;
  • PyObjectConverter implements IPyObjectDecoder via a dictionary of decoder functions built for each generated type by calling getters for each data type property;
  • PythonNet can now be passed to the tool using --serializer PythonNet to indicate whether to generate the above operators.

The PyObjectConverter operator is a sink which can be placed after CreateRuntime to register the decoder group. The argument for including Python.NET as a serializer library is the growing need for interoperability between Python and workflow types. JSON is often used for this purpose but directly accessing the data models can be both more performant and more convenient for certain applications.

All the groundwork is identical in terms of parsing the schema and generating the types. If we decide adding this feature directly to the tool would not be a good idea, another option would be splitting the tool into a core reusable assembly so it becomes easier to extend Sgen serialization to other languages and protocols.

Example workflow for registering the decoders and converting the output of Eval:

image

@glopesdev glopesdev added the feature New planned feature label Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New planned feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant