1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/2cd1bacf5e04/ changeset: 2cd1bacf5e04 user: greg date: 2012-03-12 15:20:56 summary: Handle tool versions with job reruns. affected #: 3 files diff -r e1c0cd5ed76766e4bf18f5342bf6cd395fca4732 -r 2cd1bacf5e0463bd804bf5fc7ac79a3ddf142937 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -241,7 +241,7 @@ os.close( fd ) shutil.move( filename, os.path.abspath( self.integrated_tool_panel_config ) ) os.chmod( self.integrated_tool_panel_config, 0644 ) - def get_tool( self, tool_id, tool_version=None ): + def get_tool( self, tool_id, tool_version=None, get_all_versions=False ): """Attempt to locate a tool in the tool box.""" if tool_id in self.tools_by_id: tool = self.tools_by_id[ tool_id ] @@ -252,6 +252,12 @@ tv = self.__get_tool_version( tool_id ) if tv: tool_version_ids = tv.get_version_ids( self.app ) + if get_all_versions: + available_tool_versions = [] + for tool_version_id in tool_version_ids: + if tool_version_id in self.tools_by_id: + available_tool_versions.append( self.tools_by_id[ tool_version_id ] ) + return available_tool_versions for tool_version_id in tool_version_ids: if tool_version_id in self.tools_by_id: tool = self.tools_by_id[ tool_version_id ] diff -r e1c0cd5ed76766e4bf18f5342bf6cd395fca4732 -r 2cd1bacf5e0463bd804bf5fc7ac79a3ddf142937 lib/galaxy/web/controllers/tool_runner.py --- a/lib/galaxy/web/controllers/tool_runner.py +++ b/lib/galaxy/web/controllers/tool_runner.py @@ -109,16 +109,49 @@ raise Exception("Failed to get job information for dataset hid %d" % data.hid) # Get the tool object tool_id = job.tool_id + tool_version = job.tool_version try: # Load the tool toolbox = self.get_toolbox() - tool = toolbox.get_tool( tool_id ) + tools = toolbox.get_tool( tool_id, tool_version=tool_version, get_all_versions=True ) + if len( tools ) > 1: + tool_id_select_field = self.build_tool_id_select_field( tools, tool_id ) + for tool in tools: + if tool.id == tool_id: + break + else: + tool = tools[ 0 ] + tool_id_version_message = 'This job was initially run with tool id "%s", version "%s", and multiple derivations ' % ( job.tool_id, job.tool_version ) + tool_id_version_message += 'of this tool are available. Rerun the job with the selected tool or choose another derivation of the tool.' + else: + tool_id_select_field = None + tool = tools[ 0 ] + if tool.id == job.tool_id and tool.version == job.tool_version: + tool_id_version_message = '' + elif tool.id == job.tool_id: + if job.tool_version == None: + # For some reason jobs don't always keep track of the tool version. + tool_id_version_message = '' + else: + if len( tools ) > 1: + tool_id_version_message = 'This job was initially run with tool version "%s", which is not currently available. ' % job.tool_version + tool_id_version_message += 'You can rerun the job with the selected tool or choose another derivation of the tool.' + else: + tool_id_version_message = 'This job was initially run with tool version "%s", which is not currently available. ' % job.tool_version + tool_id_version_message += 'You can rerun the job with this tool version, which is a derivation of the original tool.' + else: + if len( tools ) > 1: + tool_id_version_message = 'This job was initially run with tool version "%s", which is not currently available. ' % job.tool_version + tool_id_version_message += 'You can rerun the job with the selected tool or choose another derivation of the tool.' + else: + tool_id_version_message = 'This job was initially run with tool id "%s", version "%s", which is not ' % ( job.tool_id, job.tool_version ) + tool_id_version_message += 'currently available. You can rerun the job with this tool, which is a derivation of the original tool.' assert tool is not None, 'Requested tool has not been loaded.' except: - #this is expected, so not an exception + # This is expected so not an exception. + tool_id_version_message = '' 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 + # 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 @@ -163,7 +196,30 @@ if from_noframe is not None: add_frame.wiki_url = trans.app.config.wiki_url add_frame.from_noframe = True - return trans.fill_template( "tool_form.mako", history=history, toolbox=toolbox, tool=tool, util=util, add_frame=add_frame, **vars ) + return trans.fill_template( "tool_form.mako", + history=history, + toolbox=toolbox, + tool_id_select_field=tool_id_select_field, + tool=tool, + util=util, + add_frame=add_frame, + tool_id_version_message=tool_id_version_message, + **vars ) + def build_tool_id_select_field( self, tools, selected_tool_id ): + """Build a SelectField whose options are the ids for the received list of tools.""" + options = [] + refresh_on_change_values = [] + for tool in tools: + options.append( ( tool.id, tool.id ) ) + refresh_on_change_values.append( tool.id ) + select_field = SelectField( name='tool_id', refresh_on_change=True, refresh_on_change_values=refresh_on_change_values ) + for option_tup in options: + selected = option_tup[0] == selected_tool_id + if selected: + select_field.add_option( option_tup[0], option_tup[1], selected=True ) + else: + select_field.add_option( option_tup[0], option_tup[1] ) + return select_field @web.expose def redirect( self, trans, redirect_url=None, **kwd ): if not redirect_url: @@ -251,7 +307,6 @@ datasets.append( create_dataset( 'Pasted Entry' ) ) break return [ d.id for d in datasets ] - @web.expose def upload_async_message( self, trans, **kwd ): # might be more appropriate in a different controller diff -r e1c0cd5ed76766e4bf18f5342bf6cd395fca4732 -r 2cd1bacf5e0463bd804bf5fc7ac79a3ddf142937 templates/tool_form.mako --- a/templates/tool_form.mako +++ b/templates/tool_form.mako @@ -1,4 +1,5 @@ <%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /><%namespace file="/base_panels.mako" import="overlay" /><%def name="stylesheets()"> @@ -274,10 +275,11 @@ assert len(tool.action) == 2 tool_url = tool.action[0] + h.url_for(tool.action[1]) %> -%if message: - <div class="errormessage">${message}</div> - <br/> + +%if tool_id_version_message: + ${render_msg( tool_id_version_message, 'error' )} %endif + <div class="toolForm" id="${tool.id}"> %if tool.has_multiple_pages: <div class="toolFormTitle">${tool.name} (step ${tool_state.page+1} of ${tool.npages})</div> @@ -286,7 +288,18 @@ %endif <div class="toolFormBody"><form id="tool_form" name="tool_form" action="${tool_url}" enctype="${tool.enctype}" target="${tool.target}" method="${tool.method}"> - <input type="hidden" name="tool_id" value="${tool.id}"> + %if tool_id_select_field: + <div class="form-row"> + <label>Tool id:</label> + ${tool_id_select_field.get_html()} + <div class="toolParamHelp" style="clear: both;"> + Select a different derivation of this tool to rerun the job. + </div> + </div> + <div style="clear: both"></div> + %else: + <input type="hidden" name="tool_id" value="${tool.id}"> + %endif <input type="hidden" name="tool_state" value="${util.object_to_string( tool_state.encode( tool, app ) )}"> %if tool.display_by_page[tool_state.page]: ${trans.fill_template_string( tool.display_by_page[tool_state.page], context=tool.get_param_html_map( trans, tool_state.page, tool_state.inputs ) )} Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.