mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add API to install resolver tool dependencies
and to build a tool dependency cache (if activated in galaxy.ini). An example to install dependencies for the twobit converter: ``` import bioblend.galaxy url = 'http://localhost:8080/' api_key = 'admin_api_key' tool_id = 'CONVERTER_fasta_to_2bit' endpoint = "api/tools/%s/install_dependencies" % tool_id gi = bioblend.galaxy.GalaxyInstance(url, api_key) gi.make_post_request("/".join((url, endpoint)), payload={'id': tool_id}) ``` If `use_cached_dependency_manager` is activated in the galaxy.ini, a cached environment can be built like this: ``` endpoint = "api/tools/%s/build_dependency_cache" % tool_id gi.make_post_request("/".join((url, endpoint)), payload={'id': tool_id}) ```
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
<!-- <description>__NOT_USED_CURRENTLY_FOR_CONVERTERS__</description> -->
|
||||
<!-- Used on the metadata edit page. -->
|
||||
<requirements>
|
||||
<requirement type="package" version="332">ucsc-twobittofa</requirement>
|
||||
<requirement type="package">ucsc_tools</requirement>
|
||||
</requirements>
|
||||
<command>faToTwoBit '$input' '$output'</command>
|
||||
|
||||
@@ -129,6 +129,33 @@ class ToolsController( BaseAPIController, UsesVisualizationMixin ):
|
||||
tool = self._get_tool(id)
|
||||
return tool.tool_requirements_status
|
||||
|
||||
@expose_api
|
||||
@web.require_admin
|
||||
def install_dependencies(self, trans, id, **kwds):
|
||||
"""
|
||||
POST /api/tools/{tool_id}/install_dependencies
|
||||
Attempts to install requirements via the dependency resolver
|
||||
"""
|
||||
tool = self._get_tool(id)
|
||||
[tool._view.install_dependency(id=None, **req.to_dict()) for req in tool.requirements]
|
||||
if kwds.get('build_dependency_cache'):
|
||||
tool.build_dependency_cache()
|
||||
# TODO: rework resolver install system to log and report what has been done.
|
||||
# _view.install_dependency should return a dict with stdout, stderr and success status
|
||||
return tool.tool_requirements_status
|
||||
|
||||
@expose_api
|
||||
@web.require_admin
|
||||
def build_dependency_cache(self, trans, id, **kwds):
|
||||
"""
|
||||
POST /api/tools/{tool_id}/build_dependency_cache
|
||||
Attempts to cache installed dependencies.
|
||||
"""
|
||||
tool = self._get_tool(id)
|
||||
tool.build_dependency_cache()
|
||||
# TODO: Should also have a more meaningful return.
|
||||
return tool.tool_requirements_status
|
||||
|
||||
@expose_api
|
||||
@web.require_admin
|
||||
def diagnostics( self, trans, id, **kwd ):
|
||||
|
||||
@@ -262,6 +262,8 @@ def populate_api_routes( webapp, app ):
|
||||
webapp.mapper.connect( '/api/tools/{id:.+?}/citations', action='citations', controller="tools" )
|
||||
webapp.mapper.connect( '/api/tools/{id:.+?}/download', action='download', controller="tools" )
|
||||
webapp.mapper.connect( '/api/tools/{id:.+?}/requirements', action='requirements', controller="tools")
|
||||
webapp.mapper.connect( '/api/tools/{id:.+?}/install_dependencies', action='install_dependencies', controller="tools", conditions=dict( method=[ "POST" ] ))
|
||||
webapp.mapper.connect( '/api/tools/{id:.+?}/build_dependency_cache', action='build_dependency_cache', controller="tools", conditions=dict( method=[ "POST" ] ))
|
||||
webapp.mapper.connect( '/api/tools/{id:.+?}', action='show', controller="tools" )
|
||||
webapp.mapper.resource( 'tool', 'tools', path_prefix='/api' )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user