Added checking of target class name is valid
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2020-10-01 21:30:41 +02:00
parent 9c189d1447
commit 0755d8453e
2 changed files with 6 additions and 3 deletions

View File

@ -32,8 +32,8 @@ app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URI', "sqlite:/
app.config['MINIO_ENDPOINT'] = os.environ['MINIO_ENDPOINT']
app.config['MINIO_ACCESS_KEY'] = os.environ['MINIO_ACCESS_KEY']
app.config['MINIO_SECRET_KEY'] = os.environ['MINIO_SECRET_KEY']
app.config['MINIO_SVM_BUCKET_NAME'] = os.environ['MINIO_SVM_BUCKET_NAME']
app.config['MINIO_CNN_BUCKET_NAME'] = os.environ['MINIO_CNN_BUCKET_NAME']
app.config['MINIO_SVM_BUCKET_NAME'] = os.environ.get('MINIO_SVM_BUCKET_NAME', 'svm')
app.config['MINIO_CNN_BUCKET_NAME'] = os.environ.get('MINIO_CNN_BUCKET_NAME', 'cnn')
app.config['MINIO_SECURE'] = os.environ.get('MINIO_SECURE', False)
app.config['MINIO_REGION'] = os.environ.get('MINIO_REGION', None)

View File

@ -61,9 +61,12 @@ class SVMView(FlaskView):
try:
_, _, _, _, mid_window, mid_step, short_window, short_step, compute_beat \
_, _, _, classes, mid_window, mid_step, short_window, short_step, compute_beat \
= load_model(temp_model_filename)
if info['target_class_name'] not in classes:
abort(400, f"This model does not have a class named {info['target_class_name']}")
# Because of pyAudiomeme the files already saved, so we just use the file uploader functions
storage.connection.fput_object(
current_app.config['MINIO_SVM_BUCKET_NAME'],