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

Support pydantic code generation #5

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open

Support pydantic code generation #5

wants to merge 34 commits into from

Conversation

chicco785
Copy link
Member

@chicco785 chicco785 commented Jul 29, 2023

Description

Support pydantic code generation

Changes Made

  • generate a new langpack for pydantic
  • support EQ and GL profiles
  • support enums correctly
  • leverage python native data types (without need of duplicating them e.g. Boolean for bool)
  • support geo dataypes for easier manipulation and query
  • support cyclic references by stripping them to the first level during serialization
  • Work around for potential issue in CIM schema: Multiplicity of PowerSystemResources attribute in Location is set to be M:1, but should be M:1..N

Related Issues

Fixes #3

Checklist

  • I have used a PR title that is descriptive enough for a release note.
  • I have tested these changes locally.
  • I have added appropriate tests or updated existing tests.
  • I have tested these changes on a dedicated VM or a customer VM [name of the VM]
  • I have added appropriate documentation or updated existing documentation.

@chicco785 chicco785 self-assigned this Jul 29, 2023
@chicco785 chicco785 added the feature This issue/PR relates to a feature request. label Jul 29, 2023
@chicco785
Copy link
Member Author

testing the code generated revealed that:

  • due to recursion of the model the approach of generating 1 file per class is not possible as a solution, pydantic validation will fail with several errors
  • assigning default None to fields where the value is optional, causes recursion error. this implies though, we have to pass a value (None or [] for lists) when creating instances
  • having too large pydantic schema, causes recursion error, so the version of the code generates only EQ classes

@chicco785
Copy link
Member Author

There may be some bugs in the CIM schema, in particular:

  • Multiplicity of PowerSystemResources attribute in Location is set to be M:1, but should be M:1..N.

@chicco785
Copy link
Member Author

to test:

@chicco785
Copy link
Member Author

to test:

this eventually will be handled in a separate pr corresponding issues will be opened.

@chicco785 chicco785 marked this pull request as ready for review August 3, 2023 07:29
@chicco785
Copy link
Member Author

@MarcoPignati also alliander is working on something similar with a slight different approach, it's worth having a chat with them: sogno-platform#18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Support pydantic code generation
2 participants