Enhance tool shed repository installation process to automatically reset the attributes of a previously installed repository (that is no longer in the installed state) so that it can be installed. This streamlines the installation process when installing multiple repositories so that one or more of them do not need to be uninstalled.

This commit is contained in:
Greg Von Kuster
2013-06-21 14:03:03 -04:00
parent bc27b54627
commit 5bb32be8f4
3 changed files with 48 additions and 27 deletions
@@ -147,41 +147,48 @@ def create_repository_dependency_objects( trans, tool_path, tool_shed_url, repo_
dist_to_shed = installed_tool_shed_repository.dist_to_shed
elif installed_tool_shed_repository.status in [ trans.model.ToolShedRepository.installation_status.DEACTIVATED ]:
# The current tool shed repository is deactivated, so updating it's database record is not necessary - just activate it.
log.debug( "Reactivating deactivated tool_shed_repository '%s'." % str( installed_tool_shed_repository.name ) )
common_install_util.activate_repository( trans, installed_tool_shed_repository )
can_update = False
else:
# The tool shed repository currently being processed is already installed or is in the process of being installed, so it's record
# in the database cannot be updated.
if installed_tool_shed_repository.status in [ trans.model.ToolShedRepository.installation_status.INSTALLED ]:
log.debug( "Skipping installation of tool_shed_repository '%s' because it is already installed." % \
str( installed_tool_shed_repository.name ) )
else:
log.debug( "Skipping installation of tool_shed_repository '%s' because it's installation status is '%s'." % \
( str( installed_tool_shed_repository.name ), str( installed_tool_shed_repository.status ) ) )
can_update = False
else:
# This block will be reached only if reinstalling is True, install_repository_dependencies is False and is_in_repo_info_dicts is False.
# The tool shed repository currently being processed must be a repository dependency that the user elected to not install, so it's
# record in the database cannot be updated.
debug_msg = "Skipping installation of tool_shed_repository '%s' because it is likely a " % str( installed_tool_shed_repository.name )
debug_msg += "repository dependency that was elected to not be installed."
log.debug( debug_msg )
can_update = False
else:
# This block will be reached only if reinstalling is False and install_repository_dependencies is False. This implies that the tool shed
# repository currently being processed has already been installed.
if len( all_repo_info_dicts ) == 1:
# If only a single repository is being installed, return an informative message to the user.
message += "Revision <b>%s</b> of tool shed repository <b>%s</b> owned by <b>%s</b> " % ( changeset_revision, name, repository_owner )
if installed_changeset_revision != changeset_revision:
message += "was previously installed using changeset revision <b>%s</b>. " % installed_changeset_revision
else:
message += "was previously installed. "
if installed_tool_shed_repository.uninstalled:
message += "The repository has been uninstalled, however, so reinstall the original repository instead of installing it again. "
elif installed_tool_shed_repository.deleted:
message += "The repository has been deactivated, however, so activate the original repository instead of installing it again. "
if installed_changeset_revision != changeset_revision:
message += "You can get the latest updates for the repository using the <b>Get updates</b> option from the repository's "
message += "<b>Repository Actions</b> pop-up menu. "
created_or_updated_tool_shed_repositories.append( installed_tool_shed_repository )
tool_panel_section_keys.append( tool_panel_section_key )
return created_or_updated_tool_shed_repositories, tool_panel_section_keys, all_repo_info_dicts, filtered_repo_info_dicts, message
else:
# We're in the process of installing multiple tool shed repositories into Galaxy. Since the repository currently being processed
# has already been installed, skip it and process the next repository in the list.
if installed_tool_shed_repository.status in [ trans.model.ToolShedRepository.installation_status.INSTALLED ]:
# Since the repository currently being processed is already in the INSTALLED state, skip it and process the next repository in the
# list if there is one.
log.debug( "Skipping installation of tool_shed_repository '%s' because it's installation status is '%s'." % \
( str( installed_tool_shed_repository.name ), str( installed_tool_shed_repository.status ) ) )
can_update = False
else:
# The repository currently being processed is in some state other than INSTALLED, so reset it for installation.
debug_msg = "Resetting tool_shed_repository '%s' for installation.\n" % str( installed_tool_shed_repository.name )
debug_msg += "The current state of the tool_shed_repository is:\n"
debug_msg += "deleted: %s\n" % str( installed_tool_shed_repository.deleted )
debug_msg += "update_available: %s\n" % str( installed_tool_shed_repository.update_available )
debug_msg += "uninstalled: %s\n" % str( installed_tool_shed_repository.uninstalled )
debug_msg += "status: %s\n" % str( installed_tool_shed_repository.status )
debug_msg += "error_message: %s\n" % str( installed_tool_shed_repository.error_message )
log.debug( debug_msg )
suc.reset_previously_installed_repository( trans, installed_tool_shed_repository )
can_update = True
else:
# A tool shed repository is being installed into a Galaxy instance for the first time, or we're attempting to install it or reinstall it resulted
# in an error. In the latter case, the repository record in the database has no metadata and it's status has been set to 'New'. In either case,
+13
View File
@@ -1182,6 +1182,19 @@ def repository_was_previously_installed( trans, tool_shed_url, repository_name,
return tool_shed_repository, previous_changeset_revision
return None, None
def reset_previously_installed_repository( trans, repository ):
"""
Reset the atrributes of a tool_shed_repository that was previsouly installed. The repository will be in some state other than with a
status of INSTALLED, so all atributes will be set to the default NEW state. This will enable the repository to be freshly installed.
"""
repository.deleted = False
repository.update_available = False
repository.uninstalled = False
repository.status = trans.model.ToolShedRepository.installation_status.NEW
repository.error_message = None
trans.sa_session.add( repository )
trans.sa_session.flush()
def reversed_lower_upper_bounded_changelog( repo, excluded_lower_bounds_changeset_revision, included_upper_bounds_changeset_revision ):
"""
Return a reversed list of changesets in the repository changelog after the excluded_lower_bounds_changeset_revision, but up to and
@@ -106,20 +106,21 @@ class BasicToolShedFeatures( ShedTwillTestCase ):
self.verify_tool_metadata_for_installed_repository( installed_repository )
def test_0030_install_filtering_repository_again( self ):
'''Attempt to install the already installed filtering repository, and check for the resulting error message.'''
'''Attempt to install the already installed filtering repository.'''
installed_repository = test_db_util.get_installed_repository_by_name_owner( 'filtering_0000', common.test_user_1_name )
post_submit_strings_displayed = [ installed_repository.name,
installed_repository.owner,
installed_repository.installed_changeset_revision,
'was previously installed',
'to manage the repository' ]
# The page displayed after installation is the ajaxian "Montior installing tool shed repositories" page. Since the filter
# repository was already installed, nothing will be in the process of being installed, so the grid will display 'No Items'.
post_submit_strings_displayed = [ 'No Items' ]
self.install_repository( 'filtering_0000',
common.test_user_1_name,
'Test 0000 Basic Repository Features 1',
post_submit_strings_displayed=post_submit_strings_displayed )
strings_displayed = [ 'filtering_0000',
'user1',
"Galaxy's filtering tool",
'user1',
self.url.replace( 'http://', '' ),
installed_repository.installed_changeset_revision ]
self.display_installed_repository_manage_page( installed_repository, strings_displayed=strings_displayed )
self.display_galaxy_browse_repositories_page( strings_displayed=strings_displayed )
def test_0035_verify_installed_repository_metadata( self ):