model-service/model_service/schemas/aimodel_schema.py
marcsello 7a9d098107
All checks were successful
continuous-integration/drone/push Build is passing
Fixed stuff
- Creating a new new object when it isn't supposed
- Serializing enum field
2020-09-14 03:02:31 +02:00

19 lines
443 B
Python

#!/usr/bin/env python3
from marshmallow import fields
from marshmallow_sqlalchemy import ModelSchema
from marshmallow_enum import EnumField
from model import AIModel, AIModelType
class AIModelSchema(ModelSchema):
default = fields.Method("boolize_default", dump_only=True)
type = EnumField(AIModelType)
def boolize_default(self, ai_model) -> bool:
return bool(ai_model.default)
class Meta:
model = AIModel