From fa550e100ff760e810aaf24f256273e551161e02 Mon Sep 17 00:00:00 2001 From: Greg Von Kuster Date: Wed, 29 Feb 2012 11:34:10 -0500 Subject: [PATCH] Fixes for installing tool shed repositories that contain tools when done by the InstallManager, and loading the tool panel with tools in an installed repository. --- lib/galaxy/tool_shed/install_manager.py | 20 +++++++++++++------- lib/galaxy/tools/__init__.py | 5 ++--- lib/galaxy/util/shed_util.py | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/galaxy/tool_shed/install_manager.py b/lib/galaxy/tool_shed/install_manager.py index f475ffc73da..d37fd58568b 100644 --- a/lib/galaxy/tool_shed/install_manager.py +++ b/lib/galaxy/tool_shed/install_manager.py @@ -116,19 +116,25 @@ class InstallManager( object ): changeset_revision, tmp_name ): # Generate the metadata for the installed tool shed repository, among other things. It is critical that the installed repository is # updated to the desired changeset_revision before metadata is set because the process for setting metadata uses the repository files on disk. - tool_panel_dict = {} + tool_panel_dict_for_display = {} + tool_panel_dict_for_metadata = {} for tool_elem in repository_elem: # The tool_elem looks something like this: tool_config = tool_elem.get( 'file' ) + guid = self.get_guid( repository_clone_url, relative_install_dir, tool_config ) # See if tool_config is defined somewhere in self.proprietary_tool_panel_elems. is_loaded, tool_section = self.get_containing_tool_section( tool_config ) + tool_panel_dict_for_tool_config = generate_tool_panel_dict_for_tool_config( guid, tool_config, tool_section=tool_section ) + # The tool_panel_dict_for_tool_config dictionary contains a single entry that looks something like this. + # { : { tool_config : , id: , version : , name : }} + # Add the new entry to the dictionary we're defining to set metadata. + for k, v in tool_panel_dict_for_tool_config.items(): + tool_panel_dict_for_metadata[ k ] = v if is_loaded: - guid = self.get_guid( repository_clone_url, relative_install_dir, tool_config ) - tool_panel_dict_for_tool_config = generate_tool_panel_dict_for_tool_config( guid, tool_config, tool_section=tool_section ) - # { : { tool_config : , id: , version : , name : }} + # Add the new entry to the dictionary we're defining to set the tool panel display. for k, v in tool_panel_dict_for_tool_config.items(): - tool_panel_dict[ k ] = v - metadata_dict = generate_metadata( self.toolbox, relative_install_dir, repository_clone_url, tool_panel_dict=tool_panel_dict ) + tool_panel_dict_for_display[ k ] = v + metadata_dict = generate_metadata( self.toolbox, relative_install_dir, repository_clone_url, tool_panel_dict=tool_panel_dict_for_metadata ) # Add a new record to the tool_shed_repository table if one doesn't already exist. If one exists but is marked # deleted, undelete it. It is critical that this happens before the call to add_to_tool_panel() below because # tools will not be properly loaded if the repository is marked deleted. @@ -157,7 +163,7 @@ class InstallManager( object ): repository_tools_tups, self.repository_owner, self.migrated_tools_config, - tool_panel_dict, + tool_panel_dict=tool_panel_dict_for_display, new_install=True ) # Remove the temporary file try: diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index f18300d31b3..1827bdb8882 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -189,14 +189,14 @@ class ToolBox( object ): tool_panel_dict = generate_tool_panel_dict_for_repository_tools( metadata, tool_section=tool_section ) if section: # This means all tools are loaded into the same tool panel section or are all outside of any sections. - for guid, tool_section_dict in tool_panel_dict.items(): + for tool_panel_dict_guid, tool_section_dict in tool_panel_dict.items(): if tool_section_dict [ 'id' ] != section.id or \ tool_section_dict [ 'version' ] != section.version or \ tool_section_dict [ 'name' ] != section.name: tool_section_dict [ 'id' ] = section.id tool_section_dict [ 'version' ] = section.version tool_section_dict [ 'name' ] = section.name - tool_panel_dict[ guid ] = tool_section_dict + tool_panel_dict[ tool_panel_dict_guid ] = tool_section_dict update_needed = True else: # The tool_panel_section was introduced late, so set it's value if its missing in the metadata. @@ -1986,7 +1986,6 @@ class Tool: Find extra files in the job working directory and move them into the appropriate dataset's files directory """ - # print "Working in collect_associated_files" for name, hda in output.items(): temp_file_path = os.path.join( job_working_directory, "dataset_%s_files" % ( hda.dataset.id ) ) try: diff --git a/lib/galaxy/util/shed_util.py b/lib/galaxy/util/shed_util.py index fd7a1fa3b2f..c39ad7349d7 100644 --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -18,14 +18,14 @@ def add_to_tool_panel( app, repository_name, repository_clone_url, changeset_rev index, shed_tool_conf_dict = get_shed_tool_conf_dict( app, shed_tool_conf ) tool_path = shed_tool_conf_dict[ 'tool_path' ] config_elems = shed_tool_conf_dict[ 'config_elems' ] - # Generate the list of ElementTree Element objects for each section or list of tools. + # Generate the list of ElementTree Element objects for each section or tool. elem_list = generate_tool_panel_elem_list( repository_name, repository_clone_url, changeset_revision, tool_panel_dict, repository_tools_tups, owner=owner ) - # Load the tools into the tool panel outside of any sections. + # Load the tools into the tool panel. for config_elem in elem_list: if config_elem.tag == 'section': app.toolbox.load_section_tag_set( config_elem, app.toolbox.tool_panel, tool_path )