Did done
This commit is contained in:
parent
87d74f3563
commit
40d20b2fa9
@ -13,6 +13,9 @@ from pyAudioAnalysis.audioTrainTest import load_model, load_model_knn
|
|||||||
|
|
||||||
class ModelView(FlaskView):
|
class ModelView(FlaskView):
|
||||||
aimodel_schema = AIModelSchema(many=False)
|
aimodel_schema = AIModelSchema(many=False)
|
||||||
|
aimodels_schema = AIModelSchema(many=True,
|
||||||
|
exclude=['timestamp', 'mid_window', 'mid_step', 'short_window', 'short_step',
|
||||||
|
'compute_beat'])
|
||||||
default_schema = DefaultSchema(many=False)
|
default_schema = DefaultSchema(many=False)
|
||||||
info_schema = InfoSchema(many=False)
|
info_schema = InfoSchema(many=False)
|
||||||
|
|
||||||
@ -28,6 +31,10 @@ class ModelView(FlaskView):
|
|||||||
pass
|
pass
|
||||||
# Everything else should be raised
|
# Everything else should be raised
|
||||||
|
|
||||||
|
def index(self):
|
||||||
|
models = AIModel.query.all()
|
||||||
|
return jsonify(self.aimodels_schema.dump(models)), 200
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
|
|
||||||
# get important data from the request
|
# get important data from the request
|
||||||
@ -88,8 +95,8 @@ class ModelView(FlaskView):
|
|||||||
os.remove(temp_model_filename)
|
os.remove(temp_model_filename)
|
||||||
os.remove(temp_means_filename)
|
os.remove(temp_means_filename)
|
||||||
|
|
||||||
m = AIModel(mid_window=mid_window, mid_step=mid_step, short_window=short_window, short_step=short_step,
|
m = AIModel(id=info['id'], mid_window=mid_window, mid_step=mid_step, short_window=short_window,
|
||||||
compute_beat=compute_beat, type=info['type'])
|
short_step=short_step, compute_beat=compute_beat, type=info['type'])
|
||||||
|
|
||||||
db.session.add(m)
|
db.session.add(m)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
@ -100,11 +107,21 @@ class ModelView(FlaskView):
|
|||||||
|
|
||||||
if _id == "$default":
|
if _id == "$default":
|
||||||
default = Default.query.first_or_404() # TODO: Kitalálni, hogy inkább a latestestest-el térjen-e vissza
|
default = Default.query.first_or_404() # TODO: Kitalálni, hogy inkább a latestestest-el térjen-e vissza
|
||||||
m = default.default
|
m = default.aimodel
|
||||||
else:
|
else:
|
||||||
m = AIModel.query.fiter_by(id=_id).first_or_404()
|
m = AIModel.query.filter_by(id=_id).first_or_404()
|
||||||
|
|
||||||
return "asd"
|
if "means" in request.args:
|
||||||
|
bucket = current_app.config['MINIO_MEANS_BUCKET_NAME']
|
||||||
|
else:
|
||||||
|
bucket = current_app.config['MINIO_MODEL_BUCKET_NAME']
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = storage.connection.get_object(bucket, str(m.id))
|
||||||
|
except NoSuchKey:
|
||||||
|
abort(500, "The ID is stored in the database but not int the Object Store")
|
||||||
|
|
||||||
|
return Response(data.stream(), mimetype=data.headers['Content-type'])
|
||||||
|
|
||||||
@route('<_id>/details')
|
@route('<_id>/details')
|
||||||
def get_details(self, _id: str):
|
def get_details(self, _id: str):
|
||||||
@ -123,7 +140,7 @@ class ModelView(FlaskView):
|
|||||||
default = Default.query.first_or_404()
|
default = Default.query.first_or_404()
|
||||||
m = default.aimodel
|
m = default.aimodel
|
||||||
else:
|
else:
|
||||||
m = AIModel.query.fiter_by(id=_id).first_or_404()
|
m = AIModel.query.filter_by(id=_id).first_or_404()
|
||||||
|
|
||||||
storage.connection.remove_object(current_app.config['MINIO_MODEL_BUCKET_NAME'], str(m.id))
|
storage.connection.remove_object(current_app.config['MINIO_MODEL_BUCKET_NAME'], str(m.id))
|
||||||
storage.connection.remove_object(current_app.config['MINIO_MEANS_BUCKET_NAME'], str(m.id))
|
storage.connection.remove_object(current_app.config['MINIO_MEANS_BUCKET_NAME'], str(m.id))
|
||||||
|
Loading…
Reference in New Issue
Block a user