-
Notifications
You must be signed in to change notification settings - Fork 9
Add CLI to generate models from schemas #105
Description
This command should walk the schemas host, collect every current schema, and use https://github.com/koxudaxi/datamodel-code-generator/ to generate Python code such that metadata objects can be represented by a Python object by consumers.
Every JSON schema can be collected by walking through https://main-fmu-schemas-prod.radix.equinor.com/schemas/?json=true (or the dev endpoint).
This command could potentially generate a simple interface to return one of these generated objects if metadata json or yaml is fed into it. Alternatively, that interface could be left to consumers to customize to their needs.
The command should not be prefaced with fmu- to not pollute that interface. It should perhaps begin with codegen- or ...
The command can reference
fmu-datamodels/src/fmu/datamodels/_schema_urls.py
Lines 12 to 13 in bf52952
| DEV_URL: Final[str] = "https://main-fmu-schemas-dev.radix.equinor.com" | |
| PROD_URL: Final[str] = "https://main-fmu-schemas-prod.radix.equinor.com" |
to get the url, so that the user only needs to provide 'dev' or 'prod', with a default of prod. The command can optionally take a path to output the generated code into, with a sane default.
Related issue: #30