commit/galaxy-central: greg: Handle multiple relationships in the tool lineage chain at the time of repository installation.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/f465995c107e/ changeset: f465995c107e user: greg date: 2012-02-09 17:43:03 summary: Handle multiple relationships in the tool lineage chain at the time of repository installation. affected #: 4 files diff -r 981551e6caca70574a3ccf4f633fb4302e855dad -r f465995c107ebb5e932404c07bb8e7f878214cc6 lib/galaxy/tool_shed/install_manager.py --- a/lib/galaxy/tool_shed/install_manager.py +++ b/lib/galaxy/tool_shed/install_manager.py @@ -106,10 +106,11 @@ 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' ] diff -r 981551e6caca70574a3ccf4f633fb4302e855dad -r f465995c107ebb5e932404c07bb8e7f878214cc6 lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -477,33 +477,35 @@ 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 diff -r 981551e6caca70574a3ccf4f633fb4302e855dad -r f465995c107ebb5e932404c07bb8e7f878214cc6 lib/galaxy/web/controllers/admin_toolshed.py --- a/lib/galaxy/web/controllers/admin_toolshed.py +++ b/lib/galaxy/web/controllers/admin_toolshed.py @@ -242,8 +242,8 @@ 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 @@ 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: diff -r 981551e6caca70574a3ccf4f633fb4302e855dad -r f465995c107ebb5e932404c07bb8e7f878214cc6 lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -774,13 +774,27 @@ 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 ): 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.
participants (1)
-
Bitbucket