There's been some discussion about how it would be useful to have models for creating and validating farmOS records. I think this library would be a great place to provide such models for Python, and would allow us to do it in a very "pythonic" way.
Models could be stored under a farmOS.models module and be imported like from farmOS.models import log, area, asset
I'd like to propose we use pydantic for this - https://pydantic-docs.helpmanual.io/. Basically, this library allows you to define models which are classes that inherit from the pydantic BaseModel class which already has a bunch of properties and features built in. You can easily create objects from the models you define, and pass them around as if they were types in a strictly typed language.
Another benefit is that the farmOS-aggregator could use these models to further document it's auto-generated OpenAPI schema. Other tools such as SQLAlchemy have support for pydantic models as well. I'm sure there are lots of other benefits.
There's been some discussion about how it would be useful to have models for creating and validating farmOS records. I think this library would be a great place to provide such models for Python, and would allow us to do it in a very "pythonic" way.
Models could be stored under a
farmOS.models
module and be imported likefrom farmOS.models import log, area, asset
I'd like to propose we use
pydantic
for this - https://pydantic-docs.helpmanual.io/. Basically, this library allows you to definemodels
which are classes that inherit from the pydanticBaseModel
class which already has a bunch of properties and features built in. You can easily createobjects
from the models you define, and pass them around as if they weretypes
in a strictly typed language.Another benefit is that the farmOS-aggregator could use these models to further document it's auto-generated OpenAPI schema. Other tools such as SQLAlchemy have support for pydantic models as well. I'm sure there are lots of other benefits.