Implemeted default pooter
This commit is contained in:
parent
f97228b61c
commit
7fcc4bfa37
@ -1,9 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
from marshmallow import fields
|
||||
from marshmallow_sqlalchemy import ModelSchema
|
||||
from model import Default
|
||||
|
||||
|
||||
class DefaultSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = Default
|
||||
id = fields.UUID()
|
||||
|
@ -5,6 +5,7 @@ from flask_classful import FlaskView, route
|
||||
from model import db, Default, AIModel
|
||||
from minio.error import BucketAlreadyExists, BucketAlreadyOwnedByYou, ResponseError, NoSuchKey
|
||||
from schemas import AIModelSchema, DefaultSchema
|
||||
from marshmallow.exceptions import ValidationError
|
||||
from utils import json_required, storage
|
||||
|
||||
|
||||
@ -56,4 +57,17 @@ class ModelView(FlaskView):
|
||||
@json_required
|
||||
@route('$default', methods=['PUT'])
|
||||
def put_default(self):
|
||||
return jsonify({})
|
||||
|
||||
try:
|
||||
req = self.default_schema.load(request.json())
|
||||
except ValidationError as e:
|
||||
abort(404, str(e))
|
||||
|
||||
m = AIModel.query.fiter_by(id=req['id']).first_or_404()
|
||||
|
||||
Default.query.delete()
|
||||
new_default = Default(m)
|
||||
db.session.add(new_default)
|
||||
db.session.commit()
|
||||
|
||||
return jsonify(self.aimodel_schema.dump(m))
|
||||
|
Loading…
Reference in New Issue
Block a user