commit/galaxy-central: 5 new changesets
5 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/38c8222d9e79/ Changeset: 38c8222d9e79 User: jmchilton Date: 2014-12-25 17:24:23+00:00 Summary: Bugfix: Allow passing key to GET /api/datatypes/mapping. All anonymous API endpoints should also allow authenticated access and just ignore the key. Affected #: 1 file diff -r 179199007ec93cdfa45b200e9a27486035ff2477 -r 38c8222d9e79a237dea9179a63b486447aeb9999 lib/galaxy/webapps/galaxy/api/datatypes.py --- a/lib/galaxy/webapps/galaxy/api/datatypes.py +++ b/lib/galaxy/webapps/galaxy/api/datatypes.py @@ -44,7 +44,7 @@ return { 'error': str( exception ) } @web.expose_api_anonymous - def mapping( self, trans ): + def mapping( self, trans, **kwd ): ''' GET /api/datatypes/mapping Return a dictionary of class to class mappings. https://bitbucket.org/galaxy/galaxy-central/commits/cd529da77278/ Changeset: cd529da77278 User: jmchilton Date: 2014-12-25 17:24:23+00:00 Summary: Suite of API tests for exist datatypes endpoint. Affected #: 1 file diff -r 38c8222d9e79a237dea9179a63b486447aeb9999 -r cd529da7727870e472d18a4ba9037aa554bb9e81 test/api/test_datatypes.py --- /dev/null +++ b/test/api/test_datatypes.py @@ -0,0 +1,51 @@ +from base import api + + +HIDDEN_DURING_UPLOAD_DATATYPE = "fli" + + +class DatatypesApiTestCase( api.ApiTestCase ): + + def test_index( self ): + datatypes = self._index_datatypes() + for common_type in ["tabular", "fasta"]: + assert common_type in datatypes, "%s not in %s" % (common_type, datatypes) + + def test_index_upload_only( self ): + # fli is not displayed in upload - so only show it if upload_only + # is explicitly false. + datatypes = self._index_datatypes( data={ "upload_only": False } ) + assert HIDDEN_DURING_UPLOAD_DATATYPE in datatypes + + datatypes = self._index_datatypes( data={ "upload_only": True } ) + assert HIDDEN_DURING_UPLOAD_DATATYPE not in datatypes + + datatypes = self._index_datatypes( ) + assert HIDDEN_DURING_UPLOAD_DATATYPE not in datatypes + + def test_full_index( self ): + datatypes = self._index_datatypes( data={ "extension_only": False } ) + for datatype in datatypes: + self._assert_has_keys( datatype, "extension", "description", "description_url" ) + assert datatype["extension"] != HIDDEN_DURING_UPLOAD_DATATYPE + + def test_mapping( self ): + response = self._get( "datatypes/mapping" ) + self._assert_status_code_is( response, 200 ) + mapping_dict = response.json() + self._assert_has_keys( mapping_dict, "ext_to_class_name", "class_to_classes" ) + + def test_sniffers( self ): + response = self._get( "datatypes/sniffers" ) + self._assert_status_code_is( response, 200 ) + sniffer_list = response.json() + owl_index = sniffer_list.index( "galaxy.datatypes.xml:Owl" ) + xml_index = sniffer_list.index( "galaxy.datatypes.xml:GenericXml" ) + assert owl_index < xml_index + + def _index_datatypes( self, data={} ): + response = self._get( "datatypes", data=data ) + self._assert_status_code_is( response, 200 ) + datatypes = response.json() + assert isinstance( datatypes, list ) + return datatypes https://bitbucket.org/galaxy/galaxy-central/commits/afc01429c885/ Changeset: afc01429c885 User: jmchilton Date: 2014-12-25 17:24:23+00:00 Summary: Update datatypes API to newer API decoarator/exception handling. Affected #: 1 file diff -r cd529da7727870e472d18a4ba9037aa554bb9e81 -r afc01429c88520099bbbb1715f8412d995d4b92c lib/galaxy/webapps/galaxy/api/datatypes.py --- a/lib/galaxy/webapps/galaxy/api/datatypes.py +++ b/lib/galaxy/webapps/galaxy/api/datatypes.py @@ -2,7 +2,8 @@ API operations allowing clients to determine datatype supported by Galaxy. """ -from galaxy import web +from galaxy.web import _future_expose_api_anonymous as expose_api_anonymous +from galaxy import exceptions from galaxy.web.base.controller import BaseAPIController from galaxy.util import asbool from galaxy.datatypes.data import Data @@ -13,7 +14,7 @@ class DatatypesController( BaseAPIController ): - @web.expose_api_anonymous + @expose_api_anonymous def index( self, trans, **kwd ): """ GET /api/datatypes @@ -38,12 +39,14 @@ dictionary[key] = elem.get(key) rval.append(dictionary) return rval - except Exception, exception: + except Exception as exception: log.error( 'could not get datatypes: %s', str( exception ), exc_info=True ) - trans.response.status = 500 - return { 'error': str( exception ) } + if not isinstance( exception, exceptions.MessageException ): + raise exceptions.InternalServerError( str( exception ) ) + else: + raise - @web.expose_api_anonymous + @expose_api_anonymous def mapping( self, trans, **kwd ): ''' GET /api/datatypes/mapping @@ -69,12 +72,15 @@ visit_bases( types, c ) class_to_classes[ n ] = dict( ( t, True ) for t in types ) return dict( ext_to_class_name=ext_to_class_name, class_to_classes=class_to_classes ) - except Exception, exception: + + except Exception as exception: log.error( 'could not get datatype mapping: %s', str( exception ), exc_info=True ) - trans.response.status = 500 - return { 'error': str( exception ) } + if not isinstance( exception, exceptions.MessageException ): + raise exceptions.InternalServerError( str( exception ) ) + else: + raise - @web.expose_api_anonymous + @expose_api_anonymous def sniffers( self, trans, **kwd ): ''' GET /api/datatypes/sniffers @@ -87,7 +93,9 @@ if datatype is not None: rval.append( datatype ) return rval - except Exception, exception: + except Exception as exception: log.error( 'could not get datatypes: %s', str( exception ), exc_info=True ) - trans.response.status = 500 - return { 'error': str( exception ) } + if not isinstance( exception, exceptions.MessageException ): + raise exceptions.InternalServerError( str( exception ) ) + else: + raise https://bitbucket.org/galaxy/galaxy-central/commits/750775b64cb7/ Changeset: 750775b64cb7 User: jmchilton Date: 2014-12-25 17:24:23+00:00 Summary: Reduce repeated nested object access in galaxy.api.datatypes. Affected #: 1 file diff -r afc01429c88520099bbbb1715f8412d995d4b92c -r 750775b64cb758876745af058550b97ae1c47105 lib/galaxy/webapps/galaxy/api/datatypes.py --- a/lib/galaxy/webapps/galaxy/api/datatypes.py +++ b/lib/galaxy/webapps/galaxy/api/datatypes.py @@ -20,17 +20,18 @@ GET /api/datatypes Return an object containing upload datatypes. """ + datatypes_registry = self._datatypes_registry extension_only = asbool( kwd.get( 'extension_only', True ) ) upload_only = asbool( kwd.get( 'upload_only', True ) ) try: if extension_only: if upload_only: - return trans.app.datatypes_registry.upload_file_formats + return datatypes_registry.upload_file_formats else: - return [ ext for ext in trans.app.datatypes_registry.datatypes_by_extension ] + return [ ext for ext in datatypes_registry.datatypes_by_extension ] else: rval = [] - for elem in trans.app.datatypes_registry.datatype_elems: + for elem in datatypes_registry.datatype_elems: if not asbool(elem.get('display_in_upload')) and upload_only: continue keys = ['extension', 'description', 'description_url'] @@ -55,7 +56,7 @@ try: ext_to_class_name = dict() classes = [] - for k, v in trans.app.datatypes_registry.datatypes_by_extension.iteritems(): + for k, v in self._datatypes_registry.datatypes_by_extension.iteritems(): c = v.__class__ ext_to_class_name[k] = c.__module__ + "." + c.__name__ classes.append( c ) @@ -88,7 +89,7 @@ ''' try: rval = [] - for sniffer_elem in trans.app.datatypes_registry.sniffer_elems: + for sniffer_elem in self._datatypes_registry.sniffer_elems: datatype = sniffer_elem.get( 'type' ) if datatype is not None: rval.append( datatype ) @@ -99,3 +100,7 @@ raise exceptions.InternalServerError( str( exception ) ) else: raise + + @property + def _datatypes_registry( self ): + return self.app.datatypes_registry https://bitbucket.org/galaxy/galaxy-central/commits/0587bc5413d6/ Changeset: 0587bc5413d6 User: jmchilton Date: 2014-12-25 17:24:23+00:00 Summary: Expose datatype converter information via datatype API. With test case. Affected #: 3 files diff -r 750775b64cb758876745af058550b97ae1c47105 -r 0587bc5413d66e85673d7b429bc04d34e47ad4c4 lib/galaxy/webapps/galaxy/api/datatypes.py --- a/lib/galaxy/webapps/galaxy/api/datatypes.py +++ b/lib/galaxy/webapps/galaxy/api/datatypes.py @@ -101,6 +101,19 @@ else: raise + @expose_api_anonymous + def converters( self, trans, **kwd ): + converters = [] + for (source_type, targets) in self._datatypes_registry.datatype_converters.iteritems(): + for target_type in targets: + converters.append( { + 'source': source_type, + 'target': target_type, + 'tool_id': targets[ target_type ].id, + } ) + + return converters + @property def _datatypes_registry( self ): return self.app.datatypes_registry diff -r 750775b64cb758876745af058550b97ae1c47105 -r 0587bc5413d66e85673d7b429bc04d34e47ad4c4 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -198,7 +198,7 @@ webapp.mapper.resource( 'datatype', 'datatypes', path_prefix='/api', - collection={ 'sniffers': 'GET', 'mapping' : 'GET' }, + collection={ 'sniffers': 'GET', 'mapping' : 'GET', 'converters': 'GET' }, parent_resources=dict( member_name='datatype', collection_name='datatypes' ) ) #webapp.mapper.connect( 'run_workflow', '/api/workflow/{workflow_id}/library/{library_id}', controller='workflows', action='run', workflow_id=None, library_id=None, conditions=dict(method=["GET"]) ) webapp.mapper.resource( 'search', 'search', path_prefix='/api' ) diff -r 750775b64cb758876745af058550b97ae1c47105 -r 0587bc5413d66e85673d7b429bc04d34e47ad4c4 test/api/test_datatypes.py --- a/test/api/test_datatypes.py +++ b/test/api/test_datatypes.py @@ -43,6 +43,19 @@ xml_index = sniffer_list.index( "galaxy.datatypes.xml:GenericXml" ) assert owl_index < xml_index + def test_converters( self ): + response = self._get( "datatypes/converters" ) + self._assert_status_code_is( response, 200 ) + converters_list = response.json() + found_fasta_to_tabular = False + + for converter in converters_list: + self._assert_has_key( converter, "source", "target", "tool_id" ) + if converter["source"] == "fasta" and converter["target"] == "tabular": + found_fasta_to_tabular = True + + assert found_fasta_to_tabular + def _index_datatypes( self, data={} ): response = self._get( "datatypes", data=data ) self._assert_status_code_is( response, 200 ) 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