mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
refactor into an API
This commit is contained in:
@@ -352,3 +352,37 @@ class JobController( BaseAPIController, UsesLibraryMixinItems ):
|
||||
if all( list( a.dataset.deleted is False for a in job.output_datasets ) ):
|
||||
out.append( self.encode_all_ids( trans, job.to_dict( 'element' ), True ) )
|
||||
return out
|
||||
|
||||
@expose_api
|
||||
def error( self, trans, id, **kwd ):
|
||||
"""
|
||||
error( trans, id )
|
||||
* POST /api/jobs/{id}/error
|
||||
submits a bug report via the API.
|
||||
|
||||
:type id: string
|
||||
:param id: Encoded job id
|
||||
|
||||
:rtype: dictionary
|
||||
:returns: dictionary containing information regarding where the error report was sent.
|
||||
"""
|
||||
# biostar_report = 'biostar' in str( kwd.get( 'submit_error_report') ).lower()
|
||||
# if biostar_report:
|
||||
# return trans.response.send_redirect( url_for( controller='biostar', action='biostar_tool_bug_report', hda=id, email=email, message=message ) )
|
||||
|
||||
# Get dataset on which this error was triggered
|
||||
try:
|
||||
decoded_dataset_id = self.decode_id( kwd['dataset_id'] )
|
||||
except Exception:
|
||||
raise exceptions.MalformedId()
|
||||
dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( decoded_dataset_id )
|
||||
|
||||
# Get job
|
||||
job = self.__get_job( trans, id )
|
||||
tool = trans.app.toolbox.get_tool( job.tool_id, tool_version=job.tool_version ) or None
|
||||
messages = trans.app.error_reports.default_error_sink.submit_report(
|
||||
dataset, job, tool, user_submission=True, email=kwd.get('email', trans.user.email),
|
||||
message=kwd.get('message', None)
|
||||
)
|
||||
|
||||
return { 'messages': messages }
|
||||
|
||||
@@ -759,6 +759,7 @@ def populate_api_routes( webapp, app ):
|
||||
webapp.mapper.connect( 'job_inputs', '/api/jobs/{id}/inputs', controller='jobs', action='inputs', conditions=dict( method=['GET'] ) )
|
||||
webapp.mapper.connect( 'job_outputs', '/api/jobs/{id}/outputs', controller='jobs', action='outputs', conditions=dict( method=['GET'] ) )
|
||||
webapp.mapper.connect( 'build_for_rerun', '/api/jobs/{id}/build_for_rerun', controller='jobs', action='build_for_rerun', conditions=dict( method=['GET'] ) )
|
||||
webapp.mapper.connect( 'job_error', '/api/jobs/{id}/error', controller='jobs', action='error', conditions=dict( method=['POST'] ) )
|
||||
|
||||
# Job files controllers. Only for consumption by remote job runners.
|
||||
webapp.mapper.resource( 'file',
|
||||
|
||||
@@ -159,18 +159,6 @@ class DatasetInterface( BaseUIController, UsesAnnotations, UsesItemRatings, Uses
|
||||
exit_code = "Invalid dataset ID or you are not allowed to access this dataset"
|
||||
return exit_code
|
||||
|
||||
@web.expose
|
||||
def report_error( self, trans, id, email='', message="", **kwd ):
|
||||
biostar_report = 'biostar' in str( kwd.get( 'submit_error_report') ).lower()
|
||||
if biostar_report:
|
||||
return trans.response.send_redirect( url_for( controller='biostar', action='biostar_tool_bug_report', hda=id, email=email, message=message ) )
|
||||
|
||||
dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( self.decode_id( id ) )
|
||||
job = self._get_job_for_dataset( trans, id )
|
||||
tool = trans.app.toolbox.get_tool(job.tool_id, tool_version=job.tool_version) or None
|
||||
messages = trans.app.error_reports.default_error_sink.submit_report(dataset, job, tool, user_submission=True, email=email, message=message)
|
||||
return trans.show_messages(messages)
|
||||
|
||||
@web.expose
|
||||
def default(self, trans, dataset_id=None, **kwd):
|
||||
return 'This link may not be followed from within Galaxy.'
|
||||
|
||||
Reference in New Issue
Block a user