Commit bae44e04 authored by David Mendez's avatar David Mendez
Browse files

Downloads: add controller to handle the submission requests

parent fc5f4034
......@@ -11,6 +11,7 @@ from app.namespaces.job_submission.submit_similarity_controller import API as su
from app.namespaces.job_submission.submit_substructure_controller import API as submit_substructure_search_namespace
from app.namespaces.job_submission.submit_connectivity_controller import API as submit_connectivity_search_namespace
from app.namespaces.job_submission.submit_blast_controller import API as submit_blast_search_namespace
from app.namespaces.job_submission.submit_download_controller import API as submit_download_namespace
from app.namespaces.job_statistics.record_search_controller import API as record_search_namespace
from app.namespaces.job_statistics.record_download_controller import API as record_download_namespace
from app.db import DB
......@@ -61,7 +62,7 @@ def create_app():
for namespace in [job_admin_namespace, job_status_namespace, submit_test_job_namespace,
submit_similarity_search_namespace, submit_substructure_search_namespace,
submit_connectivity_search_namespace, submit_blast_search_namespace, record_search_namespace,
record_download_namespace]:
record_download_namespace, submit_download_namespace]:
api.add_namespace(namespace)
return flask_app
......
"""
Module that describes and handles the requests concerned with the downloads
"""
from flask import request
from flask_restplus import Namespace, Resource, fields
from app.namespaces.job_submission.shared_marshalls import BASE_SUBMISSION_RESPONSE
from app.namespaces.models import delayed_job_models
from app.namespaces.job_submission import job_submission_service
API = Namespace('submit/download', description='Namespace to submit a download job')
DOWNLOAD_JOB = API.model('DownloadJob', {
'index_name': fields.String(description='The index against you want to make the download',
required=True, example='chembl_molecule'),
'query': fields.String(description='Query to execute against the index to get the items',
required=True, example='{"bool":{"must":[{"query_string":'
'{"analyze_wildcard":true,"query":"*"}}],"filter":[[{"bool":'
'{"should":[{"term":{"molecule_type":"Antibody"}}]}}]]}}'),
'format': fields.String(description='Format of the download (SDF is available for the chembl_molecule index only)',
required=True, example='SVG', enum=['CSV', 'TSV', 'SDF']),
'download_columns_group': fields.String(description='Group that summarises and describes the columns that you want '
'to download. See for example: https://www.ebi.ac.uk/chembl/'
'glados_api/shared/properties_configuration/group/'
'chembl_molecule/download/', example='download'),
'context_id': fields.String(description='Id of the results of another job to join to the download. '
'Useful to join structure or sequence search results.'),
})
SUBMISSION_RESPONSE = API.inherit('SubmissionResponse', BASE_SUBMISSION_RESPONSE)
@API.route('/')
class SubmitConnectivityJob(Resource):
"""
Resource that handles download job submission requests
"""
job_type = delayed_job_models.JobTypes.DOWNLOAD
@API.expect(DOWNLOAD_JOB)
@API.doc(body=DOWNLOAD_JOB)
@API.marshal_with(SUBMISSION_RESPONSE)
def post(self): # pylint: disable=no-self-use
"""
Submits a job to the queue.
:return: a json response with the result of the submission
"""
json_data = request.json
response = job_submission_service.submit_job(self.job_type, json_data)
return response
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