1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/8a8dcc0d3668/ changeset: 8a8dcc0d3668 user: jgoecks date: 2012-09-21 17:52:47 summary: Push data sources/converter methods from controller mixin to dataset object. affected #: 4 files diff -r c56a600064a4add89de1c970e99983ae438b8db2 -r 8a8dcc0d36687fcfaaa1ae26e136e76b4a0d7bb0 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1248,6 +1248,56 @@ def get_visualizations( self ): return self.datatype.get_visualizations( self ) + def get_datasources( self, trans ): + """ + Returns datasources for dataset; if datasources are not available + due to indexing, indexing is started. Return value is a dictionary + with entries of type + (<datasource_type> : {<datasource_name>, <indexing_message>}). + """ + track_type, data_sources = self.datatype.get_track_type() + data_sources_dict = {} + msg = None + for source_type, data_source in data_sources.iteritems(): + if source_type == "data_standalone": + # Nothing to do. + msg = None + else: + # Convert. + msg = self.convert_dataset( trans, data_source ) + + # Store msg. + data_sources_dict[ source_type ] = { "name" : data_source, "message": msg } + + return data_sources_dict + + def convert_dataset( self, trans, target_type ): + """ + Converts a dataset to the target_type and returns a message indicating + status of the conversion. None is returned to indicate that dataset + was converted successfully. + """ + + # Get converted dataset; this will start the conversion if necessary. + try: + converted_dataset = self.get_converted_dataset( trans, target_type ) + except NoConverterException: + return messages.NO_CONVERTER + except ConverterDependencyException, dep_error: + return { 'kind': messages.ERROR, 'message': dep_error.value } + + # Check dataset state and return any messages. + msg = None + if converted_dataset and converted_dataset.state == trans.app.model.Dataset.states.ERROR: + job_id = trans.sa_session.query( trans.app.model.JobToOutputDatasetAssociation ) \ + .filter_by( dataset_id=converted_dataset.id ).first().job_id + job = trans.sa_session.query( trans.app.model.Job ).get( job_id ) + msg = { 'kind': messages.ERROR, 'message': job.stderr } + elif not converted_dataset or converted_dataset.state != trans.app.model.Dataset.states.OK: + msg = messages.PENDING + + return msg + class HistoryDatasetAssociation( DatasetInstance ): def __init__( self, hid = None, diff -r c56a600064a4add89de1c970e99983ae438b8db2 -r 8a8dcc0d36687fcfaaa1ae26e136e76b4a0d7bb0 lib/galaxy/web/api/datasets.py --- a/lib/galaxy/web/api/datasets.py +++ b/lib/galaxy/web/api/datasets.py @@ -80,7 +80,7 @@ return msg # Get datasources and check for messages. - data_sources = self._get_datasources( trans, dataset ) + data_sources = dataset.get_datasources( trans ) messages_list = [ data_source_dict[ 'message' ] for data_source_dict in data_sources.values() ] msg = get_highest_priority_msg( messages_list ) if msg: @@ -139,7 +139,7 @@ return msg # Get datasources and check for messages. - data_sources = self._get_datasources( trans, dataset ) + data_sources = dataset.get_datasources( trans ) messages_list = [ data_source_dict[ 'message' ] for data_source_dict in data_sources.values() ] return_message = get_highest_priority_msg( messages_list ) if return_message: diff -r c56a600064a4add89de1c970e99983ae438b8db2 -r 8a8dcc0d36687fcfaaa1ae26e136e76b4a0d7bb0 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -312,33 +312,6 @@ if dataset.state != trans.app.model.Job.states.OK: return messages.PENDING return None - - def convert_dataset( self, trans, dataset, target_type ): - """ - Converts a dataset to the target_type and returns a message indicating - status of the conversion. None is returned to indicate that dataset - was converted successfully. - """ - - # Get converted dataset; this will start the conversion if necessary. - try: - converted_dataset = dataset.get_converted_dataset( trans, target_type ) - except NoConverterException: - return messages.NO_CONVERTER - except ConverterDependencyException, dep_error: - return { 'kind': messages.ERROR, 'message': dep_error.value } - - # Check dataset state and return any messages. - msg = None - if converted_dataset and converted_dataset.state == trans.app.model.Dataset.states.ERROR: - job_id = trans.sa_session.query( trans.app.model.JobToOutputDatasetAssociation ) \ - .filter_by( dataset_id=converted_dataset.id ).first().job_id - job = trans.sa_session.query( trans.app.model.Job ).get( job_id ) - msg = { 'kind': messages.ERROR, 'message': job.stderr } - elif not converted_dataset or converted_dataset.state != trans.app.model.Dataset.states.OK: - msg = messages.PENDING - - return msg class UsesLibraryMixin: @@ -625,29 +598,6 @@ return visualization - def _get_datasources( self, trans, dataset ): - """ - Returns datasources for dataset; if datasources are not available - due to indexing, indexing is started. Return value is a dictionary - with entries of type - (<datasource_type> : {<datasource_name>, <indexing_message>}). - """ - track_type, data_sources = dataset.datatype.get_track_type() - data_sources_dict = {} - msg = None - for source_type, data_source in data_sources.iteritems(): - if source_type == "data_standalone": - # Nothing to do. - msg = None - else: - # Convert. - msg = self.convert_dataset( trans, dataset, data_source ) - - # Store msg. - data_sources_dict[ source_type ] = { "name" : data_source, "message": msg } - - return data_sources_dict - class UsesStoredWorkflowMixin( SharableItemSecurityMixin ): """ Mixin for controllers that use StoredWorkflow objects. """ def get_stored_workflow( self, trans, id, check_ownership=True, check_accessible=False ): diff -r c56a600064a4add89de1c970e99983ae438b8db2 -r 8a8dcc0d36687fcfaaa1ae26e136e76b4a0d7bb0 lib/galaxy/web/controllers/visualization.py --- a/lib/galaxy/web/controllers/visualization.py +++ b/lib/galaxy/web/controllers/visualization.py @@ -755,7 +755,7 @@ for track in tracks: # Get dataset and indexed datatype. dataset = self.get_hda_or_ldda( trans, track[ 'hda_ldda'], track[ 'dataset_id' ] ) - data_sources = self._get_datasources( trans, dataset ) + data_sources = dataset.get_datasources( trans ) data_provider_registry = trans.app.data_provider_registry if 'data_standalone' in data_sources: indexed_type = data_sources['data_standalone']['name'] 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.