1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/1bd3e09417b1/ changeset: 1bd3e09417b1 user: greg date: 2013-01-11 21:06:35 summary: When installing multiple repositories sumultaneously, merge all repository and tool dependenceis into a single container for display. affected #: 3 files diff -r be7625f376d16cefa2fb4984fa6483f37b4b71d4 -r 1bd3e09417b16e31d2ecce606ac1db5f5564e887 lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -1,4 +1,4 @@ -import os, tempfile, shutil, logging, urllib2 +import os, tempfile, shutil, logging, urllib2, threading from galaxy.datatypes import checkers from galaxy.web import url_for from galaxy import util @@ -1202,6 +1202,78 @@ def load_installed_display_applications( app, installed_repository_dict, deactivate=False ): # Load or deactivate proprietary datatype display applications app.datatypes_registry.load_display_applications( installed_repository_dict=installed_repository_dict, deactivate=deactivate ) +def merge_containers_dicts_for_new_install( containers_dicts ): + """ + When installing one or more tool shed repositories for the first time, the received list of containers_dicts contains a containers_dict for + each repository being installed. Since the repositories are being installed for the first time, all entries are None except the repository + dependencies and tool dependencies. The entries for missing dependencies are all None since they have previously been merged into the installed + dependencies. This method will merge the dependencies entries into a single container and return it for display. + """ + new_containers_dict = dict( readme_files=None, + datatypes=None, + missing_repository_dependencies=None, + repository_dependencies=None, + missing_tool_dependencies=None, + tool_dependencies=None, + invalid_tools=None, + valid_tools=None, + workflows=None ) + if containers_dicts: + lock = threading.Lock() + lock.acquire( True ) + try: + repository_dependencies_root_folder = None + tool_dependencies_root_folder = None + # Use a unique folder id (hopefully the following is). + folder_id = 867 + for old_container_dict in containers_dicts: + # Merge repository_dependencies. + old_container_repository_dependencies_root = old_container_dict[ 'repository_dependencies' ] + if old_container_repository_dependencies_root: + if repository_dependencies_root_folder is None: + repository_dependencies_root_folder = container_util.Folder( id=folder_id, key='root', label='root', parent=None ) + folder_id += 1 + repository_dependencies_folder = container_util.Folder( id=folder_id, + key='merged', + label='Repository dependencies', + parent=repository_dependencies_root_folder ) + folder_id += 1 + # The old_container_repository_dependencies_root will be a root folder containing a single sub_folder. + old_container_repository_dependencies_folder = old_container_repository_dependencies_root.folders[ 0 ] + # Change the folder id so it won't confict with others being merged. + old_container_repository_dependencies_folder.id = folder_id + folder_id += 1 + # Generate the label by retrieving the repository name. + toolshed, name, owner, changeset_revision = container_util.get_components_from_key( old_container_repository_dependencies_folder.key ) + old_container_repository_dependencies_folder.label = str( name ) + repository_dependencies_folder.folders.append( old_container_repository_dependencies_folder ) + # Merge tool_dependencies. + old_container_tool_dependencies_root = old_container_dict[ 'tool_dependencies' ] + if old_container_tool_dependencies_root: + if tool_dependencies_root_folder is None: + tool_dependencies_root_folder = old_container_tool_dependencies_root + # Change the folder id so it won't confict with others being merged. + tool_dependencies_root_folder.id = folder_id + folder_id += 1 + tool_dependencies_folder = tool_dependencies_root_folder.folders[ 0 ] + tool_dependencies_folder.id = folder_id + folder_id += 1 + else: + # The old_container_tool_dependencies_root will be a root folder containing a single sub_folder. + old_container_tool_dependencies_folder = old_container_tool_dependencies_root.folders[ 0 ] + for td in old_container_tool_dependencies_folder.tool_dependencies: + tool_dependencies_folder.tool_dependencies.append( td ) + if repository_dependencies_root_folder: + repository_dependencies_root_folder.folders.append( repository_dependencies_folder ) + new_containers_dict[ 'repository_dependencies' ] = repository_dependencies_root_folder + if tool_dependencies_root_folder: + tool_dependencies_root_folder.folders.append( tool_dependencies_folder ) + new_containers_dict[ 'tool_dependencies' ] = tool_dependencies_root_folder + except Exception, e: + log.debug( "Exception in merge_containers_dicts_for_new_install: %s" % str( e ) ) + finally: + lock.release() + return new_containers_dict def panel_entry_per_tool( tool_section_dict ): # Return True if tool_section_dict looks like this. # {<Tool guid> : [{ tool_config : <tool_config_file>, id: <ToolSection id>, version : <ToolSection version>, name : <TooSection name>}]} diff -r be7625f376d16cefa2fb4984fa6483f37b4b71d4 -r 1bd3e09417b16e31d2ecce606ac1db5f5564e887 lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py --- a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py @@ -1266,7 +1266,6 @@ shed_tool_conf_select_field = None tool_path = suc.get_tool_path_by_shed_tool_conf_filename( trans, shed_tool_conf ) tool_panel_section_select_field = build_tool_panel_section_select_field( trans ) - containers_dicts = [] if len( repo_info_dicts ) == 1: # If we're installing a single repository, see if it contains a readme or dependencies that we can display. repo_info_dict = repo_info_dicts[ 0 ] @@ -1287,13 +1286,9 @@ missing_repository_dependencies=missing_repository_dependencies, installed_tool_dependencies=installed_tool_dependencies, missing_tool_dependencies=missing_tool_dependencies ) - containers_dicts.append( containers_dict ) else: # We're installing a list of repositories, each of which may have tool dependencies or repository dependencies. - all_installed_repository_dependencies = [] - all_missing_repository_dependencies = [] - all_installed_tool_dependencies = [] - all_missing_tool_dependencies = [] + containers_dicts = [] for repo_info_dict in repo_info_dicts: name, repository_owner, changeset_revision, includes_tool_dependencies, installed_repository_dependencies, \ missing_repository_dependencies, installed_tool_dependencies, missing_tool_dependencies = \ @@ -1302,11 +1297,13 @@ tool_shed_url=tool_shed_url, tool_path=tool_path, readme_files_dict=None, - repository_dependencies=installed_repository_dependencies, + installed_repository_dependencies=installed_repository_dependencies, missing_repository_dependencies=missing_repository_dependencies, - tool_dependencies=installed_tool_dependencies, + installed_tool_dependencies=installed_tool_dependencies, missing_tool_dependencies=missing_tool_dependencies ) containers_dicts.append( containers_dict ) + # Merge all containers into a single container. + containers_dict = shed_util.merge_containers_dicts_for_new_install( containers_dicts ) # Handle tool dependencies chack box. if trans.app.config.tool_dependency_dir is None: if includes_tool_dependencies: @@ -1327,7 +1324,7 @@ includes_repository_dependencies=includes_repository_dependencies, install_repository_dependencies_check_box=install_repository_dependencies_check_box, new_tool_panel_section=new_tool_panel_section, - containers_dicts=containers_dicts, + containers_dict=containers_dict, shed_tool_conf=shed_tool_conf, shed_tool_conf_select_field=shed_tool_conf_select_field, tool_panel_section_select_field=tool_panel_section_select_field, diff -r be7625f376d16cefa2fb4984fa6483f37b4b71d4 -r 1bd3e09417b16e31d2ecce606ac1db5f5564e887 templates/admin/tool_shed_repository/select_tool_panel_section.mako --- a/templates/admin/tool_shed_repository/select_tool_panel_section.mako +++ b/templates/admin/tool_shed_repository/select_tool_panel_section.mako @@ -20,25 +20,24 @@ # this case, the repository metadata is an empty dictionary, but one or both of includes_repository_dependencies # and includes_tool_dependencies may be True. If either of these are True but we have no metadata, we cannot install # repository dependencies on this pass. - - # TODO: do we need this? - can_display_repository_dependencies = False - can_display_tool_dependencies = False - - if includes_repository_dependencies and not can_display_repository_dependencies: - for containers_dict in containers_dicts: - repository_dependencies = containers_dict[ 'repository_dependencies' ] - missing_repository_dependencies = containers_dict[ 'missing_repository_dependencies' ] - if repository_dependencies or missing_repository_dependencies: - can_display_repository_dependencies = True - break - if includes_tool_dependencies and not can_display_tool_dependencies: - for containers_dict in containers_dicts: - tool_dependencies = containers_dict[ 'tool_dependencies' ] - missing_tool_dependencies = containers_dict[ 'missing_tool_dependencies' ] - if tool_dependencies or missing_tool_dependencies: - can_display_tool_dependencies = True - break + if includes_repository_dependencies: + repository_dependencies = containers_dict[ 'repository_dependencies' ] + missing_repository_dependencies = containers_dict[ 'missing_repository_dependencies' ] + if repository_dependencies or missing_repository_dependencies: + can_display_repository_dependencies = True + else: + can_display_repository_dependencies = False + else: + can_display_repository_dependencies = False + if includes_tool_dependencies: + tool_dependencies = containers_dict[ 'tool_dependencies' ] + missing_tool_dependencies = containers_dict[ 'missing_tool_dependencies' ] + if tool_dependencies or missing_tool_dependencies: + can_display_tool_dependencies = True + else: + can_display_tool_dependencies = False + else: + can_display_tool_dependencies = False %> %if message: @@ -63,14 +62,7 @@ <div class="toolFormBody"><form name="select_tool_panel_section" id="select_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='prepare_for_install', tool_shed_url=tool_shed_url, encoded_repo_info_dicts=encoded_repo_info_dicts, includes_tools=includes_tools, includes_tool_dependencies=includes_tool_dependencies )}" method="post" ><div style="clear: both"></div> - <% - if len( containers_dicts ) == 1: - containers_dict = containers_dicts[ 0 ] - readme_files_dict = containers_dict.get( 'readme_files', None ) - else: - containers_dict = None - readme_files_dict = None - %> + <% readme_files_dict = containers_dict.get( 'readme_files', None ) %> %if readme_files_dict: <div class="form-row"><table class="colored" width="100%"> @@ -86,15 +78,8 @@ <th bgcolor="#EBD9B2">Confirm dependency installation</th></table></div> - %for index, containers_dict in enumerate( containers_dicts ): - %if index == 0: - ${render_dependencies_section( install_repository_dependencies_check_box, install_tool_dependencies_check_box, containers_dict )} - <div style="clear: both"></div> - %else: - ${render_dependencies_section( None, None, containers_dict )} - <div style="clear: both"></div> - %endif - %endfor + ${render_dependencies_section( install_repository_dependencies_check_box, install_tool_dependencies_check_box, containers_dict )} + <div style="clear: both"></div> %endif <div class="form-row"><table class="colored" width="100%"> 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.