- Creating a new new object when it isn't supposed - Serializing enum field
This commit is contained in:
parent
bfe2ec8c8c
commit
7a9d098107
@ -1,13 +1,16 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from marshmallow import fields
|
from marshmallow import fields
|
||||||
from marshmallow_sqlalchemy import ModelSchema
|
from marshmallow_sqlalchemy import ModelSchema
|
||||||
from model import AIModel
|
from marshmallow_enum import EnumField
|
||||||
|
from model import AIModel, AIModelType
|
||||||
|
|
||||||
|
|
||||||
class AIModelSchema(ModelSchema):
|
class AIModelSchema(ModelSchema):
|
||||||
|
|
||||||
default = fields.Method("boolize_default", dump_only=True)
|
default = fields.Method("boolize_default", dump_only=True)
|
||||||
|
|
||||||
|
type = EnumField(AIModelType)
|
||||||
|
|
||||||
def boolize_default(self, ai_model) -> bool:
|
def boolize_default(self, ai_model) -> bool:
|
||||||
return bool(ai_model.default)
|
return bool(ai_model.default)
|
||||||
|
|
||||||
|
@ -60,8 +60,6 @@ class CNNView(FlaskView):
|
|||||||
storage.connection.put_object(current_app.config['MINIO_CNN_BUCKET_NAME'], "weights/" + str(m.id), weights_file,
|
storage.connection.put_object(current_app.config['MINIO_CNN_BUCKET_NAME'], "weights/" + str(m.id), weights_file,
|
||||||
weights_file.content_length, content_type=weights_file.content_type)
|
weights_file.content_length, content_type=weights_file.content_type)
|
||||||
|
|
||||||
m = AIModel(id=info['id'], type=AIModelType.CNN)
|
|
||||||
|
|
||||||
db.session.add(m)
|
db.session.add(m)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user