aiidateam / aiida-restapi

AiiDA Web API for data queries and workflow management.
https://aiida-restapi.readthedocs.io
MIT License
10 stars 7 forks source link

infer models from ORM / AiiDA DB layer #1

Open ltalirz opened 3 years ago

ltalirz commented 3 years ago

Reimplementing the entity models (node, user, ...) from scratch is quite straightforward with pydantic, and probably the quickest way to start.

Ideally, at some point however we should try to infer the models, either from AiiDA's public ORM interface or from the underlying django/sqlalchemy DB models.

Note: An intermediate solution may be to embed the pydantic models in the ORM in some way in order to at least keep these two close together.

chrisjsewell commented 3 years ago

As noted in https://github.com/aiidateam/aiida-restapi/issues/26#issuecomment-861421127, technically, we should maybe be getting this information from subclasses of aiida/orm/implementation/entities.py::BackendEntity or aiida/orm/entities.py:Entity. But neither of these really provides an easy (programmatic) way to retrieve the "fields" required either to instantiate an entity (their name, type and description), or the "fields" that can be used with the QueryBuilder. This is compounded by the fact you have these disconnects with the QueryBuilder, like name -> label for computers.