Commit c134421a authored by David Mendez's avatar David Mendez

Merge branch 'staging' into 'master'

Allow to set up a specific rate limit for updating the job progress

See merge request !27
parents 6b7394a5 c9099706
......@@ -9,13 +9,15 @@ from app.authorisation.decorators import token_required_for_job_id
from app.blueprints.job_status.services import job_status_service
from app.blueprints.job_status.controllers import marshmallow_schemas
from app.request_validation.decorators import validate_form_with, validate_url_params_with
from app.rate_limiter import RATE_LIMITER
from app.config import RUN_CONFIG
JOB_STATUS_BLUEPRINT = Blueprint('job_status', __name__)
@JOB_STATUS_BLUEPRINT.route('/<job_id>', methods = ['GET'])
@JOB_STATUS_BLUEPRINT.route('/<job_id>', methods=['GET'])
@validate_url_params_with(marshmallow_schemas.JobStatus)
def get_job_status(job_id):
try:
# remove scheme so client can decide which one to use
raw_host_url = request.host_url
......@@ -25,26 +27,27 @@ def get_job_status(job_id):
except job_status_service.JobNotFoundError:
abort(404)
@JOB_STATUS_BLUEPRINT.route('/inputs/<job_id>/<input_key>', methods = ['GET'])
@JOB_STATUS_BLUEPRINT.route('/inputs/<job_id>/<input_key>', methods=['GET'])
@validate_url_params_with(marshmallow_schemas.JobInputFileRequest)
def get_job_input(job_id, input_key):
try:
input_file_path = job_status_service.get_input_file_path(job_id, input_key)
return send_file(input_file_path)
except job_status_service.InputFileNotFoundError:
abort(404)
@JOB_STATUS_BLUEPRINT.route('/<job_id>', methods = ['PATCH'])
@JOB_STATUS_BLUEPRINT.route('/<job_id>', methods=['PATCH'])
@token_required_for_job_id
@validate_url_params_with(marshmallow_schemas.JobStatus)
@validate_form_with(marshmallow_schemas.JobStatusUpdate)
@RATE_LIMITER.limit(RUN_CONFIG.get('rate_limit').get('rates').get('job_progress_update'))
def update_job_progress(job_id):
try:
progress = int(request.form.get('progress'))
status_log = request.form.get('status_log')
status_description = request.form.get('status_description')
return jsonify(job_status_service.update_job_progress(job_id, progress, status_log, status_description))
except job_status_service.JobNotFoundError:
abort(500, 'Job was deleted...')
\ No newline at end of file
abort(500, 'Job was deleted...')
......@@ -105,6 +105,7 @@ DEFAULT_RATE_LIMIT = {
'default_for_all_routes': '3 per second',
'admin_login': '3 per second',
'job_submission': '10 per minute',
'job_progress_update': '30 per second',
},
'storage_url': 'memory://'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment