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

Write a pydantic-importer (pydantic class -> LinkML YAML) #88

Open
cmungall opened this issue Aug 17, 2022 · 1 comment
Open

Write a pydantic-importer (pydantic class -> LinkML YAML) #88

cmungall opened this issue Aug 17, 2022 · 1 comment
Labels
good first issue Good for newcomers

Comments

@cmungall
Copy link
Member

cmungall commented Aug 17, 2022

From discussion with @ialarmedalien on slack

Approach 1: can convert to json schema and convert from that https://pydantic-docs.helpmanual.io/usage/schema/ --- but that’s not very satisfactory as there would be loss eg inheritance

Approach 2: write something specific to pydantic using https://pydantic-docs.helpmanual.io/usage/exporting_models/

@ialarmedalien
Copy link

It would be preferable to avoid using the Schema Builder to assemble a set of classes and fields as other formats do, because we already have the class/field set up via pydantic or dataclasses.

Ideally there would be a generator to output an object/class as linkml, so that converting a schema comprising pydantic (or dataclass) classes would be a matter of running the classes through the generator / mixing the generator function into the classes / whatever specific mechanism was chosen. A simple solution could be having the classes be subclasses of YAMLRoot, but without a way to save the transformed schema as linkml, you'd have to do this transform every time you worked with that schema and you would not have the rest of the linkml tools to play with.

@sierra-moxon sierra-moxon changed the title Write a pydantic-importer Write a pydantic-importer (pydantic class -> LinkML YAML) Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants