commit/galaxy-central: jgoecks: Add basic tool execution to the API.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/127709d69d2c/ changeset: 127709d69d2c user: jgoecks date: 2012-04-26 00:03:11 summary: Add basic tool execution to the API. affected #: 1 file diff -r 0a13c751de1adf649983aa66f53fd23811d03d8f -r 127709d69d2c08bbceb3aa811c42696aec26ad10 lib/galaxy/web/api/tools.py --- a/lib/galaxy/web/api/tools.py +++ b/lib/galaxy/web/api/tools.py @@ -1,5 +1,10 @@ from galaxy import config, tools, web, util from galaxy.web.base.controller import BaseController, BaseAPIController +from galaxy.util.bunch import Bunch + +messages = Bunch( + NO_TOOL = "no tool" +) class ToolsController( BaseAPIController ): """ @@ -11,8 +16,10 @@ """ GET /api/tools: returns a list of tools defined by parameters parameters: - in_panel - if true, tools are returned in panel structure, including sections and labels - trackster - if true, only tools that are compatible with Trackster are returned + in_panel - if true, tools are returned in panel structure, + including sections and labels + trackster - if true, only tools that are compatible with + Trackster are returned """ # Read params. @@ -29,4 +36,40 @@ Returns tool information, including parameters and inputs. """ return self.app.toolbox.tools_by_id[ id ].to_dict( trans, for_display=True ) + + @web.expose_api + def create( self, trans, payload, **kwd ): + """ + POST /api/tools + Executes tool using specified inputs, creating new history-dataset + associations, which are returned. + """ + + # TODO: set target history? + + # -- Execute tool. -- + + # Get tool. + tool_id = payload[ 'id' ] + tool = trans.app.toolbox.get_tool( tool_id ) + if not tool: + return { "message": { "type": "error", "text" : messages.NO_TOOL } } + + # Set up inputs. + inputs = payload[ 'inputs' ] + # HACK: add run button so that tool.handle_input will run tool. + inputs['runtool_btn'] = 'Execute' + # TODO: encode data ids and decode ids. + params = util.Params( inputs, sanitize = False ) + template, vars = tool.handle_input( trans, params.__dict__ ) + + # TODO: check for errors and ensure that output dataset(s) are available. + output_datasets = vars[ 'out_data' ].values() + rval = { + "outputs": [] + } + outputs = rval[ "outputs" ] + for output in output_datasets: + outputs.append( output.get_api_value() ) + return rval \ No newline at end of file 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.
participants (1)
-
Bitbucket