1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/fdcdc0115a12/ changeset: fdcdc0115a12 user: greg date: 2011-12-15 16:49:40 summary: Reset repository metadata for installed tool shed repositories when a new update to the repository contents has been pulled from the tool shed. affected #: 3 files diff -r 13ba6909faae12b0a7efcdc76e0797c5e7903929 -r fdcdc0115a123aa40bc46e69df769f171837534e lib/galaxy/tool_shed/install_manager.py --- a/lib/galaxy/tool_shed/install_manager.py +++ b/lib/galaxy/tool_shed/install_manager.py @@ -73,18 +73,19 @@ if returncode == 0: returncode, tmp_name = update_repository( current_working_dir, relative_install_dir, changeset_revision ) if returncode == 0: - metadata_dict = load_repository_contents( self.app, - name, - description, - self.repository_owner, - changeset_revision, - repository_clone_url, - self.install_tool_config, - self.tool_path, - tool_section, - relative_install_dir, - current_working_dir, - tmp_name ) + metadata_dict = load_repository_contents( app=self.app, + name=name, + description=description, + owner=self.repository_owner, + changeset_revision=changeset_revision, + tool_path=self.tool_path, + repository_clone_url=repository_clone_url, + relative_install_dir=relative_install_dir, + current_working_dir=current_working_dir, + tmp_name=tmp_name, + tool_section=tool_section, + shed_tool_conf=self.install_tool_config, + new_install=True ) # Add a new record to the tool_id_guid_map table for each # tool in the repository if one doesn't already exist. if 'tools' in metadata_dict: diff -r 13ba6909faae12b0a7efcdc76e0797c5e7903929 -r fdcdc0115a123aa40bc46e69df769f171837534e lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -2,6 +2,7 @@ from datetime import date, datetime, timedelta from time import strftime from galaxy import util +from galaxy.util.json import * from galaxy.tools import ToolSection from galaxy.tools.search import ToolBoxSearch from galaxy.model.orm import * @@ -77,7 +78,7 @@ os.chdir( current_working_dir ) tmp_stderr.close() return returncode, tmp_name -def create_or_undelete_tool_shed_repository( app, name, description, changeset_revision, repository_clone_url, metadata_dict, owner='' ): +def create_or_update_tool_shed_repository( app, name, description, changeset_revision, repository_clone_url, metadata_dict, owner='' ): # This method is used by the InstallManager, which does not have access to trans. sa_session = app.model.context.current tmp_url = clean_repository_clone_url( repository_clone_url ) @@ -85,16 +86,13 @@ if not owner: owner = get_repository_owner( tmp_url ) includes_datatypes = 'datatypes_config' in metadata_dict - flush_needed = False tool_shed_repository = get_repository_by_shed_name_owner_changeset_revision( app, tool_shed, name, owner, changeset_revision ) if tool_shed_repository: - if tool_shed_repository.deleted: - tool_shed_repository.description = description - tool_shed_repository.changeset_revision = changeset_revision - tool_shed_repository.metadata = metadata_dict - tool_shed_repository.includes_datatypes = includes_datatypes - tool_shed_repository.deleted = False - flush_needed = True + tool_shed_repository.description = description + tool_shed_repository.changeset_revision = changeset_revision + tool_shed_repository.metadata = metadata_dict + tool_shed_repository.includes_datatypes = includes_datatypes + tool_shed_repository.deleted = False else: tool_shed_repository = app.model.ToolShedRepository( tool_shed=tool_shed, name=name, @@ -104,10 +102,8 @@ changeset_revision=changeset_revision, metadata=metadata_dict, includes_datatypes=includes_datatypes ) - flush_needed = True - if flush_needed: - sa_session.add( tool_shed_repository ) - sa_session.flush() + sa_session.add( tool_shed_repository ) + sa_session.flush() def generate_datatypes_metadata( datatypes_config, metadata_dict ): """ Update the received metadata_dict with changes that have been applied @@ -471,12 +467,17 @@ except Exception, e: log.debug( "Exception importing datatypes code file included in installed repository: %s" % str( e ) ) app.datatypes_registry.load_datatypes( root_dir=app.config.root, config=datatypes_config, imported_module=imported_module ) -def load_repository_contents( app, name, description, owner, changeset_revision, repository_clone_url, shed_tool_conf, - tool_path, tool_section, relative_install_dir, current_working_dir, tmp_name ): +def load_repository_contents( app, name, description, owner, changeset_revision, tool_path, repository_clone_url, relative_install_dir, + current_working_dir, tmp_name, tool_section=None, shed_tool_conf=None, new_install=True ): # This method is used by the InstallManager, which does not have access to trans. # Generate the metadata for the installed tool shed repository. It is imperative 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. + # is set because the process for setting metadata uses the repository files on disk. This + # method is called when new tools have been installed (in which case values should be received + # for tool_section and shed_tool_conf, and new_install should be left at it's default value) + # and when updates have been pulled to previously installed repositories (in which case the + # default value None is set for tool_section and shed_tool_conf, and the value of new_install + # is passed as False). metadata_dict = generate_metadata( app.toolbox, relative_install_dir, repository_clone_url ) if 'datatypes_config' in metadata_dict: datatypes_config = os.path.abspath( metadata_dict[ 'datatypes_config' ] ) @@ -497,42 +498,38 @@ repository_tools_tups = handle_missing_index_file( app, tool_path, sample_files, repository_tools_tups ) # Handle tools that use fabric scripts to install dependencies. handle_tool_dependencies( current_working_dir, relative_install_dir, repository_tools_tups ) - # Generate a new entry for the tool config. - elem_list = generate_tool_panel_elem_list( name, - repository_clone_url, - changeset_revision, - repository_tools_tups, - tool_section=tool_section, - owner=owner ) - if tool_section: - for section_elem in elem_list: - # Load the section into the tool panel. - app.toolbox.load_section_tag_set( section_elem, app.toolbox.tool_panel, tool_path ) - else: - # Load the tools into the tool panel outside of any sections. - for tool_elem in elem_list: - guid = tool_elem.get( 'guid' ) - app.toolbox.load_tool_tag_set( tool_elem, app.toolbox.tool_panel, tool_path=tool_path, guid=guid ) + if new_install: + # Generate a new entry for the tool config. + elem_list = generate_tool_panel_elem_list( name, + repository_clone_url, + changeset_revision, + repository_tools_tups, + tool_section=tool_section, + owner=owner ) + if tool_section: + for section_elem in elem_list: + # Load the section into the tool panel. + app.toolbox.load_section_tag_set( section_elem, app.toolbox.tool_panel, tool_path ) + else: + # Load the tools into the tool panel outside of any sections. + for tool_elem in elem_list: + guid = tool_elem.get( 'guid' ) + app.toolbox.load_tool_tag_set( tool_elem, app.toolbox.tool_panel, tool_path=tool_path, guid=guid ) + for elem_entry in elem_list: + # Append the new entry (either section or list of tools) to the shed_tool_config file. + add_shed_tool_conf_entry( app, shed_tool_conf, elem_entry ) + if app.toolbox_search.enabled: + # If search support for tools is enabled, index the new installed tools. + app.toolbox_search = ToolBoxSearch( app.toolbox ) # Remove the temporary file try: os.unlink( tmp_name ) except: pass - for elem_entry in elem_list: - # Append the new entry (either section or list of tools) to the shed_tool_config file. - add_shed_tool_conf_entry( app, shed_tool_conf, elem_entry ) - if app.toolbox_search.enabled: - # If search support for tools is enabled, index the new installed tools. - app.toolbox_search = ToolBoxSearch( app.toolbox ) # 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. - log.debug( "Adding new row to tool_shed_repository table for repository '%s'" % name ) - create_or_undelete_tool_shed_repository( app, - name, - description, - changeset_revision, - repository_clone_url, - metadata_dict ) + log.debug( "Adding new row (or updating an existing row) for repository '%s' in the tool_shed_repository table." % name ) + create_or_update_tool_shed_repository( app, name, description, changeset_revision, repository_clone_url, metadata_dict ) return metadata_dict def pretty_print_xml( elem, level=0 ): pad = ' ' diff -r 13ba6909faae12b0a7efcdc76e0797c5e7903929 -r fdcdc0115a123aa40bc46e69df769f171837534e lib/galaxy/web/controllers/admin_toolshed.py --- a/lib/galaxy/web/controllers/admin_toolshed.py +++ b/lib/galaxy/web/controllers/admin_toolshed.py @@ -237,18 +237,19 @@ returncode, tmp_name = update_repository( current_working_dir, relative_install_dir, changeset_revision ) if returncode == 0: owner = get_repository_owner( clean_repository_clone_url( repository_clone_url ) ) - metadata_dict = load_repository_contents( trans.app, - name, - description, - owner, - changeset_revision, - repository_clone_url, - shed_tool_conf, - tool_path, - tool_section, - relative_install_dir, - current_working_dir, - tmp_name ) + metadata_dict = load_repository_contents( app=trans.app, + name=name, + description=description, + owner=owner, + changeset_revision=changeset_revision, + tool_path=tool_path, + repository_clone_url=repository_clone_url, + relative_install_dir=relative_install_dir, + current_working_dir=current_working_dir, + tmp_name=tmp_name, + tool_section=tool_section, + shed_tool_conf=shed_tool_conf, + new_install=True ) installed_repository_names.append( name ) else: tmp_stderr = open( tmp_name, 'rb' ) @@ -302,7 +303,7 @@ status = params.get( 'status', 'done' ) repository = get_repository( trans, kwd[ 'id' ] ) description = util.restore_text( params.get( 'description', repository.description ) ) - relative_install_dir = self.__get_relative_install_dir( trans, repository ) + tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository ) repo_files_dir = os.path.abspath( os.path.join( relative_install_dir, repository.name ) ) if params.get( 'edit_repository_button', False ): if description != repository.description: @@ -351,13 +352,28 @@ message = "The cloned tool shed repository named '%s' is current (there are no updates available)." % name else: current_working_dir = os.getcwd() - relative_install_dir = self.__get_relative_install_dir( trans, repository ) + tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository ) if relative_install_dir: repo_files_dir = os.path.join( relative_install_dir, name ) returncode, tmp_name = pull_repository( current_working_dir, repo_files_dir, name ) if returncode == 0: returncode, tmp_name = update_repository( current_working_dir, repo_files_dir, latest_changeset_revision ) if returncode == 0: + # Update the repository metadata. + repository_clone_url = os.path.join( tool_shed_url, 'repos', owner, name ) + metadata_dict = load_repository_contents( app=trans.app, + name=name, + description=repository.description, + owner=owner, + changeset_revision=changeset_revision, + tool_path=tool_path, + repository_clone_url=repository_clone_url, + relative_install_dir=relative_install_dir, + current_working_dir=current_working_dir, + tmp_name=tmp_name, + tool_section=None, + shed_tool_conf=None, + new_install=False ) # Update the repository changeset_revision in the database. repository.changeset_revision = latest_changeset_revision repository.update_available = False @@ -408,8 +424,9 @@ metadata=metadata, message=message, status=status ) - def __get_relative_install_dir( self, trans, repository ): - # Get the directory where the repository is install. + def __get_tool_path_and_relative_install_dir( self, trans, repository ): + # Return both the tool_path configured in the relative shed_tool_conf and + # the relative path to the directory where the repository is installed. tool_shed = clean_tool_shed_url( repository.tool_shed ) partial_install_dir = '%s/repos/%s/%s/%s' % ( tool_shed, repository.owner, repository.name, repository.installed_changeset_revision ) # Get the relative tool installation paths from each of the shed tool configs. @@ -420,7 +437,7 @@ relative_install_dir = os.path.join( tool_path, partial_install_dir ) if os.path.isdir( relative_install_dir ): break - return relative_install_dir + return tool_path, relative_install_dir def __generate_tool_path( self, repository_clone_url, changeset_revision ): """ Generate a tool path that guarantees repositories with the same name will always be installed 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.