1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b45044f8372a/ Changeset: b45044f8372a User: greg Date: 2014-06-06 15:45:37 Summary: Fix for getting updates to an installed repository that has a dependency on a Tool dependency definition repository that also has available updates. Affected #: 6 files diff -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 -r b45044f8372a282065af34175c465f3f9c1c671e 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 @@ -517,7 +517,7 @@ tmp_clone_url = common_util.url_join( tool_shed_url, 'repos', owner, name ) tmp_repo_info_tuple = ( None, tmp_clone_url, latest_downloadable_revision, None, owner, None, None ) installed_repository, installed_changeset_revision = \ - suc.repository_was_previously_installed( trans, tool_shed_url, name, tmp_repo_info_tuple ) + suc.repository_was_previously_installed( trans, tool_shed_url, name, tmp_repo_info_tuple, from_tip=False ) if installed_repository: current_changeset_revision = str( installed_repository.changeset_revision ) message = 'Revision <b>%s</b> of repository <b>%s</b> owned by <b>%s</b> has already been installed.' % \ @@ -1854,6 +1854,10 @@ name, owner, changeset_revision ) + original_metadata_dict = repository.metadata + original_repository_dependencies_dict = original_metadata_dict.get( 'repository_dependencies', {} ) + original_repository_dependencies = original_repository_dependencies_dict.get( 'repository_dependencies', [] ) + original_tool_dependencies_dict = original_metadata_dict.get( 'tool_dependencies', {} ) if changeset_revision and latest_changeset_revision and latest_ctx_rev: if changeset_revision == latest_changeset_revision: message = "The installed repository named '%s' is current, there are no updates available. " % name @@ -1910,32 +1914,80 @@ repository, repository_tools_tups ) if 'repository_dependencies' in metadata_dict or 'tool_dependencies' in metadata_dict: - if 'repository_dependencies' in metadata_dict: - # Updates received include newly defined repository dependencies, so allow the user - # the option of installting them. We cannot update the repository with the changes - # until that happens, so we have to send them along. - new_kwd = dict( tool_shed_url=tool_shed_url, - updating_repository_id=trans.security.encode_id( repository.id ), + new_repository_dependencies_dict = metadata_dict.get( 'repository_dependencies', {} ) + new_repository_dependencies = new_repository_dependencies_dict.get( 'repository_dependencies', [] ) + new_tool_dependencies_dict = metadata_dict.get( 'tool_dependencies', {} ) + if new_repository_dependencies: + # [[http://localhost:9009', package_picard_1_56_0', devteam', 910b0b056666', False', False']] + proceed_to_install = False + if new_repository_dependencies == original_repository_dependencies: + for new_repository_tup in new_repository_dependencies: + # Make sure all dependencies are installed. + # TODO: Repository dependencies that are not installed should be displayed to to the user, + # giving them the option to install them or now. This is the same behavior as when initially + # installing and when re-installing. + new_tool_shed, new_name, new_owner, new_changeset_revision, new_pir, new_oicct = \ + common_util.parse_repository_dependency_tuple( new_repository_tup ) + # Mock up a repo_info_tupe that has the information needed to see if the repository dependency + # was previously installed. + repo_info_tuple = ( '', new_tool_shed, new_changeset_revision, '', new_owner, [], [] ) + # Since the value of new_changeset_revision came from a repository dependency + # definition, it may occur earlier in the Tool Shed's repository changelog than + # the Galaxy tool_shed_repository.installed_changeset_revision record value, so + # we set from_tip to True to make sure we get the entire set of changeset revisions + # from the Tool Shed. + new_repository_db_record, installed_changeset_revision = \ + suc.repository_was_previously_installed( trans, + tool_shed_url, + new_name, + repo_info_tuple, + from_tip=True ) + if new_repository_db_record: + if new_repository_db_record.status in [ trans.install_model.ToolShedRepository.installation_status.ERROR, + trans.install_model.ToolShedRepository.installation_status.NEW, + trans.install_model.ToolShedRepository.installation_status.UNINSTALLED ]: + proceed_to_install = True + break + else: + proceed_to_install = True + break + if proceed_to_install: + # Updates received include newly defined repository dependencies, so allow the user + # the option of installting them. We cannot update the repository with the changes + # until that happens, so we have to send them along. + new_kwd = dict( tool_shed_url=tool_shed_url, + updating_repository_id=trans.security.encode_id( repository.id ), + updating_to_ctx_rev=latest_ctx_rev, + updating_to_changeset_revision=latest_changeset_revision, + encoded_updated_metadata=encoding_util.tool_shed_encode( metadata_dict ), + updating=True ) + return self.prepare_for_install( trans, **new_kwd ) + # Updates received did not include any newly defined repository dependencies but did include + # newly defined tool dependencies. If the newly defined tool dependencies are not the same + # as the originally defined tool dependencies, we need to install them. + proceed_to_install = False + for new_key, new_val in new_tool_dependencies_dict.items(): + if new_key not in original_tool_dependencies_dict: + proceed_to_install = True + break + original_val = original_tool_dependencies_dict[ new_key ] + if new_val != original_val: + proceed_to_install = True + break + if proceed_to_install: + encoded_tool_dependencies_dict = encoding_util.tool_shed_encode( metadata_dict.get( 'tool_dependencies', {} ) ) + encoded_relative_install_dir = encoding_util.tool_shed_encode( relative_install_dir ) + new_kwd = dict( updating_repository_id=trans.security.encode_id( repository.id ), updating_to_ctx_rev=latest_ctx_rev, updating_to_changeset_revision=latest_changeset_revision, encoded_updated_metadata=encoding_util.tool_shed_encode( metadata_dict ), - updating=True ) - return self.prepare_for_install( trans, **new_kwd ) - # Updates received did not include any newly defined repository dependencies but did include - # newly defined tool dependencies. - encoded_tool_dependencies_dict = encoding_util.tool_shed_encode( metadata_dict.get( 'tool_dependencies', {} ) ) - encoded_relative_install_dir = encoding_util.tool_shed_encode( relative_install_dir ) - new_kwd = dict( updating_repository_id=trans.security.encode_id( repository.id ), - updating_to_ctx_rev=latest_ctx_rev, - updating_to_changeset_revision=latest_changeset_revision, - encoded_updated_metadata=encoding_util.tool_shed_encode( metadata_dict ), - encoded_relative_install_dir=encoded_relative_install_dir, - encoded_tool_dependencies_dict=encoded_tool_dependencies_dict, - message=message, - status = status ) - return self.install_tool_dependencies_with_update( trans, **new_kwd ) + encoded_relative_install_dir=encoded_relative_install_dir, + encoded_tool_dependencies_dict=encoded_tool_dependencies_dict, + message=message, + status = status ) + return self.install_tool_dependencies_with_update( trans, **new_kwd ) # Updates received did not include any newly defined repository dependencies or newly defined - # tool dependencies. + # tool dependencies that need to be installed. repository = repository_util.update_repository_record( trans, repository=repository, updated_metadata_dict=metadata_dict, diff -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 -r b45044f8372a282065af34175c465f3f9c1c671e lib/galaxy/webapps/tool_shed/controllers/repository.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository.py @@ -2594,31 +2594,44 @@ status=status ) @web.expose - def previous_changeset_revisions( self, trans, **kwd ): + def previous_changeset_revisions( self, trans, from_tip=False, **kwd ): """ - Handle a request from a local Galaxy instance. This method will handle the case where the repository was previously installed using an - older changeset_revsion, but later the repository was updated in the tool shed and the Galaxy admin is trying to install the latest - changeset revision of the same repository instead of updating the one that was previously installed. + Handle a request from a local Galaxy instance. This method will handle two scenarios: (1) the + repository was previously installed using an older changeset_revsion, but later the repository + was updated in the tool shed and the Galaxy admin is trying to install the latest changeset + revision of the same repository instead of updating the one that was previously installed. (2) + the admin is attempting to get updates for an installed repository that has a repository dependency + and both the repository and its dependency have available updates. In this case, the from_tip + parameter will be True because the repository dependency definition may define a changeset hash + for the dependency that is newer than the installed changeset revision of the dependency (this is + due to the behavior of "Tool dependency definition" repositories, whose metadata is always the tip), + so the complete list of changset hashes in the changelog must be returned. """ name = kwd.get( 'name', None ) owner = kwd.get( 'owner', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) - repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) - repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) - # Get the lower bound changeset revision. - lower_bound_changeset_revision = metadata_util.get_previous_metadata_changeset_revision( repository, - repo, - changeset_revision, - downloadable=True ) - # Build the list of changeset revision hashes. - changeset_hashes = [] - for changeset in hg_util.reversed_lower_upper_bounded_changelog( repo, - lower_bound_changeset_revision, - changeset_revision ): - changeset_hashes.append( str( repo.changectx( changeset ) ) ) - if changeset_hashes: - changeset_hashes_str = ','.join( changeset_hashes ) - return changeset_hashes_str + if name is not None and owner is not None: + repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) + from_tip = util.string_as_bool( from_tip ) + if from_tip: + changeset_revision = repository.tip( trans.app ) + else: + changeset_revision = kwd.get( 'changeset_revision', None ) + if changeset_revision is not None: + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) + # Get the lower bound changeset revision. + lower_bound_changeset_revision = metadata_util.get_previous_metadata_changeset_revision( repository, + repo, + changeset_revision, + downloadable=True ) + # Build the list of changeset revision hashes. + changeset_hashes = [] + for changeset in hg_util.reversed_lower_upper_bounded_changelog( repo, + lower_bound_changeset_revision, + changeset_revision ): + changeset_hashes.append( str( repo.changectx( changeset ) ) ) + if changeset_hashes: + changeset_hashes_str = ','.join( changeset_hashes ) + return changeset_hashes_str return '' @web.expose diff -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 -r b45044f8372a282065af34175c465f3f9c1c671e lib/tool_shed/util/common_install_util.py --- a/lib/tool_shed/util/common_install_util.py +++ b/lib/tool_shed/util/common_install_util.py @@ -264,7 +264,8 @@ repository, installed_changeset_revision = suc.repository_was_previously_installed( trans, tool_shed, name, - tmp_repo_info_tuple ) + tmp_repo_info_tuple, + from_tip=False ) if repository: new_rd_tup = [ tool_shed, name, diff -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 -r b45044f8372a282065af34175c465f3f9c1c671e lib/tool_shed/util/repository_dependency_util.py --- a/lib/tool_shed/util/repository_dependency_util.py +++ b/lib/tool_shed/util/repository_dependency_util.py @@ -75,6 +75,10 @@ # Make sure required_repository is in the repository_dependency table. repository_dependency = get_repository_dependency_by_repository_id( trans, required_repository.id ) if not repository_dependency: + log.debug( 'Creating new repository_dependency record for installed revision %s of repository: %s owned by %s.' % \ + ( str( required_repository.installed_changeset_revision ), + str( required_repository.name ), + str( required_repository.owner ) ) ) repository_dependency = trans.install_model.RepositoryDependency( tool_shed_repository_id=required_repository.id ) trans.install_model.context.add( repository_dependency ) trans.install_model.context.flush() @@ -129,7 +133,7 @@ for repo_info_dict in all_repo_info_dicts: # If the user elected to install repository dependencies, all items in the all_repo_info_dicts list will # be processed. However, if repository dependencies are not to be installed, only those items contained - # in the received repo_info_dicts list will be processed but the the all_repo_info_dicts list will be used + # in the received repo_info_dicts list will be processed but the all_repo_info_dicts list will be used # to create all defined repository dependency relationships. if is_in_repo_info_dicts( repo_info_dict, repo_info_dicts ) or install_repository_dependencies: for name, repo_info_tuple in repo_info_dict.items(): @@ -138,7 +142,7 @@ suc.get_repo_info_tuple_contents( repo_info_tuple ) # See if the repository has an existing record in the database. repository_db_record, installed_changeset_revision = \ - suc.repository_was_previously_installed( trans, tool_shed_url, name, repo_info_tuple ) + suc.repository_was_previously_installed( trans, tool_shed_url, name, repo_info_tuple, from_tip=False ) if repository_db_record: if repository_db_record.status in [ trans.install_model.ToolShedRepository.installation_status.INSTALLED, trans.install_model.ToolShedRepository.installation_status.CLONING, diff -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 -r b45044f8372a282065af34175c465f3f9c1c671e lib/tool_shed/util/shed_util_common.py --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -1352,7 +1352,7 @@ folder_contents.append( node ) return folder_contents -def repository_was_previously_installed( trans, tool_shed_url, repository_name, repo_info_tuple ): +def repository_was_previously_installed( trans, tool_shed_url, repository_name, repo_info_tuple, from_tip=False ): """ Find out if a repository is already installed into Galaxy - there are several scenarios where this is necessary. For example, this method will handle the case where the repository was previously @@ -1375,10 +1375,11 @@ return tool_shed_repository, changeset_revision # Get all previous changeset revisions from the tool shed for the repository back to, but excluding, # the previous valid changeset revision to see if it was previously installed using one of them. - params = '?galaxy_url=%s&name=%s&owner=%s&changeset_revision=%s' % ( url_for( '/', qualified=True ), - str( repository_name ), - str( repository_owner ), - changeset_revision ) + params = '?galaxy_url=%s&name=%s&owner=%s&changeset_revision=%s&from_tip=%s' % ( url_for( '/', qualified=True ), + str( repository_name ), + str( repository_owner ), + changeset_revision, + str( from_tip ) ) url = common_util.url_join( tool_shed_url, 'repository/previous_changeset_revisions%s' % params ) text = common_util.tool_shed_get( trans.app, tool_shed_url, url ) diff -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 -r b45044f8372a282065af34175c465f3f9c1c671e lib/tool_shed/util/tool_dependency_util.py --- a/lib/tool_shed/util/tool_dependency_util.py +++ b/lib/tool_shed/util/tool_dependency_util.py @@ -617,7 +617,7 @@ tool_dependencies=tool_dependencies ) # The required_repository may have been installed with a different changeset revision. required_repository, installed_changeset_revision = \ - suc.repository_was_previously_installed( trans, tool_shed_url, name, repo_info_tuple ) + suc.repository_was_previously_installed( trans, tool_shed_url, name, repo_info_tuple, from_tip=False ) if required_repository: required_repository_installed_tool_dependencies, required_repository_missing_tool_dependencies = \ get_installed_and_missing_tool_dependencies_for_installed_repository( trans, required_repository, tool_dependencies ) 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.