commit/galaxy-central: greg: Fixes and code cleanup for the tool shed's install and test framework.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b3171af94dcc/ Changeset: b3171af94dcc User: greg Date: 2014-01-20 17:48:05 Summary: Fixes and code cleanup for the tool shed's install and test framework. Affected #: 4 files diff -r 5404f0c3d733f25ba803bc6e0568fb889b1894c2 -r b3171af94dccffaa6e8a5b9b8bda1fd39479643c lib/galaxy/webapps/tool_shed/api/repository_revisions.py --- a/lib/galaxy/webapps/tool_shed/api/repository_revisions.py +++ b/lib/galaxy/webapps/tool_shed/api/repository_revisions.py @@ -134,7 +134,12 @@ def repository_dependencies( self, trans, id, **kwd ): """ GET /api/repository_revisions/{encoded repository_metadata id}/repository_dependencies - Displays information about a repository_metadata record in the Tool Shed. + + Returns a list of dictionaries that each define a specific downloadable revision of a + repository in the Tool Shed. This method returns dictionaries with more information in + them than other methods in this controller. The information about repository_metdata is + enhanced to include information about the repository (e.g., name, owner, etc) associated + with the repository_metadata record. :param id: the encoded id of the `RepositoryMetadata` object """ @@ -182,14 +187,24 @@ else: changeset_revision = new_changeset_revision repository_dependency_repository_metadata_id = trans.security.encode_id( repository_dependency_repository_metadata.id ) + repository_dependency_metadata_dict = \ + repository_dependency_repository_metadata.to_dict( view='element', + value_mapper=self.__get_value_mapper( trans ) ) repository_dependency_dict = repository_dependency.to_dict( view='element', value_mapper=self.__get_value_mapper( trans ) ) - # We have to add the changeset_revision of of the repository dependency. - repository_dependency_dict[ 'changeset_revision' ] = changeset_revision - repository_dependency_dict[ 'url' ] = web.url_for( controller='repositories', - action='show', - id=repository_dependency_id ) - repository_dependencies_dicts.append( repository_dependency_dict ) + # We need to be careful with the entries in our repository_dependency_dict here since this Tool Shed API + # controller is working with repository_metadata records. The above to_dict() method returns a dictionary + # with an id entry for the repository record. However, all of the other methods in this controller have + # the id entry associated with a repository_metadata record id. To avoid confusion, we'll update the + # repository_dependency_metadata_dict with entries from the repository_dependency_dict without using the + # Python dictionary update() method because we do not want to overwrite existing entries. + for k, v in repository_dependency_dict.items(): + if k not in repository_dependency_metadata_dict: + repository_dependency_metadata_dict[ k ] = v + repository_dependency_metadata_dict[ 'url' ] = web.url_for( controller='repositories', + action='show', + id=repository_dependency_id ) + repository_dependencies_dicts.append( repository_dependency_metadata_dict ) return repository_dependencies_dicts @web.expose_api_anonymous diff -r 5404f0c3d733f25ba803bc6e0568fb889b1894c2 -r b3171af94dccffaa6e8a5b9b8bda1fd39479643c lib/tool_shed/scripts/api/common.py --- a/lib/tool_shed/scripts/api/common.py +++ b/lib/tool_shed/scripts/api/common.py @@ -145,7 +145,7 @@ extended_dict[ 'latest_revision' ] = str( latest_changeset_revision ) return extended_dict, error_message else: - error_message = 'Invalid extended_dict does not contain name or woner entries: %s' % str( extended_dict ) + error_message = 'Invalid extended_dict does not contain name or owner entries: %s' % str( extended_dict ) return None, error_message def json_from_url( url ): diff -r 5404f0c3d733f25ba803bc6e0568fb889b1894c2 -r b3171af94dccffaa6e8a5b9b8bda1fd39479643c lib/tool_shed/util/common_util.py --- a/lib/tool_shed/util/common_util.py +++ b/lib/tool_shed/util/common_util.py @@ -183,11 +183,11 @@ def tool_shed_get( app, tool_shed_url, uri ): """Make contact with the tool shed via the uri provided.""" registry = app.tool_shed_registry - ## urllib2 auto-detects system proxies, when passed a Proxyhandler - ## Refer: http://docs.python.org/2/howto/urllib2.html#proxies + # urllib2 auto-detects system proxies, when passed a Proxyhandler. + # Refer: http://docs.python.org/2/howto/urllib2.html#proxies proxy = urllib2.ProxyHandler() - urlopener = urllib2.build_opener(proxy) - urllib2.install_opener(urlopener) + urlopener = urllib2.build_opener( proxy ) + urllib2.install_opener( urlopener ) password_mgr = registry.password_manager_for_url( tool_shed_url ) if password_mgr is not None: auth_handler = urllib2.HTTPBasicAuthHandler( password_mgr ) diff -r 5404f0c3d733f25ba803bc6e0568fb889b1894c2 -r b3171af94dccffaa6e8a5b9b8bda1fd39479643c test/install_and_test_tool_shed_repositories/base/util.py --- a/test/install_and_test_tool_shed_repositories/base/util.py +++ b/test/install_and_test_tool_shed_repositories/base/util.py @@ -362,24 +362,21 @@ if error_message: log.debug( 'Error getting additional details from the API: %s' % str( error_message ) ) else: - # Don't test deprecated repositories since testing them is necessary only if reproducibility is guaranteed - # and we are not currently guaranteeing reproducibility. - deprecated = asbool( repository_dict.get( 'deprecated', False ) ) - if not deprecated: - # Don't test empty repositories. - changeset_revision = baseline_repository_dict[ 'changeset_revision' ] - if changeset_revision != suc.INITIAL_CHANGELOG_HASH: - # If testing repositories of type tool_dependency_definition, filter accordingly. - if test_framework == TOOL_DEPENDENCY_DEFINITIONS and repository_dict[ 'type' ] != rt_util.TOOL_DEPENDENCY_DEFINITION: - continue - # Merge the dictionary returned from /api/repository_revisions with the detailed repository_dict and - # append it to the list of repository_dicts to install and test. - if latest_revision_only: - latest_revision = repository_dict[ 'latest_revision' ] - if changeset_revision == latest_revision: - repository_dicts.append( dict( repository_dict.items() + baseline_repository_dict.items() ) ) - else: + changeset_revision = baseline_repository_dict[ 'changeset_revision' ] + # We have to test deprecated repositories since other repositories can define them as dependencies, but + # don't test empty repositories. + if changeset_revision != suc.INITIAL_CHANGELOG_HASH: + # If testing repositories of type tool_dependency_definition, filter accordingly. + if test_framework == TOOL_DEPENDENCY_DEFINITIONS and repository_dict[ 'type' ] != rt_util.TOOL_DEPENDENCY_DEFINITION: + continue + # Merge the dictionary returned from /api/repository_revisions with the detailed repository_dict and + # append it to the list of repository_dicts to install and test. + if latest_revision_only: + latest_revision = repository_dict[ 'latest_revision' ] + if changeset_revision == latest_revision: repository_dicts.append( dict( repository_dict.items() + baseline_repository_dict.items() ) ) + else: + repository_dicts.append( dict( repository_dict.items() + baseline_repository_dict.items() ) ) if testing_single_repository_dict: tsr_name = testing_single_repository_dict[ 'name' ] tsr_owner = testing_single_repository_dict[ 'owner' ] @@ -435,7 +432,7 @@ hg_id = '%d:%s' % ( ctx_rev, str( changectx ) ) return hg_id -def get_repository_dependencies_for_changeset_revision( tool_shed_url, encoded_repository_metadata_id ): +def get_repository_dependencies_dicts( tool_shed_url, encoded_repository_metadata_id ): """ Return the list of dictionaries that define all repository dependencies of the repository_metadata record associated with the received encoded_repository_metadata_id via the Tool Shed API. @@ -443,19 +440,6 @@ error_message = '' parts = [ 'api', 'repository_revisions', encoded_repository_metadata_id, 'repository_dependencies' ] api_url = get_api_url( base=tool_shed_url, parts=parts ) - repository_dependency_dicts, error_message = json_from_url( api_url ) - if error_message: - return None, error_message - return repository_dependency_dicts, error_message - -def get_repository_dependencies_dicts( url, encoded_repository_metadata_id ): - """ - Return a list if dictionaries that define the repository dependencies of the repository defined by the - received repository_dict. - """ - error_message = '' - parts = [ 'api', 'repository_revisions', encoded_repository_metadata_id, 'repository_dependencies' ] - api_url = get_api_url( base=url, parts=parts ) repository_dependencies_dicts, error_message = json_from_url( api_url ) if error_message: return None, error_message @@ -644,7 +628,7 @@ return True, reason # Skip this repository if it has a repository dependency that is in the exclude list. repository_dependency_dicts, error_message = \ - get_repository_dependencies_for_changeset_revision( galaxy_tool_shed_url, encoded_repository_metadata_id ) + get_repository_dependencies_dicts( galaxy_tool_shed_url, encoded_repository_metadata_id ) if error_message: log.debug( 'Error getting repository dependencies for revision %s of repository %s owned by %s:' % \ ( changeset_revision, name, owner ) ) @@ -877,7 +861,7 @@ # has been updated within the past 12 hours. The RepositoryMetadata class's to_dict() method # returns the value of time_last_tested in datetime.isoformat(). twenty_hours_ago = ( datetime.utcnow() - timedelta( hours=20 ) ).isoformat() - time_last_tested, error_message = get_time_last_tested( galaxy_tool_shed_url, repository_metadata_id ) + time_last_tested, error_message = get_time_last_tested( galaxy_tool_shed_url, required_repository_metadata_id ) if time_last_tested is not None and time_last_tested < twenty_hours_ago: log.debug( 'The install containers for version %s of repository dependency %s owned by %s have been ' % \ ( changeset_revision, name, owner ) ) 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)
-
commits-noreply@bitbucket.org