1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/a00a36e7cf4c/ changeset: a00a36e7cf4c user: greg date: 2012-02-10 22:33:19 summary: Do not allow conflicting datatypes included in a tool shed repository currently being installed to override datattypes already in the datatypes registry. Also, a bit of cleanup in handling datatypes included in repositories being activated / installed / deactivated / uninstalled. A bit more cleanup is still necessary. affected #: 3 files diff -r 62fc9e05383514811e5add9db5f9ad6560a06b20 -r a00a36e7cf4c3b73a0ee2a411b065213f19cf3df lib/galaxy/datatypes/registry.py --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -47,11 +47,13 @@ self.datatype_elems = [] self.sniffer_elems = [] self.xml_filename = None - def load_datatypes( self, root_dir=None, config=None, deactivate=False ): + def load_datatypes( self, root_dir=None, config=None, deactivate=False, override=True ): """ - Parse a datatypes XML file located at root_dir/config. If deactivate is True, an installed - tool shed repository that includes proprietary datatypes is being deactivated, so appropriate - loaded datatypes will be removed from the registry. + Parse a datatypes XML file located at root_dir/config. If deactivate is True, an installed tool shed + repository that includes proprietary datatypes is being deactivated, so appropriate loaded datatypes + will be removed from the registry. The value of override will be False when a tool shed repository is + being installed. Since installation is occurring after the datatypes registry has been initialized, its + contents cannot be overridden by new introduced conflicting data types. """ def __import_module( full_path, datatype_module ): sys.path.insert( 0, full_path ) @@ -116,9 +118,13 @@ self.datatype_elems.append( elem ) if extension and extension in self.datatypes_by_extension and deactivate: # We are deactivating an installed tool shed repository, so eliminate the datatype from the registry. + # TODO: Handle deactivating datatype converters, etc before removing from self.datatypes_by_extension. self.log.debug( "Removing datatype with extension '%s' from the registry." % extension ) del self.datatypes_by_extension[ extension ] - elif extension and ( dtype or type_extension ): + can_process_datatype = False + else: + can_process_datatype = ( extension and ( dtype or type_extension ) ) and ( extension not in self.datatypes_by_extension or override ) + if can_process_datatype: if dtype: fields = dtype.split( ':' ) datatype_module = fields[0] @@ -194,6 +200,11 @@ else: if elem not in self.display_app_containers: self.display_app_containers.append( elem ) + elif not deactivate: + # A new tool shed repository that contains proprietary datatypes is being installed, and since installation + # is occurring after the datatypes registry has been initialized, its contents cannot be overridden by new + # introduced conflicting data types. + self.log.warning( "Ignoring conflicting datatype with extension '%s' from %s." % ( extension, config ) ) except Exception, e: if deactivate: self.log.warning( "Error deactivating datatype with extension '%s': %s" % ( extension, str( e ) ) ) @@ -233,14 +244,22 @@ self.log.debug( "Deactivated sniffer for datatype '%s'" % dtype ) else: # See if we have a conflicting sniffer already loaded. + conflict = False for conflict_loc, sniffer_class in enumerate( self.sniff_order ): if sniffer_class.__class__ == aclass.__class__: # We have a conflicting sniffer, so replace the one previously loaded. - del self.sniff_order[ conflict_loc ] - self.log.debug( "Replaced conflicting sniffer for datatype '%s'" % dtype ) + conflict = True + if override: + del self.sniff_order[ conflict_loc ] + self.log.debug( "Replaced conflicting sniffer for datatype '%s'" % dtype ) break - self.sniff_order.append( aclass ) - self.log.debug( "Loaded sniffer for datatype '%s'" % dtype ) + if conflict: + if override: + self.sniff_order.append( aclass ) + self.log.debug( "Loaded sniffer for datatype '%s'" % dtype ) + else: + self.sniff_order.append( aclass ) + self.log.debug( "Loaded sniffer for datatype '%s'" % dtype ) except Exception, exc: if deactivate: self.log.warning( "Error deactivating sniffer for datatype '%s': %s" % ( dtype, str( exc ) ) ) diff -r 62fc9e05383514811e5add9db5f9ad6560a06b20 -r a00a36e7cf4c3b73a0ee2a411b065213f19cf3df lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -527,12 +527,14 @@ if display_path: # Load or deactivate proprietary datatype display applications app.datatypes_registry.load_display_applications( installed_repository_dict=repository_dict, deactivate=deactivate ) -def alter_config_and_load_prorietary_datatypes( app, datatypes_config, relative_install_dir, deactivate=False ): +def alter_config_and_load_prorietary_datatypes( app, datatypes_config, relative_install_dir, deactivate=False, override=True ): """ Parse a proprietary datatypes config (a datatypes_conf.xml file included in an installed tool shed repository) and add information to appropriate elements that will enable proprietary datatype class modules, datatypes converters - and display application to be discovered and properly imported by the datatypes registry. This method is used by - the InstallManager, which does not have access to trans. + and display application to be discovered and properly imported by the datatypes registry. The value of override will + be False when a tool shed repository is being installed. Since installation is occurring after the datatypes registry + has been initialized, its contents cannot be overridden by conflicting data types. This method is used by the InstallManager, + which does not have access to trans. """ tree = util.parse_xml( datatypes_config ) datatypes_config_root = tree.getroot() @@ -597,7 +599,7 @@ else: proprietary_datatypes_config = datatypes_config # Load proprietary datatypes - app.datatypes_registry.load_datatypes( root_dir=app.config.root, config=proprietary_datatypes_config, deactivate=deactivate ) + app.datatypes_registry.load_datatypes( root_dir=app.config.root, config=proprietary_datatypes_config, deactivate=deactivate, override=override ) try: os.unlink( proprietary_datatypes_config ) except: @@ -728,7 +730,8 @@ if 'datatypes_config' in metadata_dict: datatypes_config = os.path.abspath( metadata_dict[ 'datatypes_config' ] ) # Load data types required by tools. - converter_path, display_path = alter_config_and_load_prorietary_datatypes( app, datatypes_config, relative_install_dir ) + override = not new_install + converter_path, display_path = alter_config_and_load_prorietary_datatypes( app, datatypes_config, relative_install_dir, override=override ) if converter_path or display_path: # Create a dictionary of tool shed repository related information. repository_dict = create_repository_dict_for_proprietary_datatypes( tool_shed=tool_shed, diff -r 62fc9e05383514811e5add9db5f9ad6560a06b20 -r a00a36e7cf4c3b73a0ee2a411b065213f19cf3df lib/galaxy/web/controllers/admin_toolshed.py --- a/lib/galaxy/web/controllers/admin_toolshed.py +++ b/lib/galaxy/web/controllers/admin_toolshed.py @@ -616,9 +616,6 @@ break for elem in sections_to_load: trans.app.toolbox.load_section_tag_set( elem, trans.app.toolbox.tool_panel, tool_path ) - if repository.includes_datatypes: - # Load proprietary datatypes. - load_datatype_items( trans.app, repository, relative_install_dir ) if uninstalled: message = 'The <b>%s</b> repository has been reinstalled.' % repository.name else: @@ -656,8 +653,6 @@ if tool_section: trans.app.toolbox.tool_panel[ section_key ] = tool_section log.debug( "Appended reactivated tool to section: %s" % tool_section.name ) - shed_tool_conf, tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository ) - load_datatype_items( trans.app, repository, relative_install_dir ) @web.expose @web.require_admin def manage_repository( self, trans, **kwd ): 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.