3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e950fc8b720a/ Changeset: e950fc8b720a User: jmchilton Date: 2014-01-15 21:42:24 Summary: Bug fix related to tool dataset collection of HDA children. If the parent dataset is deleted don't allow it child to be selected as the initial value for a param when generating state - it won't work anyway because these don't appear in the final selection box. Affected #: 1 file diff -r 9fe1a6fc375b3fad14dac271ed8f85e02fc6ef6d -r e950fc8b720ad9db8b27c4599ab947ebfb0bcb7e lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1719,7 +1719,7 @@ most_recent_dataset.append(data) # Also collect children via association object dataset_collector( data.children ) - dataset_collector( history.datasets ) + dataset_collector( history.active_datasets ) most_recent_dataset.reverse() if already_used is not None: for val in most_recent_dataset: https://bitbucket.org/galaxy/galaxy-central/commits/0951e07b7486/ Changeset: 0951e07b7486 User: jmchilton Date: 2014-01-15 21:42:24 Summary: Optimize database access during tool rendering. Prefetch all children, permission, and role data that will be needed for calculation in first database call. Number of database calls no longer proporational to size of history. 17x speed up on my laptop with ~400 history items - typical tool form update times drop from over 5 seconds to under a third of a second. That is with sqlite database on local SSD, I imagine with remote databases and/or larger histories this speed improvement could be even more significant. Affected #: 2 files diff -r e950fc8b720ad9db8b27c4599ab947ebfb0bcb7e -r 0951e07b74866c1539a7df46b051bb431f67acf4 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -35,7 +35,9 @@ PasswordField, SelectField, TextArea, TextField, WorkflowField, WorkflowMappingField) from sqlalchemy.orm import object_session +from sqlalchemy.orm import joinedload from sqlalchemy.sql.expression import func +from sqlalchemy import not_ log = logging.getLogger( __name__ ) @@ -898,6 +900,22 @@ rval = galaxy.datatypes.data.nice_size( rval ) return rval + @property + def active_datasets_children_and_roles( self ): + if not hasattr(self, '_active_datasets_children_and_roles'): + db_session = object_session( self ) + query = db_session.query( HistoryDatasetAssociation ).filter( HistoryDatasetAssociation.table.c.history_id == self.id ). \ + filter( not_( HistoryDatasetAssociation.deleted ) ). \ + order_by( HistoryDatasetAssociation.table.c.hid.asc() ). \ + options( + joinedload("children"), + joinedload("dataset"), + joinedload("dataset.actions"), + joinedload("dataset.actions.role"), + ) + self._active_datasets_children_and_roles = query.all() + return self._active_datasets_children_and_roles + def contents_iter( self, **kwds ): """ Fetch filtered list of contents of history. diff -r e950fc8b720ad9db8b27c4599ab947ebfb0bcb7e -r 0951e07b74866c1539a7df46b051bb431f67acf4 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1655,7 +1655,7 @@ field.add_option( "%s: (as %s) %s" % ( hid, target_ext, hda_name ), hda.id, selected ) # Also collect children via association object dataset_collector( hda.children, hid ) - dataset_collector( history.active_datasets, None ) + dataset_collector( history.active_datasets_children_and_roles, None ) some_data = bool( field.options ) if some_data: if value is None or len( field.options ) == 1: @@ -1719,7 +1719,7 @@ most_recent_dataset.append(data) # Also collect children via association object dataset_collector( data.children ) - dataset_collector( history.active_datasets ) + dataset_collector( history.active_datasets_children_and_roles ) most_recent_dataset.reverse() if already_used is not None: for val in most_recent_dataset: https://bitbucket.org/galaxy/galaxy-central/commits/581b149358aa/ Changeset: 581b149358aa User: jmchilton Date: 2014-01-24 05:40:41 Summary: Merged in jmchilton/galaxy-central-fork-1 (pull request #297) Optimize database access during tool rendering. Affected #: 2 files diff -r ce250b678c13cabd72f13e3ed118976b7fcb4fe8 -r 581b149358aa655dd7c25a460f1ec48093268e93 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -35,7 +35,9 @@ PasswordField, SelectField, TextArea, TextField, WorkflowField, WorkflowMappingField) from sqlalchemy.orm import object_session +from sqlalchemy.orm import joinedload from sqlalchemy.sql.expression import func +from sqlalchemy import not_ log = logging.getLogger( __name__ ) @@ -897,6 +899,22 @@ rval = galaxy.datatypes.data.nice_size( rval ) return rval + @property + def active_datasets_children_and_roles( self ): + if not hasattr(self, '_active_datasets_children_and_roles'): + db_session = object_session( self ) + query = db_session.query( HistoryDatasetAssociation ).filter( HistoryDatasetAssociation.table.c.history_id == self.id ). \ + filter( not_( HistoryDatasetAssociation.deleted ) ). \ + order_by( HistoryDatasetAssociation.table.c.hid.asc() ). \ + options( + joinedload("children"), + joinedload("dataset"), + joinedload("dataset.actions"), + joinedload("dataset.actions.role"), + ) + self._active_datasets_children_and_roles = query.all() + return self._active_datasets_children_and_roles + def contents_iter( self, **kwds ): """ Fetch filtered list of contents of history. diff -r ce250b678c13cabd72f13e3ed118976b7fcb4fe8 -r 581b149358aa655dd7c25a460f1ec48093268e93 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1653,7 +1653,7 @@ field.add_option( "%s: (as %s) %s" % ( hid, target_ext, hda_name ), hda.id, selected ) # Also collect children via association object dataset_collector( hda.children, hid ) - dataset_collector( history.active_datasets, None ) + dataset_collector( history.active_datasets_children_and_roles, None ) some_data = bool( field.options ) if some_data: if value is None or len( field.options ) == 1: @@ -1709,7 +1709,7 @@ most_recent_dataset.append(data) # Also collect children via association object dataset_collector( data.children ) - dataset_collector( history.datasets ) + dataset_collector( history.active_datasets_children_and_roles ) most_recent_dataset.reverse() if already_used is not None: for val in most_recent_dataset: 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.