mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add force_rebuild param to build_dependency_cache
This will remove a pre-existing cached dependency directory.
This commit is contained in:
@@ -1306,7 +1306,7 @@ class Tool( object, Dictifiable ):
|
||||
visit_input_values( self.inputs, values, validate_inputs )
|
||||
return messages
|
||||
|
||||
def build_dependency_cache(self):
|
||||
def build_dependency_cache(self, **kwds):
|
||||
if isinstance(self.app.toolbox.dependency_manager, CachedDependencyManager):
|
||||
self.app.toolbox.dependency_manager.build_cache(
|
||||
requirements=self.requirements,
|
||||
@@ -1314,7 +1314,8 @@ class Tool( object, Dictifiable ):
|
||||
tool_dir=self.tool_dir,
|
||||
job_directory=None,
|
||||
metadata=False,
|
||||
tool_instance=self
|
||||
tool_instance=self,
|
||||
**kwds
|
||||
)
|
||||
|
||||
def build_dependency_shell_commands( self, job_directory=None, metadata=False ):
|
||||
|
||||
@@ -5,6 +5,7 @@ Dependency management for tools.
|
||||
import json
|
||||
import logging
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
@@ -175,6 +176,12 @@ class CachedDependencyManager(DependencyManager):
|
||||
resolved_dependencies = self.requirements_to_dependencies(requirements, **kwds)
|
||||
cacheable_dependencies = [dep for req, dep in resolved_dependencies.items() if dep.cacheable]
|
||||
hashed_requirements_dir = self.get_hashed_requirements_path(cacheable_dependencies)
|
||||
if kwds.get('force_rebuild', False) and os.path.exists(hashed_requirements_dir):
|
||||
try:
|
||||
shutil.rmtree(hashed_requirements_dir)
|
||||
except Exception:
|
||||
log.warning("Could not delete cached requirements directory '%s'" % hashed_requirements_dir)
|
||||
pass
|
||||
[dep.build_cache(hashed_requirements_dir) for dep in cacheable_dependencies]
|
||||
|
||||
def dependency_shell_commands( self, requirements, **kwds ):
|
||||
|
||||
@@ -135,11 +135,15 @@ class ToolsController( BaseAPIController, UsesVisualizationMixin ):
|
||||
"""
|
||||
POST /api/tools/{tool_id}/install_dependencies
|
||||
Attempts to install requirements via the dependency resolver
|
||||
|
||||
parameters:
|
||||
build_dependency_cache: If true, attempts to cache dependencies for this tool
|
||||
force_rebuild: If true and chache dir exists, attempts to delete cache dir
|
||||
"""
|
||||
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()
|
||||
tool.build_dependency_cache(**kwds)
|
||||
# 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
|
||||
@@ -150,9 +154,12 @@ class ToolsController( BaseAPIController, UsesVisualizationMixin ):
|
||||
"""
|
||||
POST /api/tools/{tool_id}/build_dependency_cache
|
||||
Attempts to cache installed dependencies.
|
||||
|
||||
parameters:
|
||||
force_rebuild: If true and chache dir exists, attempts to delete cache dir
|
||||
"""
|
||||
tool = self._get_tool(id)
|
||||
tool.build_dependency_cache()
|
||||
tool.build_dependency_cache(**kwds)
|
||||
# TODO: Should also have a more meaningful return.
|
||||
return tool.tool_requirements_status
|
||||
|
||||
|
||||
Reference in New Issue
Block a user