Handle multiple relationships in the tool lineage chain at the time of repository installation.

This commit is contained in:
Greg Von Kuster
2012-02-09 11:43:03 -05:00
parent 5cafc0b7d3
commit ab648e32d2
4 changed files with 49 additions and 32 deletions
+3 -2
View File
@@ -106,10 +106,11 @@ class InstallManager( object ):
text = response.read()
response.close()
if text:
tool_versions_dict = from_json_string( text )
handle_tool_versions( self.app, tool_versions_dict, tool_shed_repository )
tool_version_dicts = from_json_string( text )
handle_tool_versions( self.app, tool_version_dicts, tool_shed_repository )
else:
# Set the tool versions since they seem to be missing for this repository in the tool shed.
# CRITICAL NOTE: These default settings may not properly handle all parent/child associations.
for tool_dict in metadata_dict[ 'tools' ]:
flush_needed = False
tool_id = tool_dict[ 'guid' ]
+26 -24
View File
@@ -477,33 +477,35 @@ def handle_tool_dependencies( current_working_dir, repo_files_dir, repository_to
error = tmp_stderr.read()
tmp_stderr.close()
log.debug( 'Problem installing dependencies for tool "%s"\n%s' % ( repository_tool.name, error ) )
def handle_tool_versions( app, tool_versions, tool_shed_repository ):
def handle_tool_versions( app, tool_version_dicts, tool_shed_repository ):
"""
This method is used by the InstallManager, which does not have access to trans. Using
the tool_versions dictionary retrieved from the tool shed, create the parent / child pairs
of tool versions. The tool_versions dictionary contains { tool id : parent tool id } pairs.
This method is used by the InstallManager, which does not have access to trans. Using the list
of tool_version_dicts retrieved from the tool shed (one per chngeset revison up to the currently
installed changeset revision), create the parent / child pairs of tool versions. Each dictionary
contains { tool id : parent tool id } pairs.
"""
sa_session = app.model.context.current
for tool_guid, parent_id in tool_versions.items():
tool_version_using_tool_guid = get_tool_version( app, tool_guid )
tool_version_using_parent_id = get_tool_version( app, parent_id )
if not tool_version_using_tool_guid:
tool_version_using_tool_guid = app.model.ToolVersion( tool_id=tool_guid, tool_shed_repository=tool_shed_repository )
sa_session.add( tool_version_using_tool_guid )
sa_session.flush()
if not tool_version_using_parent_id:
tool_version_using_parent_id = app.model.ToolVersion( tool_id=parent_id, tool_shed_repository=tool_shed_repository )
sa_session.add( tool_version_using_parent_id )
sa_session.flush()
# Associate the two versions as parent / child.
tool_version_association = get_tool_version_association( app,
tool_version_using_parent_id,
tool_version_using_tool_guid )
if not tool_version_association:
tool_version_association = app.model.ToolVersionAssociation( tool_id=tool_version_using_tool_guid.id,
parent_id=tool_version_using_parent_id.id )
sa_session.add( tool_version_association )
sa_session.flush()
for tool_version_dict in tool_version_dicts:
for tool_guid, parent_id in tool_version_dict.items():
tool_version_using_tool_guid = get_tool_version( app, tool_guid )
tool_version_using_parent_id = get_tool_version( app, parent_id )
if not tool_version_using_tool_guid:
tool_version_using_tool_guid = app.model.ToolVersion( tool_id=tool_guid, tool_shed_repository=tool_shed_repository )
sa_session.add( tool_version_using_tool_guid )
sa_session.flush()
if not tool_version_using_parent_id:
tool_version_using_parent_id = app.model.ToolVersion( tool_id=parent_id, tool_shed_repository=tool_shed_repository )
sa_session.add( tool_version_using_parent_id )
sa_session.flush()
tool_version_association = get_tool_version_association( app,
tool_version_using_parent_id,
tool_version_using_tool_guid )
if not tool_version_association:
# Associate the two versions as parent / child.
tool_version_association = app.model.ToolVersionAssociation( tool_id=tool_version_using_tool_guid.id,
parent_id=tool_version_using_parent_id.id )
sa_session.add( tool_version_association )
sa_session.flush()
def load_datatype_items( app, repository, relative_install_dir, deactivate=False ):
# Load proprietary datatypes.
metadata = repository.metadata
+4 -4
View File
@@ -242,8 +242,8 @@ class AdminToolshed( AdminGalaxy ):
text = response.read()
response.close()
if text:
tool_versions_dict = from_json_string( text )
handle_tool_versions( trans.app, tool_versions_dict, tool_shed_repository )
tool_version_dicts = from_json_string( text )
handle_tool_versions( trans.app, tool_version_dicts, tool_shed_repository )
else:
message += "Version information for the tools included in the <b>%s</b> repository is missing. " % name
message += "Reset all of this repository's metadata in the tool shed, then set the installed tool versions "
@@ -309,8 +309,8 @@ class AdminToolshed( AdminGalaxy ):
text = response.read()
response.close()
if text:
tool_versions_dict = from_json_string( text )
handle_tool_versions( trans.app, tool_versions_dict, repository )
tool_version_dicts = from_json_string( text )
handle_tool_versions( trans.app, tool_version_dicts, repository )
message = "Tool versions have been set for all included tools."
status = 'done'
else:
@@ -774,13 +774,27 @@ class RepositoryController( BaseUIController, ItemRatings ):
return trans.response.send_redirect( url )
@web.expose
def get_tool_versions( self, trans, **kwd ):
"""
For each valid /downloadable change set (up to the received changeset_revision) in the
repository's change log, append the change set's tool_versions dictionary to the list
that will be returned.
"""
name = kwd[ 'name' ]
owner = kwd[ 'owner' ]
changeset_revision = kwd[ 'changeset_revision' ]
repository = get_repository_by_name_and_owner( trans, name, owner )
repository_metadata = get_repository_metadata_by_changeset_revision( trans, trans.security.encode_id( repository.id ), changeset_revision )
repo_dir = repository.repo_path
repo = hg.repository( get_configured_ui(), repo_dir )
tool_version_dicts = []
for changeset in repo.changelog:
current_changeset_revision = str( repo.changectx( changeset ) )
repository_metadata = get_repository_metadata_by_changeset_revision( trans, trans.security.encode_id( repository.id ), current_changeset_revision )
if repository_metadata and repository_metadata.tool_versions:
tool_version_dicts.append( repository_metadata.tool_versions )
if current_changeset_revision == changeset_revision:
break
if repository_metadata.tool_versions:
return to_json_string( repository_metadata.tool_versions )
return to_json_string( tool_version_dicts )
return ''
@web.expose
def check_for_updates( self, trans, **kwd ):