[hg] galaxy 2558: Integrate 'rerun' support from Assaf Gordan. N...
details: http://www.bx.psu.edu/hg/galaxy/rev/52ad5635f01a changeset: 2558:52ad5635f01a user: James Taylor <james@jamestaylor.org> date: Thu Aug 13 11:27:45 2009 -0400 description: Integrate 'rerun' support from Assaf Gordan. Not supported for all tools, but checking whether the link should be displayed is expensive currently, this can be improved ghopefully. 2 file(s) affected in this change: lib/galaxy/web/controllers/tool_runner.py templates/root/history_common.mako diffs (118 lines): diff -r ad5232a4dbc5 -r 52ad5635f01a lib/galaxy/web/controllers/tool_runner.py --- a/lib/galaxy/web/controllers/tool_runner.py Thu Aug 13 11:00:00 2009 -0400 +++ b/lib/galaxy/web/controllers/tool_runner.py Thu Aug 13 11:27:45 2009 -0400 @@ -5,6 +5,7 @@ from galaxy.web.base.controller import * from galaxy.util.bunch import Bunch from galaxy.tools import DefaultToolState +from galaxy.tools.parameters.basic import UnvalidatedValue import logging log = logging.getLogger( __name__ ) @@ -52,6 +53,80 @@ add_frame.wiki_url = trans.app.config.wiki_url add_frame.from_noframe = True return trans.fill_template( template, history=history, toolbox=toolbox, tool=tool, util=util, add_frame=add_frame, **vars ) + + @web.expose + def rerun( self, trans, id=None, from_noframe=None, **kwd ): + """ + Given a HistoryDatasetAssociation id, find the job and that created + the dataset, extract the parameters, and display the appropriate tool + form with parameters already filled in. + """ + if not id: + error( "'id' parameter is required" ); + try: + id = int( id ) + except: + error( "Invalid value for 'id' parameter" ) + # Get the dataset object + data = trans.app.model.HistoryDatasetAssociation.get( id ) + # Get the associated job, if any. If this hda was copied from another, + # we need to find the job that created the origial hda + job_hda = data + while job_hda.copied_from_history_dataset_association: + job_hda = job_hda.copied_from_history_dataset_association + if not job_hda.creating_job_associations: + error( "Could not find the job for this dataset" ) + # Get the job object + job = None + for assoc in job_hda.creating_job_associations: + job = assoc.job + break + if not job: + raise Exception("Failed to get job information for dataset hid %d" % hid) + # Get the tool object + tool_id = job.tool_id + try: + # Load the tool + toolbox = self.get_toolbox() + tool = toolbox.tools_by_id.get( tool_id, None ) + except: + #this is expected, so not an exception + error( "This dataset was created by an obsolete tool (%s). Can't re-run." % tool_id ) + # Can't rerun upload, external data sources, et cetera. Workflow + # compatible will proxy this for now + if not tool.is_workflow_compatible: + error( "The '%s' tool does not currently support rerunning." % tool.name ) + # Get the job's parameters + try: + params_objects = job.get_param_values( trans.app ) + except: + raise Exception( "Failed to get paramemeters for dataset id %d " % hid ) + # Unpack unvalidated values to strings, they'll be validated when the + # form is submitted (this happens when re-running a job that was + # initially run by a workflow) + validated_params = {} + for name, value in params_objects.items(): + if isinstance( value, UnvalidatedValue ): + validated_params [ str(name) ] = str(value) + else: + validated_params [ str(name) ] = value + params_objects = validated_params + # Create a fake tool_state for the tool, with the parameters values + state = tool.new_state( trans ) + state.inputs = params_objects + tool_state_string = util.object_to_string(state.encode(tool, trans.app)) + # Setup context for template + history = trans.get_history() + template = "tool_form.mako" + vars = dict( tool_state=state, errors = {} ) + # Is the "add frame" stuff neccesary here? + add_frame = AddFrameData() + add_frame.debug = trans.debug + if from_noframe is not None: + add_frame.wiki_url = trans.app.config.wiki_url + add_frame.from_noframe = True + return trans.fill_template( template, history=history, toolbox=toolbox, tool=tool, util=util, add_frame=add_frame, **vars ) + @web.expose def redirect( self, trans, redirect_url=None, **kwd ): diff -r ad5232a4dbc5 -r 52ad5635f01a templates/root/history_common.mako --- a/templates/root/history_common.mako Thu Aug 13 11:00:00 2009 -0400 +++ b/templates/root/history_common.mako Thu Aug 13 11:27:45 2009 -0400 @@ -51,9 +51,12 @@ <div>${_('Job is currently running')}</div> %elif data_state == "error": <div> - An error occurred running this job: <i>${data.display_info().strip()}</i>, - <a href="${h.url_for( controller='dataset', action='errors', id=data.id )}" target="galaxy_main">report this error</a> + An error occurred running this job: <i>${data.display_info().strip()}</i> </div> + <div> + <a href="${h.url_for( controller='dataset', action='errors', id=data.id )}" target="galaxy_main">report this error</a> + | <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main">rerun</a> + </div> %elif data_state == "discarded": <div> The job creating this dataset was cancelled before completion. @@ -77,6 +80,7 @@ <div> %if data.has_data: <a href="${h.url_for( action='display', id=data.id, tofile='yes', toext=data.ext )}" target="_blank">save</a> + | <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main">rerun</a> %for display_app in data.datatype.get_display_types(): <% display_links = data.datatype.get_display_links( data, display_app, app, request.base ) %> %if len( display_links ) > 0:
participants (1)
-
Greg Von Kuster