7 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/2b6e21823ea7/
Changeset: 2b6e21823ea7
User: jmchilton
Date: 2014-12-25 18:35:13+00:00
Summary: More ToolPanelManager unit testing.
Affected #: 1 file
diff -r 0587bc5413d66e85673d7b429bc04d34e47ad4c4 -r 2b6e21823ea70429b7913b913010f6501f10a601 test/unit/tool_shed_unit_tests/test_tool_panel_manager.py
--- a/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py
+++ b/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py
@@ -101,6 +101,16 @@
assert "github.com/galaxyproect/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read()
self._verify_tool_confs()
+ self._remove_guids( ["github.com/galaxyproect/example/test_tool/0.1"], uninstall=True )
+
+ # Now no versions of this tool are returned by toolbox.
+ all_versions = self.toolbox.get_tool( "test_tool", get_all_versions=True )
+ assert not all_versions
+
+ # Check that tool panel has reverted to old value...
+ section = self.toolbox.tool_panel["tid"]
+ assert len(section.elems) == 0
+
def _setup_two_versions_remove_one( self, section, uninstall ):
self._init_tool()
self._setup_two_versions_in_config( section=True )
https://bitbucket.org/galaxy/galaxy-central/commits/8ffb20fd4300/
Changeset: 8ffb20fd4300
User: jmchilton
Date: 2014-12-25 18:35:13+00:00
Summary: Eliminate repeated nested object access in ToolPanelManager.remove_guids.
Affected #: 1 file
diff -r 2b6e21823ea70429b7913b913010f6501f10a601 -r 8ffb20fd4300fbf3b4cc5ac21022e55cd2c1da68 lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
--- a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
+++ b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
@@ -445,10 +445,11 @@
self.remove_guids( guids_to_remove, shed_tool_conf, uninstall )
def remove_guids( self, guids_to_remove, shed_tool_conf, uninstall ):
+ toolbox = self.app.toolbox
# Remove the tools from the toolbox's tools_by_id dictionary.
for guid_to_remove in guids_to_remove:
- if guid_to_remove in self.app.toolbox.tools_by_id:
- del self.app.toolbox.tools_by_id[ guid_to_remove ]
+ if guid_to_remove in toolbox.tools_by_id:
+ del toolbox.tools_by_id[ guid_to_remove ]
index, shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
if uninstall:
# Remove from the shed_tool_conf file on disk.
@@ -469,12 +470,12 @@
# Remove the tool sub-element from the section element.
config_elem.remove( tool_elem )
# Remove the tool from the section in the in-memory tool panel.
- if section_key in self.app.toolbox.tool_panel:
- tool_section = self.app.toolbox.tool_panel[ section_key ]
+ if section_key in toolbox.tool_panel:
+ tool_section = toolbox.tool_panel[ section_key ]
guid = tool_elem.get( 'guid' )
tool_key = 'tool_%s' % str( guid )
# Get the list of versions of this tool that are currently available in the toolbox.
- available_tool_versions = self.app.toolbox.get_loaded_tools_by_lineage( guid )
+ available_tool_versions = toolbox.get_loaded_tools_by_lineage( guid )
if tool_key in tool_section.elems:
if available_tool_versions:
available_tool_versions.reverse()
@@ -505,8 +506,8 @@
del tool_section.elems[ tool_key ]
if uninstall:
# Remove the tool from the section in the in-memory integrated tool panel.
- if section_key in self.app.toolbox.integrated_tool_panel:
- tool_section = self.app.toolbox.integrated_tool_panel[ section_key ]
+ if section_key in toolbox.integrated_tool_panel:
+ tool_section = toolbox.integrated_tool_panel[ section_key ]
tool_key = 'tool_%s' % str( tool_elem.get( 'guid' ) )
if tool_key in tool_section.elems:
del tool_section.elems[ tool_key ]
@@ -518,8 +519,8 @@
if guid in guids_to_remove:
tool_key = 'tool_%s' % str( config_elem.get( 'guid' ) )
# Get the list of versions of this tool that are currently available in the toolbox.
- available_tool_versions = self.app.toolbox.get_loaded_tools_by_lineage( guid )
- if tool_key in self.app.toolbox.tool_panel:
+ available_tool_versions = toolbox.get_loaded_tools_by_lineage( guid )
+ if tool_key in toolbox.tool_panel:
if available_tool_versions:
available_tool_versions.reverse()
replacement_tool_key = None
@@ -528,32 +529,32 @@
# the newest loaded version of the tool.
for available_tool_version in available_tool_versions:
available_tool_section_id, available_tool_section_name = available_tool_version.get_panel_section()
- if available_tool_version.id in self.app.toolbox.tool_panel.keys() or not available_tool_section_id:
+ if available_tool_version.id in toolbox.tool_panel.keys() or not available_tool_section_id:
replacement_tool_key = 'tool_%s' % str( available_tool_version.id )
replacement_tool_version = available_tool_version
break
if replacement_tool_key and replacement_tool_version:
# Get the index of the tool_key in the tool_section.
- for tool_panel_index, key in enumerate( self.app.toolbox.tool_panel.keys() ):
+ for tool_panel_index, key in enumerate( toolbox.tool_panel.keys() ):
if key == tool_key:
break
# Remove the tool from the tool panel.
- del self.app.toolbox.tool_panel[ tool_key ]
+ del toolbox.tool_panel[ tool_key ]
# Add the replacement tool at the same location in the tool panel.
- self.app.toolbox.tool_panel.insert( tool_panel_index,
- replacement_tool_key,
- replacement_tool_version )
+ toolbox.tool_panel.insert( tool_panel_index,
+ replacement_tool_key,
+ replacement_tool_version )
else:
- del self.app.toolbox.tool_panel[ tool_key ]
+ del toolbox.tool_panel[ tool_key ]
else:
- del self.app.toolbox.tool_panel[ tool_key ]
+ del toolbox.tool_panel[ tool_key ]
if uninstall:
- if tool_key in self.app.toolbox.integrated_tool_panel:
- del self.app.toolbox.integrated_tool_panel[ tool_key ]
+ if tool_key in toolbox.integrated_tool_panel:
+ del toolbox.integrated_tool_panel[ tool_key ]
config_elems_to_remove.append( config_elem )
for config_elem in config_elems_to_remove:
# Remove the element from the in-memory list of elements.
config_elems.remove( config_elem )
# Update the config_elems of the in-memory shed_tool_conf_dict.
shed_tool_conf_dict[ 'config_elems' ] = config_elems
- self.app.toolbox.update_shed_config( index, shed_tool_conf_dict, integrated_panel_changes=uninstall )
+ toolbox.update_shed_config( index, shed_tool_conf_dict, integrated_panel_changes=uninstall )
https://bitbucket.org/galaxy/galaxy-central/commits/44dfa6fc2701/
Changeset: 44dfa6fc2701
User: jmchilton
Date: 2014-12-25 18:35:13+00:00
Summary: Reduce duplication/complexity in tool_panel_manager.py.
Big conditional in remove_guids switched on sectioned versus un-sectioned with very little difference in what was actually being done. This reduces the cyclomatic complexity of that method from 35 down to 26 (though it is still the most 'complex' method in that file by a wide margin).
Affected #: 1 file
diff -r 8ffb20fd4300fbf3b4cc5ac21022e55cd2c1da68 -r 44dfa6fc270161fb12a3f152d5f24f53d757cd29 lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
--- a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
+++ b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
@@ -446,6 +446,48 @@
def remove_guids( self, guids_to_remove, shed_tool_conf, uninstall ):
toolbox = self.app.toolbox
+
+ def remove_from_panel( tool_elem, has_elems, integrated_has_elems, section_key='' ):
+ # Hide tool from panel and promote next oldest version if
+ # available.
+ guid = tool_elem.get( 'guid' )
+ tool_key = 'tool_%s' % str( guid )
+ available_tool_versions = toolbox.get_loaded_tools_by_lineage( guid )
+ if tool_key in has_elems:
+ if available_tool_versions:
+ available_tool_versions.reverse()
+ replacement_tool_key = None
+ replacement_tool_version = None
+ # Since we are going to remove the tool from the section, replace it with
+ # the newest loaded version of the tool.
+ for available_tool_version in available_tool_versions:
+ available_tool_section_id, available_tool_section_name = available_tool_version.get_panel_section()
+ # I suspect "available_tool_version.id in has_elems.keys()" doesn't
+ # belong in the following line or at least I don't understand what
+ # purpose it might serve. -John
+ if available_tool_version.id in has_elems.keys() or (available_tool_section_id == section_key):
+ replacement_tool_key = 'tool_%s' % str( available_tool_version.id )
+ replacement_tool_version = available_tool_version
+ break
+ if replacement_tool_key and replacement_tool_version:
+ # Get the index of the tool_key in the tool_section.
+ for tool_panel_index, key in enumerate( has_elems.keys() ):
+ if key == tool_key:
+ break
+ # Remove the tool from the tool panel.
+ del has_elems[ tool_key ]
+ # Add the replacement tool at the same location in the tool panel.
+ has_elems.insert( tool_panel_index,
+ replacement_tool_key,
+ replacement_tool_version )
+ else:
+ del has_elems[ tool_key ]
+ else:
+ del has_elems[ tool_key ]
+ if uninstall:
+ if tool_key in toolbox.integrated_tool_panel:
+ del toolbox.integrated_tool_panel[ tool_key ]
+
# Remove the tools from the toolbox's tools_by_id dictionary.
for guid_to_remove in guids_to_remove:
if guid_to_remove in toolbox.tools_by_id:
@@ -472,85 +514,15 @@
# Remove the tool from the section in the in-memory tool panel.
if section_key in toolbox.tool_panel:
tool_section = toolbox.tool_panel[ section_key ]
- guid = tool_elem.get( 'guid' )
- tool_key = 'tool_%s' % str( guid )
- # Get the list of versions of this tool that are currently available in the toolbox.
- available_tool_versions = toolbox.get_loaded_tools_by_lineage( guid )
- if tool_key in tool_section.elems:
- if available_tool_versions:
- available_tool_versions.reverse()
- replacement_tool_key = None
- replacement_tool_version = None
- # Since we are going to remove the tool from the section, replace it with the
- # newest loaded version of the tool.
- for available_tool_version in available_tool_versions:
- available_tool_section_id, available_tool_section_name = available_tool_version.get_panel_section()
- if available_tool_version.id in tool_section.elems.keys() or section_key == available_tool_section_id:
- replacement_tool_key = 'tool_%s' % str( available_tool_version.id )
- replacement_tool_version = available_tool_version
- break
- if replacement_tool_key and replacement_tool_version:
- # Get the index of the tool_key in the tool_section.
- for tool_section_elems_index, key in enumerate( tool_section.elems.keys() ):
- if key == tool_key:
- break
- # Remove the tool from the tool section.
- del tool_section.elems[ tool_key ]
- # Add the replacement tool at the same location in the tool section.
- tool_section.elems.insert( tool_section_elems_index,
- replacement_tool_key,
- replacement_tool_version )
- else:
- del tool_section.elems[ tool_key ]
- else:
- del tool_section.elems[ tool_key ]
- if uninstall:
- # Remove the tool from the section in the in-memory integrated tool panel.
- if section_key in toolbox.integrated_tool_panel:
- tool_section = toolbox.integrated_tool_panel[ section_key ]
- tool_key = 'tool_%s' % str( tool_elem.get( 'guid' ) )
- if tool_key in tool_section.elems:
- del tool_section.elems[ tool_key ]
+ remove_from_panel( tool_elem, tool_section.elems, toolbox.integrated_tool_panel.get( section_key, {} ), section_key=section_key )
if len( config_elem ) < 1:
# Keep a list of all empty section elements so they can be removed.
config_elems_to_remove.append( config_elem )
elif config_elem.tag == 'tool':
guid = config_elem.get( 'guid' )
if guid in guids_to_remove:
- tool_key = 'tool_%s' % str( config_elem.get( 'guid' ) )
- # Get the list of versions of this tool that are currently available in the toolbox.
- available_tool_versions = toolbox.get_loaded_tools_by_lineage( guid )
- if tool_key in toolbox.tool_panel:
- if available_tool_versions:
- available_tool_versions.reverse()
- replacement_tool_key = None
- replacement_tool_version = None
- # Since we are going to remove the tool from the section, replace it with
- # the newest loaded version of the tool.
- for available_tool_version in available_tool_versions:
- available_tool_section_id, available_tool_section_name = available_tool_version.get_panel_section()
- if available_tool_version.id in toolbox.tool_panel.keys() or not available_tool_section_id:
- replacement_tool_key = 'tool_%s' % str( available_tool_version.id )
- replacement_tool_version = available_tool_version
- break
- if replacement_tool_key and replacement_tool_version:
- # Get the index of the tool_key in the tool_section.
- for tool_panel_index, key in enumerate( toolbox.tool_panel.keys() ):
- if key == tool_key:
- break
- # Remove the tool from the tool panel.
- del toolbox.tool_panel[ tool_key ]
- # Add the replacement tool at the same location in the tool panel.
- toolbox.tool_panel.insert( tool_panel_index,
- replacement_tool_key,
- replacement_tool_version )
- else:
- del toolbox.tool_panel[ tool_key ]
- else:
- del toolbox.tool_panel[ tool_key ]
- if uninstall:
- if tool_key in toolbox.integrated_tool_panel:
- del toolbox.integrated_tool_panel[ tool_key ]
+ # get_panel_section return '' for un-sectioned tools.
+ remove_from_panel( config_elem, toolbox.tool_panel, toolbox.integrated_tool_panel, section_key='' )
config_elems_to_remove.append( config_elem )
for config_elem in config_elems_to_remove:
# Remove the element from the in-memory list of elements.
https://bitbucket.org/galaxy/galaxy-central/commits/01293fc1f167/
Changeset: 01293fc1f167
User: jmchilton
Date: 2014-12-25 18:35:13+00:00
Summary: Abstract out ToolBox internals from tool_shed.util.tool_util.
Instead of reloading upload actions at this level and exposing tools_by_id - move this logic into the ToolBox in a new method called handle_datatypes_changed().
Affected #: 2 files
diff -r 44dfa6fc270161fb12a3f152d5f24f53d757cd29 -r 01293fc1f16715121524b987fcab031f3e149a02 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -34,6 +34,7 @@
from galaxy import exceptions
from galaxy.tools import watcher
from galaxy.tools.actions import DefaultToolAction
+from galaxy.tools.actions.upload import UploadToolAction
from galaxy.tools.actions.data_source import DataSourceToolAction
from galaxy.tools.actions.data_manager import DataManagerToolAction
from galaxy.tools.deps import build_dependency_manager
@@ -992,6 +993,13 @@
def init_dependency_manager( self ):
self.dependency_manager = build_dependency_manager( self.app.config )
+ def handle_datatypes_changed( self ):
+ """ Refresh upload tools when new datatypes are added. """
+ for tool_id in self.tools_by_id:
+ tool = self.tools_by_id[ tool_id ]
+ if isinstance( tool.tool_action, UploadToolAction ):
+ self.reload_tool_by_id( tool_id )
+
@property
def sa_session( self ):
"""
diff -r 44dfa6fc270161fb12a3f152d5f24f53d757cd29 -r 01293fc1f16715121524b987fcab031f3e149a02 lib/tool_shed/util/tool_util.py
--- a/lib/tool_shed/util/tool_util.py
+++ b/lib/tool_shed/util/tool_util.py
@@ -260,7 +260,4 @@
def reload_upload_tools( app ):
if hasattr( app, 'toolbox' ):
- for tool_id in app.toolbox.tools_by_id:
- tool = app.toolbox.tools_by_id[ tool_id ]
- if isinstance( tool.tool_action, UploadToolAction ):
- app.toolbox.reload_tool_by_id( tool_id )
+ app.toolbox.handle_datatypes_changed()
https://bitbucket.org/galaxy/galaxy-central/commits/7716c8fbb891/
Changeset: 7716c8fbb891
User: jmchilton
Date: 2014-12-25 18:35:13+00:00
Summary: Centralize abstraction for removing tools from toolbox.
Shield's toolbox.tools_by_id from lib/tool_shed/galaxy_install/tools/tool_panel_manager.py.
Affected #: 3 files
diff -r 01293fc1f16715121524b987fcab031f3e149a02 -r 7716c8fbb891eb18f81bc80fc5f85f735d025357 lib/galaxy/datatypes/registry.py
--- a/lib/galaxy/datatypes/registry.py
+++ b/lib/galaxy/datatypes/registry.py
@@ -529,8 +529,7 @@
converter.id = tool_dict[ 'guid' ]
break
if deactivate:
- if converter.id in toolbox.tools_by_id:
- del toolbox.tools_by_id[ converter.id ]
+ toolbox.remove_tool_by_id( converter.id, remove_from_panel=False )
if source_datatype in self.datatype_converters:
if target_datatype in self.datatype_converters[ source_datatype ]:
del self.datatype_converters[ source_datatype ][ target_datatype ]
diff -r 01293fc1f16715121524b987fcab031f3e149a02 -r 7716c8fbb891eb18f81bc80fc5f85f735d025357 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -952,9 +952,13 @@
status = 'done'
return message, status
- def remove_tool_by_id( self, tool_id ):
+ def remove_tool_by_id( self, tool_id, remove_from_panel=True ):
"""
- Attempt to remove the tool identified by 'tool_id'.
+ Attempt to remove the tool identified by 'tool_id'. Ignores
+ tool lineage - so to remove a tool with potentially multiple
+ versions send remove_from_panel=False and handle the logic of
+ promoting the next newest version of the tool into the panel
+ if needed.
"""
if tool_id not in self.tools_by_id:
message = "No tool with id %s" % escape( tool_id )
@@ -962,17 +966,18 @@
else:
tool = self.tools_by_id[ tool_id ]
del self.tools_by_id[ tool_id ]
- tool_key = 'tool_' + tool_id
- for key, val in self.tool_panel.items():
- if key == tool_key:
- del self.tool_panel[ key ]
- break
- elif key.startswith( 'section' ):
- if tool_key in val.elems:
- del self.tool_panel[ key ].elems[ tool_key ]
+ if remove_from_panel:
+ tool_key = 'tool_' + tool_id
+ for key, val in self.tool_panel.items():
+ if key == tool_key:
+ del self.tool_panel[ key ]
break
- if tool_id in self.data_manager_tools:
- del self.data_manager_tools[ tool_id ]
+ elif key.startswith( 'section' ):
+ if tool_key in val.elems:
+ del self.tool_panel[ key ].elems[ tool_key ]
+ break
+ if tool_id in self.data_manager_tools:
+ del self.data_manager_tools[ tool_id ]
#TODO: do we need to manually remove from the integrated panel here?
message = "Removed the tool:<br/>"
message += "<b>name:</b> %s<br/>" % tool.name
diff -r 01293fc1f16715121524b987fcab031f3e149a02 -r 7716c8fbb891eb18f81bc80fc5f85f735d025357 lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
--- a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
+++ b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py
@@ -490,8 +490,8 @@
# Remove the tools from the toolbox's tools_by_id dictionary.
for guid_to_remove in guids_to_remove:
- if guid_to_remove in toolbox.tools_by_id:
- del toolbox.tools_by_id[ guid_to_remove ]
+ # remove_from_tool_panel to false, will handling that logic below.
+ toolbox.remove_tool_by_id( guid_to_remove, remove_from_panel=False )
index, shed_tool_conf_dict = self.get_shed_tool_conf_dict( shed_tool_conf )
if uninstall:
# Remove from the shed_tool_conf file on disk.
https://bitbucket.org/galaxy/galaxy-central/commits/75e5db40bd2e/
Changeset: 75e5db40bd2e
User: jmchilton
Date: 2014-12-25 18:35:13+00:00
Summary: Eliminate walking over tools_by_id externally from toolbox.
Affected #: 2 files
diff -r 7716c8fbb891eb18f81bc80fc5f85f735d025357 -r 75e5db40bd2e6bfb481b500081a3d8b066063541 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -535,6 +535,9 @@
.filter( self.app.install_model.ToolVersion.table.c.tool_id == tool_id ) \
.first()
+ def tools( self ):
+ return self.tools_by_id.iteritems()
+
def __get_tool_shed_repository( self, tool_shed, name, owner, installed_changeset_revision ):
# We store only the port, if one exists, in the database.
tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed )
diff -r 7716c8fbb891eb18f81bc80fc5f85f735d025357 -r 75e5db40bd2e6bfb481b500081a3d8b066063541 lib/galaxy/tools/search/__init__.py
--- a/lib/galaxy/tools/search/__init__.py
+++ b/lib/galaxy/tools/search/__init__.py
@@ -27,7 +27,7 @@
self.index = self.storage.create_index( schema )
writer = self.index.writer()
## TODO: would also be nice to search section headers.
- for id, tool in self.toolbox.tools_by_id.iteritems():
+ for id, tool in self.toolbox.tools():
add_doc_kwds = {
"id": id,
"title": to_unicode(tool.name),
https://bitbucket.org/galaxy/galaxy-central/commits/4844fa109944/
Changeset: 4844fa109944
User: jmchilton
Date: 2014-12-25 18:35:13+00:00
Summary: Abstractions for registering tools from outside toolbox.
Part of effort to further limit exposing tools_by_id directly outside Toolbox.
Affected #: 4 files
diff -r 75e5db40bd2e6bfb481b500081a3d8b066063541 -r 4844fa1099447fb8397159be710c99a82726821a lib/galaxy/datatypes/registry.py
--- a/lib/galaxy/datatypes/registry.py
+++ b/lib/galaxy/datatypes/registry.py
@@ -535,7 +535,7 @@
del self.datatype_converters[ source_datatype ][ target_datatype ]
self.log.debug( "Deactivated converter: %s", converter.id )
else:
- toolbox.tools_by_id[ converter.id ] = converter
+ toolbox.register_tool( converter )
if source_datatype not in self.datatype_converters:
self.datatype_converters[ source_datatype ] = odict()
self.datatype_converters[ source_datatype ][ target_datatype ] = converter
@@ -644,8 +644,7 @@
tmp_name = tempfile.NamedTemporaryFile()
tmp_name.write( tool_xml_text )
tmp_name.flush()
- set_meta_tool = toolbox.load_tool( tmp_name.name )
- toolbox.tools_by_id[ set_meta_tool.id ] = set_meta_tool
+ set_meta_tool = toolbox.load_hidden_tool( tmp_name.name )
self.set_external_metadata_tool = set_meta_tool
self.log.debug( "Loaded external metadata tool: %s", self.set_external_metadata_tool.id )
diff -r 75e5db40bd2e6bfb481b500081a3d8b066063541 -r 4844fa1099447fb8397159be710c99a82726821a lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -804,6 +804,17 @@
self.tool_watcher.watch_file( config_file, tool.id )
return tool
+ def load_hidden_tool( self, config_file, **kwds ):
+ """ Load a hidden tool (in this context meaning one that does not
+ appear in the tool panel) and register it in tools_by_id.
+ """
+ tool = self.load_tool( config_file, **kwds )
+ self.register_tool( tool )
+ return tool
+
+ def register_tool( self, tool ):
+ self.tools_by_id[ tool.id ] = tool
+
def package_tool( self, trans, tool_id ):
"""
Create a tarball with the tool's xml, help images, and test data.
diff -r 75e5db40bd2e6bfb481b500081a3d8b066063541 -r 4844fa1099447fb8397159be710c99a82726821a lib/galaxy/tools/data_manager/manager.py
--- a/lib/galaxy/tools/data_manager/manager.py
+++ b/lib/galaxy/tools/data_manager/manager.py
@@ -244,12 +244,12 @@
return self.guid or self.declared_id #if we have a guid, we will use that as the data_manager id
def load_tool( self, tool_filename, guid=None, data_manager_id=None, tool_shed_repository_id=None ):
- tool = self.data_managers.app.toolbox.load_tool( tool_filename,
- guid=guid,
- data_manager_id=data_manager_id,
- repository_id=tool_shed_repository_id )
+ toolbox = self.data_managers.app.toolbox
+ tool = toolbox.load_hidden_tool( tool_filename,
+ guid=guid,
+ data_manager_id=data_manager_id,
+ repository_id=tool_shed_repository_id )
self.data_managers.app.toolbox.data_manager_tools[ tool.id ] = tool
- self.data_managers.app.toolbox.tools_by_id[ tool.id ] = tool
self.tool = tool
return tool
diff -r 75e5db40bd2e6bfb481b500081a3d8b066063541 -r 4844fa1099447fb8397159be710c99a82726821a lib/galaxy/tools/imp_exp/__init__.py
--- a/lib/galaxy/tools/imp_exp/__init__.py
+++ b/lib/galaxy/tools/imp_exp/__init__.py
@@ -40,14 +40,12 @@
tmp_name = tempfile.NamedTemporaryFile()
tmp_name.write( tool_xml_text )
tmp_name.flush()
- history_exp_tool = toolbox.load_tool( tmp_name.name )
- toolbox.tools_by_id[ history_exp_tool.id ] = history_exp_tool
+ history_exp_tool = toolbox.load_hidden_tool( tmp_name.name )
log.debug( "Loaded history export tool: %s", history_exp_tool.id )
# Load import tool.
tool_xml = os.path.join( os.getcwd(), "lib/galaxy/tools/imp_exp/imp_history_from_archive.xml" )
- history_imp_tool = toolbox.load_tool( tool_xml )
- toolbox.tools_by_id[ history_imp_tool.id ] = history_imp_tool
+ history_imp_tool = toolbox.load_hidden_tool( tool_xml )
log.debug( "Loaded history import tool: %s", history_imp_tool.id )
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.
10 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/9e973ebf7272/
Changeset: 9e973ebf7272
User: jmchilton
Date: 2014-12-22 18:16:25+00:00
Summary: Remove some unused imports from lib/galaxy/tools/__init__.py.
Affected #: 1 file
diff -r 815d38c48a5639d47eed92806ef4c196406f58f1 -r 9e973ebf7272bcd1ff684e82bfb62b4938875f94 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -7,20 +7,15 @@
import json
import logging
import os
-import pipes
import re
import shutil
-import sys
import string
import tarfile
import tempfile
import threading
-import traceback
import types
import urllib
-from math import isinf
-
from galaxy import eggs
eggs.require( "MarkupSafe" ) # MarkupSafe must load before mako
eggs.require( "Mako" )
@@ -35,10 +30,8 @@
from sqlalchemy import and_
from galaxy import jobs, model
-from galaxy.jobs.error_level import StdioErrorLevel
from galaxy.datatypes.metadata import JobExternalOutputMetadataWrapper
from galaxy import exceptions
-from galaxy.jobs import ParallelismInfo
from galaxy.tools import watcher
from galaxy.tools.actions import DefaultToolAction
from galaxy.tools.actions.data_source import DataSourceToolAction
@@ -58,12 +51,11 @@
from galaxy.tools.test import parse_tests
from galaxy.tools.parser import get_tool_source
from galaxy.tools.parser.xml import XmlPageSource
-from galaxy.util import listify, parse_xml, rst_to_html, string_as_bool, string_to_object, xml_text, xml_to_string
+from galaxy.util import listify, parse_xml, rst_to_html, string_as_bool, string_to_object
from galaxy.tools.parameters.meta import expand_meta_parameters
from galaxy.util.bunch import Bunch
from galaxy.util.expressions import ExpressionContext
from galaxy.util.hash_util import hmac_new
-from galaxy.util.none_like import NoneDataset
from galaxy.util.odict import odict
from galaxy.util.template import fill_template
from galaxy.web import url_for
@@ -73,7 +65,7 @@
from galaxy.model import Workflow
from tool_shed.util import common_util
from tool_shed.util import shed_util_common as suc
-from .loader import load_tool, template_macro_params, raw_tool_xml_tree, imported_macro_paths
+from .loader import template_macro_params, raw_tool_xml_tree, imported_macro_paths
from .execute import execute as execute_job
from .wrappers import (
ToolParameterValueWrapper,
https://bitbucket.org/galaxy/galaxy-central/commits/6e956fdb0034/
Changeset: 6e956fdb0034
User: jmchilton
Date: 2014-12-22 18:16:25+00:00
Summary: More PEP-8 style tweaks to lib/galaxy/tools/__init__.py.
Affected #: 1 file
diff -r 9e973ebf7272bcd1ff684e82bfb62b4938875f94 -r 6e956fdb003441f699e24750f02c61c43992a784 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -257,8 +257,9 @@
return tool_path
def __add_tool_to_tool_panel( self, tool, panel_component, section=False ):
- # See if a version of this tool is already loaded into the tool panel. The value of panel_component
- # will be a ToolSection (if the value of section=True) or self.tool_panel (if section=False).
+ # See if a version of this tool is already loaded into the tool panel.
+ # The value of panel_component will be a ToolSection (if the value of
+ # section=True) or self.tool_panel (if section=False).
tool_id = str( tool.id )
tool = self.tools_by_id[ tool_id ]
if section:
@@ -300,13 +301,17 @@
if not inserted:
inserted = True
if not inserted:
- if tool.guid is None or \
- tool.tool_shed is None or \
- tool.repository_name is None or \
- tool.repository_owner is None or \
- tool.installed_changeset_revision is None:
- # We have a tool that was not installed from the Tool Shed, but is also not yet defined in
- # integrated_tool_panel.xml, so append it to the tool panel.
+ if (
+ tool.guid is None or
+ tool.tool_shed is None or
+ tool.repository_name is None or
+ tool.repository_owner is None or
+ tool.installed_changeset_revision is None
+ ):
+ # We have a tool that was not installed from the Tool
+ # Shed, but is also not yet defined in
+ # integrated_tool_panel.xml, so append it to the tool
+ # panel.
panel_dict[ key ] = tool
log.debug( "Loaded tool id: %s, version: %s into tool panel.." % ( tool.id, tool.version ) )
else:
@@ -364,9 +369,10 @@
def load_integrated_tool_panel_keys( self ):
"""
- Load the integrated tool panel keys, setting values for tools and workflows to None. The values will
- be reset when the various tool panel config files are parsed, at which time the tools and workflows are
- loaded.
+ Load the integrated tool panel keys, setting values for tools and
+ workflows to None. The values will be reset when the various tool
+ panel config files are parsed, at which time the tools and workflows
+ are loaded.
"""
tree = parse_xml( self.integrated_tool_panel_config )
root = tree.getroot()
@@ -499,11 +505,11 @@
# We store only the port, if one exists, in the database.
tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed )
return self.app.install_model.context.query( self.app.install_model.ToolShedRepository ) \
- .filter( and_( self.app.install_model.ToolShedRepository.table.c.tool_shed == tool_shed,
- self.app.install_model.ToolShedRepository.table.c.name == name,
- self.app.install_model.ToolShedRepository.table.c.owner == owner,
- self.app.install_model.ToolShedRepository.table.c.installed_changeset_revision == installed_changeset_revision ) ) \
- .first()
+ .filter( and_( self.app.install_model.ToolShedRepository.table.c.tool_shed == tool_shed,
+ self.app.install_model.ToolShedRepository.table.c.name == name,
+ self.app.install_model.ToolShedRepository.table.c.owner == owner,
+ self.app.install_model.ToolShedRepository.table.c.installed_changeset_revision == installed_changeset_revision ) ) \
+ .first()
def get_tool_components( self, tool_id, tool_version=None, get_loaded_tools_by_lineage=False, set_selected=False ):
"""
@@ -627,12 +633,14 @@
log.exception( "Error reading tool from path: %s" % path )
def __add_tool( self, tool, load_panel_dict, panel_dict ):
- # Allow for the same tool to be loaded into multiple places in the tool panel. We have to handle
- # the case where the tool is contained in a repository installed from the tool shed, and the Galaxy
- # administrator has retrieved updates to the installed repository. In this case, the tool may have
- # been updated, but the version was not changed, so the tool should always be reloaded here. We used
- # to only load the tool if it was not found in self.tools_by_id, but performing that check did
- # not enable this scenario.
+ # Allow for the same tool to be loaded into multiple places in the
+ # tool panel. We have to handle the case where the tool is contained
+ # in a repository installed from the tool shed, and the Galaxy
+ # administrator has retrieved updates to the installed repository. In
+ # this case, the tool may have been updated, but the version was not
+ # changed, so the tool should always be reloaded here. We used to
+ # only load the tool if it was not found in self.tools_by_id, but
+ # performing that check did not enable this scenario.
self.tools_by_id[ tool.id ] = tool
if load_panel_dict:
self.__add_tool_to_tool_panel( tool, panel_dict, section=isinstance( panel_dict, ToolSection ) )
@@ -787,8 +795,6 @@
:param tool_id: the tool ID from app.toolbox
:returns: tuple of tarball filename, success True/False, message/None
"""
- message = ''
- success = True
# Make sure the tool is actually loaded.
if tool_id not in self.tools_by_id:
return None, False, "No tool with id %s" % escape( tool_id )
@@ -870,7 +876,6 @@
if os.path.exists( sample_file ):
tarfile_path, tarfile_name = os.path.split( tar_file )
tarfile_path = os.path.join( 'tool-data', tarfile_name )
- sample_name = tarfile_path + '.sample'
tarball_files.append( ( sample_file, tarfile_path ) )
data_table_definitions.append( data_table.xml_string )
if len( data_table_definitions ) > 0:
https://bitbucket.org/galaxy/galaxy-central/commits/50a4c5ef908c/
Changeset: 50a4c5ef908c
User: jmchilton
Date: 2014-12-22 18:16:26+00:00
Summary: Small simplifications to lib/galaxy/tools/__init__.py.
Affected #: 1 file
diff -r 6e956fdb003441f699e24750f02c61c43992a784 -r 50a4c5ef908c38ecf6530d7ac9dd3a497d1ec313 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -289,8 +289,7 @@
for index, integrated_panel_key in enumerate( self.integrated_tool_panel.keys() ):
if key == integrated_panel_key:
panel_dict.insert( index, key, tool )
- if not inserted:
- inserted = True
+ inserted = True
if not inserted:
# Check the tool's installed versions.
for lineage_id in tool.lineage_ids:
@@ -298,8 +297,7 @@
for index, integrated_panel_key in enumerate( self.integrated_tool_panel.keys() ):
if lineage_id_key == integrated_panel_key:
panel_dict.insert( index, key, tool )
- if not inserted:
- inserted = True
+ inserted = True
if not inserted:
if (
tool.guid is None or
@@ -322,8 +320,7 @@
if lineage_id in self.tools_by_id:
loaded_version_key = 'tool_%s' % lineage_id
if loaded_version_key in panel_dict:
- if not already_loaded:
- already_loaded = True
+ already_loaded = True
if not already_loaded:
# If the tool is not defined in integrated_tool_panel.xml, append it to the tool panel.
panel_dict[ key ] = tool
https://bitbucket.org/galaxy/galaxy-central/commits/de3fff02e89f/
Changeset: de3fff02e89f
User: jmchilton
Date: 2014-12-22 18:16:26+00:00
Summary: Remove broken method fix_integrated_tool_panel_dict.
As of 5f6c670 (Jan 10, 2014) this does nothing (``if section_value is None`` followed by ``if isinstance( section_value, Tool ):``) and nobody seemed to notice - so I assume it is unneeded. If still needed - someone needs to fix it :).
Affected #: 1 file
diff -r 50a4c5ef908c38ecf6530d7ac9dd3a497d1ec313 -r de3fff02e89fd4697e9656742ca8e3f4928b1a53 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -163,24 +163,8 @@
# This will cover cases where the Galaxy administrator manually edited one or more of the tool panel
# config files, adding or removing locally developed tools or workflows. The value of integrated_tool_panel
# will be False when things like functional tests are the caller.
- self.fix_integrated_tool_panel_dict()
self.write_integrated_tool_panel_config_file()
- def fix_integrated_tool_panel_dict( self ):
- # HACK: instead of fixing after the fact, I suggest some combination of:
- # 1) adjusting init_tools() and called methods to get this right
- # 2) redesigning the code and/or data structure used to read/write integrated_tool_panel.xml
- for key, value in self.integrated_tool_panel.iteritems():
- if isinstance( value, ToolSection ):
- for section_key, section_value in value.elems.iteritems():
- if section_value is None:
- if isinstance( section_value, Tool ):
- tool_id = section_key[5:]
- value.elems[section_key] = self.tools_by_id.get( tool_id )
- elif isinstance( section_value, Workflow ):
- workflow_id = section_key[9:]
- value.elems[section_key] = self.workflows_by_id.get( workflow_id )
-
def init_tools( self, config_filename ):
"""
Read the configuration file and load each tool. The following tags are currently supported:
@@ -723,7 +707,6 @@
# This will cover cases where the Galaxy administrator manually edited one or more of the tool panel
# config files, adding or removing locally developed tools or workflows. The value of integrated_tool_panel
# will be False when things like functional tests are the caller.
- self.fix_integrated_tool_panel_dict()
self.write_integrated_tool_panel_config_file()
return tool.id
except Exception:
https://bitbucket.org/galaxy/galaxy-central/commits/79f06cadb486/
Changeset: 79f06cadb486
User: jmchilton
Date: 2014-12-22 18:16:27+00:00
Summary: Slightly rework lib/galaxy/workflow/modules.py for readability.
Affected #: 1 file
diff -r de3fff02e89fd4697e9656742ca8e3f4928b1a53 -r 79f06cadb4861bc6e66a1733a0c3bbfa4606240c lib/galaxy/workflow/modules.py
--- a/lib/galaxy/workflow/modules.py
+++ b/lib/galaxy/workflow/modules.py
@@ -506,16 +506,17 @@
@classmethod
def from_workflow_step( Class, trans, step ):
+ toolbox = trans.app.toolbox
tool_id = step.tool_id
- if trans.app.toolbox and tool_id not in trans.app.toolbox.tools_by_id:
+ if toolbox and tool_id not in toolbox.tools_by_id:
# See if we have access to a different version of the tool.
# TODO: If workflows are ever enhanced to use tool version
# in addition to tool id, enhance the selection process here
# to retrieve the correct version of the tool.
- tool = trans.app.toolbox.get_tool( tool_id )
+ tool = toolbox.get_tool( tool_id )
if tool:
tool_id = tool.id
- if ( trans.app.toolbox and tool_id in trans.app.toolbox.tools_by_id ):
+ if ( toolbox and tool_id in toolbox.tools_by_id ):
if step.config:
# This step has its state saved in the config field due to the
# tool being previously unavailable.
https://bitbucket.org/galaxy/galaxy-central/commits/4be779372d6b/
Changeset: 4be779372d6b
User: jmchilton
Date: 2014-12-22 18:16:27+00:00
Summary: Rework toolbox 'fix' tool tags when multiple configs are loaded.
Looks like the tool tag stuff still assumed there was just one config file - that said toolbox doesn't have a self.sa_session so I think tool tags are broken and have been for some time.
Affected #: 1 file
diff -r 79f06cadb4861bc6e66a1733a0c3bbfa4606240c -r 4be779372d6b89656276307f4ae1ed4a8e6a5737 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -143,6 +143,26 @@
self.tool_watcher = watcher.get_watcher( self, app.config )
self.filter_factory = FilterFactory( self )
self.init_dependency_manager()
+ self.init_tools_from_configs( config_filenames )
+ if self.app.name == 'galaxy' and self.integrated_tool_panel_config_has_contents:
+ # Load self.tool_panel based on the order in self.integrated_tool_panel.
+ self.load_tool_panel()
+ if app.config.update_integrated_tool_panel:
+ # Write the current in-memory integrated_tool_panel to the integrated_tool_panel.xml file.
+ # This will cover cases where the Galaxy administrator manually edited one or more of the tool panel
+ # config files, adding or removing locally developed tools or workflows. The value of integrated_tool_panel
+ # will be False when things like functional tests are the caller.
+ self.write_integrated_tool_panel_config_file()
+
+ def init_tools_from_configs( self, config_filenames ):
+ """ Read through all tool config files and initialize tools in each
+ with init_tools_from_config below.
+ """
+ if self.app.config.get_bool( 'enable_tool_tags', False ):
+ log.info("removing all tool tag associations (" + str( self.sa_session.query( self.app.model.ToolTagAssociation ).count() ) + ")" )
+ self.sa_session.query( self.app.model.ToolTagAssociation ).delete()
+ self.sa_session.flush()
+
config_filenames = listify( config_filenames )
for config_filename in config_filenames:
if os.path.isdir( config_filename ):
@@ -152,20 +172,11 @@
config_filenames.extend( directory_config_files )
for config_filename in config_filenames:
try:
- self.init_tools( config_filename )
+ self.init_tools_from_config( config_filename )
except:
log.exception( "Error loading tools defined in config %s", config_filename )
- if self.app.name == 'galaxy' and self.integrated_tool_panel_config_has_contents:
- # Load self.tool_panel based on the order in self.integrated_tool_panel.
- self.load_tool_panel()
- if app.config.update_integrated_tool_panel:
- # Write the current in-memory integrated_tool_panel to the integrated_tool_panel.xml file.
- # This will cover cases where the Galaxy administrator manually edited one or more of the tool panel
- # config files, adding or removing locally developed tools or workflows. The value of integrated_tool_panel
- # will be False when things like functional tests are the caller.
- self.write_integrated_tool_panel_config_file()
-
- def init_tools( self, config_filename ):
+
+ def init_tools_from_config( self, config_filename ):
"""
Read the configuration file and load each tool. The following tags are currently supported:
@@ -183,10 +194,6 @@
</toolbox>
"""
- if self.app.config.get_bool( 'enable_tool_tags', False ):
- log.info("removing all tool tag associations (" + str( self.sa_session.query( self.app.model.ToolTagAssociation ).count() ) + ")" )
- self.sa_session.query( self.app.model.ToolTagAssociation ).delete()
- self.sa_session.flush()
log.info( "Parsing the tool configuration %s" % config_filename )
tree = parse_xml( config_filename )
root = tree.getroot()
https://bitbucket.org/galaxy/galaxy-central/commits/267fa4b9ab6a/
Changeset: 267fa4b9ab6a
User: jmchilton
Date: 2014-12-22 18:16:28+00:00
Summary: Refactor tool tag handling out of toolbox.
Pretty sure this had been broken (toolbox didn't have a self.sa_session). Anyway - this probably didn't fix that but at least now the big read tool tag loop is more readable (cyclomatic complexity of that method down from 18 to 12).
Affected #: 3 files
diff -r 4be779372d6b89656276307f4ae1ed4a8e6a5737 -r 267fa4b9ab6a80a0ae0a1f2ab5f157303f68d46d lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -51,6 +51,7 @@
from galaxy.tools.test import parse_tests
from galaxy.tools.parser import get_tool_source
from galaxy.tools.parser.xml import XmlPageSource
+from galaxy.tools.toolbox import tool_tag_manager
from galaxy.util import listify, parse_xml, rst_to_html, string_as_bool, string_to_object
from galaxy.tools.parameters.meta import expand_meta_parameters
from galaxy.util.bunch import Bunch
@@ -143,6 +144,7 @@
self.tool_watcher = watcher.get_watcher( self, app.config )
self.filter_factory = FilterFactory( self )
self.init_dependency_manager()
+ self.tool_tag_manager = tool_tag_manager( app )
self.init_tools_from_configs( config_filenames )
if self.app.name == 'galaxy' and self.integrated_tool_panel_config_has_contents:
# Load self.tool_panel based on the order in self.integrated_tool_panel.
@@ -158,11 +160,7 @@
""" Read through all tool config files and initialize tools in each
with init_tools_from_config below.
"""
- if self.app.config.get_bool( 'enable_tool_tags', False ):
- log.info("removing all tool tag associations (" + str( self.sa_session.query( self.app.model.ToolTagAssociation ).count() ) + ")" )
- self.sa_session.query( self.app.model.ToolTagAssociation ).delete()
- self.sa_session.flush()
-
+ self.tool_tag_manager.reset_tags()
config_filenames = listify( config_filenames )
for config_filename in config_filenames:
if os.path.isdir( config_filename ):
@@ -588,27 +586,7 @@
self.app.install_model.context.flush()
# Load the tool's lineage ids.
tool.lineage_ids = tool.tool_version.get_version_ids( self.app )
- if self.app.config.get_bool( 'enable_tool_tags', False ):
- tag_names = elem.get( "tags", "" ).split( "," )
- for tag_name in tag_names:
- if tag_name == '':
- continue
- tag = self.sa_session.query( self.app.model.Tag ).filter_by( name=tag_name ).first()
- if not tag:
- tag = self.app.model.Tag( name=tag_name )
- self.sa_session.add( tag )
- self.sa_session.flush()
- tta = self.app.model.ToolTagAssociation( tool_id=tool.id, tag_id=tag.id )
- self.sa_session.add( tta )
- self.sa_session.flush()
- else:
- for tagged_tool in tag.tagged_tools:
- if tagged_tool.tool_id == tool.id:
- break
- else:
- tta = self.app.model.ToolTagAssociation( tool_id=tool.id, tag_id=tag.id )
- self.sa_session.add( tta )
- self.sa_session.flush()
+ self.tool_tag_manager.handle_tags( tool.id, elem )
self.__add_tool( tool, load_panel_dict, panel_dict )
# Always load the tool into the integrated_panel_dict, or it will not be included in the integrated_tool_panel.xml file.
if key in integrated_panel_dict or index is None:
diff -r 4be779372d6b89656276307f4ae1ed4a8e6a5737 -r 267fa4b9ab6a80a0ae0a1f2ab5f157303f68d46d lib/galaxy/tools/toolbox/__init__.py
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/__init__.py
@@ -0,0 +1,7 @@
+""" API for this module containing functionality related to the tool box.
+"""
+
+from .tags import tool_tag_manager
+
+
+__all__ = ["tool_tag_manager"]
diff -r 4be779372d6b89656276307f4ae1ed4a8e6a5737 -r 267fa4b9ab6a80a0ae0a1f2ab5f157303f68d46d lib/galaxy/tools/toolbox/tags.py
--- /dev/null
+++ b/lib/galaxy/tools/toolbox/tags.py
@@ -0,0 +1,76 @@
+""" Handle details of tool tagging - perhaps a deprecated feature.
+"""
+from abc import ABCMeta
+from abc import abstractmethod
+
+import logging
+log = logging.getLogger( __name__ )
+
+
+def tool_tag_manager( app ):
+ """ Build a tool tag manager according to app's configuration
+ and return it.
+ """
+ if hasattr( app.config, "get_bool" ) and app.config.get_bool( 'enable_tool_tags', False ):
+ return PersistentToolTagManager( app )
+ else:
+ return NullToolTagManager()
+
+
+class AbstractToolTagManager( object ):
+ __metaclass__ = ABCMeta
+
+ @abstractmethod
+ def reset_tags( self ):
+ """ Starting to load tool panels, reset all tags.
+ """
+
+ @abstractmethod
+ def handle_tags( self, tool_id, tool_definition_source ):
+ """ Parse out tags and persist them.
+ """
+
+
+class NullToolTagManager( AbstractToolTagManager ):
+
+ def reset_tags( self ):
+ return None
+
+ def handle_tags( self, tool_id, tool_definition_source ):
+ return None
+
+
+class PersistentToolTagManager( AbstractToolTagManager ):
+
+ def __init__( self, app ):
+ self.app = app
+ self.sa_session = app.sa_session
+
+ def reset_tags( self ):
+ log.info("removing all tool tag associations (" + str( self.sa_session.query( self.app.model.ToolTagAssociation ).count() ) + ")" )
+ self.sa_session.query( self.app.model.ToolTagAssociation ).delete()
+ self.sa_session.flush()
+
+ def handle_tags( self, tool_id, tool_definition_source ):
+ elem = tool_definition_source
+ if self.app.config.get_bool( 'enable_tool_tags', False ):
+ tag_names = elem.get( "tags", "" ).split( "," )
+ for tag_name in tag_names:
+ if tag_name == '':
+ continue
+ tag = self.sa_session.query( self.app.model.Tag ).filter_by( name=tag_name ).first()
+ if not tag:
+ tag = self.app.model.Tag( name=tag_name )
+ self.sa_session.add( tag )
+ self.sa_session.flush()
+ tta = self.app.model.ToolTagAssociation( tool_id=tool_id, tag_id=tag.id )
+ self.sa_session.add( tta )
+ self.sa_session.flush()
+ else:
+ for tagged_tool in tag.tagged_tools:
+ if tagged_tool.tool_id == tool_id:
+ break
+ else:
+ tta = self.app.model.ToolTagAssociation( tool_id=tool_id, tag_id=tag.id )
+ self.sa_session.add( tta )
+ self.sa_session.flush()
https://bitbucket.org/galaxy/galaxy-central/commits/d0c38a7861e5/
Changeset: d0c38a7861e5
User: jmchilton
Date: 2014-12-22 18:16:28+00:00
Summary: Tweak completely broken DataTransfer._execute_workflow to respect toolbox abstraction.
Least of the brokeness at this point I suppose - but I would like to not expose tools_by_id external to the Toolbox.
Affected #: 1 file
diff -r 267fa4b9ab6a80a0ae0a1f2ab5f157303f68d46d -r d0c38a7861e5d42f6068963f0917a78cdc9e6860 lib/galaxy/jobs/deferred/data_transfer.py
--- a/lib/galaxy/jobs/deferred/data_transfer.py
+++ b/lib/galaxy/jobs/deferred/data_transfer.py
@@ -356,7 +356,7 @@
for i, step in enumerate( workflow.steps ):
job = None
if step.type == 'tool' or step.type is None:
- tool = self.app.toolbox.tools_by_id[ step.tool_id ]
+ tool = self.app.toolbox.get_tool( step.tool_id )
def callback( input, value, prefixed_name, prefixed_label ):
if isinstance( input, DataToolParameter ):
if prefixed_name in step.input_connections_by_name:
https://bitbucket.org/galaxy/galaxy-central/commits/34b3e1ca729d/
Changeset: 34b3e1ca729d
User: jmchilton
Date: 2014-12-22 18:16:30+00:00
Summary: Start decoupling Toolbox elements from XML (sections+labels).
Just a small tweak and some tests to verify these things can indeed be created from dictionaries. Also slightly simplifies galaxy.tools.
Affected #: 2 files
diff -r d0c38a7861e5d42f6068963f0917a78cdc9e6860 -r 34b3e1ca729df33c32e96ca9202d3a80836c21ed lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -330,12 +330,13 @@
elif isinstance( val, ToolSectionLabel ):
self.tool_panel[ key ] = val
elif isinstance( val, ToolSection ):
- elem = ElementTree.Element( 'section' )
- elem.attrib[ 'id' ] = val.id or ''
- elem.attrib[ 'name' ] = val.name or ''
- elem.attrib[ 'version' ] = val.version or ''
- section = ToolSection( elem )
- log.debug( "Loading section: %s" % elem.get( 'name' ) )
+ section_dict = {
+ 'id': val.id or '',
+ 'name': val.name or '',
+ 'version': val.version or '',
+ }
+ section = ToolSection( section_dict )
+ log.debug( "Loading section: %s" % section_dict.get( 'name' ) )
for section_key, section_val in val.elems.items():
if isinstance( section_val, Tool ):
tool_id = section_key.replace( 'tool_', '', 1 )
@@ -1050,6 +1051,8 @@
dict_collection_visible_keys = ( 'id', 'name', 'version' )
def __init__( self, elem=None ):
+ """ Build a ToolSection from an ElementTree element or a dictionary.
+ """
f = lambda elem, val: elem is not None and elem.get( val ) or ''
self.name = f( elem, 'name' )
self.id = f( elem, 'id' )
@@ -1089,6 +1092,9 @@
dict_collection_visible_keys = ( 'id', 'text', 'version' )
def __init__( self, elem ):
+ """ Build a ToolSectionLabel from an ElementTree element or a
+ dictionary.
+ """
self.text = elem.get( "text" )
self.id = elem.get( "id" )
self.version = elem.get( "version" ) or ''
diff -r d0c38a7861e5d42f6068963f0917a78cdc9e6860 -r 34b3e1ca729df33c32e96ca9202d3a80836c21ed test/unit/tools/test_tool_panel.py
--- /dev/null
+++ b/test/unit/tools/test_tool_panel.py
@@ -0,0 +1,26 @@
+from xml.etree import ElementTree as ET
+from galaxy.tools import ToolSection
+
+
+def test_tool_section( ):
+ elem = ET.Element( 'section' )
+ elem.attrib[ 'name' ] = "Cool Tools"
+ elem.attrib[ 'id' ] = "cool1"
+
+ section = ToolSection( elem )
+ assert section.id == "cool1"
+ assert section.name == "Cool Tools"
+ assert section.version == ""
+
+ section = ToolSection( dict(
+ id="cool1",
+ name="Cool Tools"
+ ) )
+ assert section.id == "cool1"
+ assert section.name == "Cool Tools"
+ assert section.version == ""
+
+ section = ToolSection()
+ assert section.id == ""
+ assert section.name == ""
+ assert section.version == ""
https://bitbucket.org/galaxy/galaxy-central/commits/1aa8a57c5994/
Changeset: 1aa8a57c5994
User: jmchilton
Date: 2014-12-22 18:16:30+00:00
Summary: Add comment to auto-generated integrated_tool_panel.xml.
Someone more familiar with integrated_tool_panel.xml should feel free to make this comment sharper - but something is better nothing I think.
Affected #: 1 file
diff -r 34b3e1ca729df33c32e96ca9202d3a80836c21ed -r 1aa8a57c599455b2a9faeeadb980b62b8abecc1f lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -96,6 +96,16 @@
HELP_UNINITIALIZED = threading.Lock()
+INTEGRATED_TOOL_PANEL_DESCRIPTION = """
+This is Galaxy's integrated tool panel and probably should not be modified
+directly. It will be regenerated each time Galaxy starts up. To modify locally
+managed tools (e.g. from tool_conf.xml) modify that file directly and restart
+Galaxy. Whenever possible Tool Shed managed tools (e.g. from shed_tool_conf.xml)
+should be managed from within the Galaxy interface of via is UI - but if changes
+are nessecary (such as to hide a tool or re-assign its section) modify that file
+and restart Galaxy.
+"""
+
class ToolNotFoundException( Exception ):
pass
@@ -396,6 +406,9 @@
fd, filename = tempfile.mkstemp()
os.write( fd, '<?xml version="1.0"?>\n' )
os.write( fd, '<toolbox>\n' )
+ os.write( fd, ' <!--\n ')
+ os.write( fd, '\n '.join( [ l for l in INTEGRATED_TOOL_PANEL_DESCRIPTION.split("\n") if l ] ) )
+ os.write( fd, '\n -->\n')
for key, item in self.integrated_tool_panel.items():
if item:
if isinstance( item, Tool ):
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.