[hg] galaxy 3712: Allow automatic creation of GALAXY_URL for 'da...
details: http://www.bx.psu.edu/hg/galaxy/rev/811b4794da70 changeset: 3712:811b4794da70 user: Dan Blankenberg <dan@bx.psu.edu> date: Wed Apr 28 12:47:44 2010 -0400 description: Allow automatic creation of GALAXY_URL for 'data_source' tools; add 'data_source_async' tool type which inherits from 'data_source' type, but generates a different GALAXY_URL. Backwards compatibility fix for datasource tools that have default tool_id configured, but which are now only using GALAXY_URL in the tool configuration. diffstat: lib/galaxy/tools/__init__.py | 17 ++++++++++++++++- lib/galaxy/web/controllers/tool_runner.py | 11 ++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diffs (64 lines): diff -r cdbffdf2dbf7 -r 811b4794da70 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py Wed Apr 28 12:30:32 2010 -0400 +++ b/lib/galaxy/tools/__init__.py Wed Apr 28 12:47:44 2010 -0400 @@ -1583,6 +1583,15 @@ class DataSourceTool( Tool ): tool_type = 'data_source' + + def _build_GALAXY_URL_parameter( self ): + return ToolParameter.build( self, ElementTree.XML( '<param name="GALAXY_URL" type="baseurl" value="/tool_runner?tool_id=%s" />' % self.id ) ) + + def parse_inputs( self, root ): + Tool.parse_inputs( self, root ) + if 'GALAXY_URL' not in self.inputs: + self.inputs[ 'GALAXY_URL' ] = self._build_GALAXY_URL_parameter() + def exec_before_job( self, app, inp_data, out_data, param_dict={} ): #TODO: Allow for a generic way for all Tools to have output dataset properties be set to input parameter values #as defined in a tool XML @@ -1646,6 +1655,12 @@ self.sa_session.add( data ) self.sa_session.flush() +class AsyncDataSourceTool( DataSourceTool ): + tool_type = 'data_source_async' + + def _build_GALAXY_URL_parameter( self ): + return ToolParameter.build( self, ElementTree.XML( '<param name="GALAXY_URL" type="baseurl" value="/async/%s" />' % self.id ) ) + class DataDestinationTool( Tool ): tool_type = 'data_destination' @@ -1665,7 +1680,7 @@ #load tool_type to ToolClass mappings tool_types = {} -for tool_class in [ Tool, DataDestinationTool, SetMetadataTool, DataSourceTool ]: +for tool_class in [ Tool, DataDestinationTool, SetMetadataTool, DataSourceTool, AsyncDataSourceTool ]: tool_types[ tool_class.tool_type ] = tool_class # ---- Utility classes to be factored out ----------------------------------- diff -r cdbffdf2dbf7 -r 811b4794da70 lib/galaxy/web/controllers/tool_runner.py --- a/lib/galaxy/web/controllers/tool_runner.py Wed Apr 28 12:30:32 2010 -0400 +++ b/lib/galaxy/web/controllers/tool_runner.py Wed Apr 28 12:47:44 2010 -0400 @@ -43,9 +43,18 @@ return trans.response.send_redirect( url_for( "/static/welcome.html" ) ) # Load the tool toolbox = self.get_toolbox() - tool = toolbox.tools_by_id.get( tool_id, None ) + #Backwards compatibility for datasource tools that have default tool_id configured, but which are now using only GALAXY_URL + if isinstance( tool_id, list ): + tool_ids = tool_id + else: + tool_ids = [ tool_id ] + for tool_id in tool_ids: + tool = toolbox.tools_by_id.get( tool_id, None ) + if tool: + break # No tool matching the tool id, display an error (shouldn't happen) if not tool: + tool_id = ','.join( tool_ids ) log.error( "index called with tool id '%s' but no such tool exists", tool_id ) trans.log_event( "Tool id '%s' does not exist" % tool_id ) return "Tool '%s' does not exist, kwd=%s " % (tool_id, kwd)
participants (1)
-
Nate Coraor