3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e9152659a0be/ Changeset: e9152659a0be Branch: workflow-uuid User: kellrott Date: 2014-08-20 23:10:43 Summary: Refactoring work to add in Workflow UUIDs Affected #: 6 files diff -r b6ae7b6283c30bcb58e87003066102bfa5af5e11 -r e9152659a0be5e932e6eea591bd6c99977983854 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2974,6 +2974,7 @@ tag_str += ":" + tag.user_value tags_str_list.append( tag_str ) rval['tags'] = tags_str_list + rval['latest_workflow_uuid'] = ( lambda uuid: str( uuid ) if self.latest_workflow.uuid else None )( self.latest_workflow.uuid ) return rval @@ -2982,12 +2983,16 @@ dict_collection_visible_keys = ( 'name', 'has_cycles', 'has_errors' ) dict_element_visible_keys = ( 'name', 'has_cycles', 'has_errors' ) - def __init__( self ): + def __init__( self, uuid=None ): self.user = None self.name = None self.has_cycles = None self.has_errors = None self.steps = [] + if uuid is None: + self.uuid = uuid4() + else: + self.uuid = UUID(str(uuid)) def has_outputs_defined(self): """ @@ -2998,6 +3003,11 @@ return True return False + def to_dict( self, view='collection', value_mapper=None): + rval = super( Workflow, self ).to_dict( view=view, value_mapper = value_mapper ) + rval['uuid'] = ( lambda uuid: str( uuid ) if uuid else None )( self.uuid ) + return rval + class WorkflowStep( object ): diff -r b6ae7b6283c30bcb58e87003066102bfa5af5e11 -r e9152659a0be5e932e6eea591bd6c99977983854 lib/galaxy/model/mapping.py --- a/lib/galaxy/model/mapping.py +++ b/lib/galaxy/model/mapping.py @@ -690,7 +690,8 @@ Column( "stored_workflow_id", Integer, ForeignKey( "stored_workflow.id" ), index=True, nullable=False ), Column( "name", TEXT ), Column( "has_cycles", Boolean ), - Column( "has_errors", Boolean ) + Column( "has_errors", Boolean ), + Column( "uuid", UUIDType, nullable=True ) ) model.WorkflowStep.table = Table( "workflow_step", metadata, diff -r b6ae7b6283c30bcb58e87003066102bfa5af5e11 -r e9152659a0be5e932e6eea591bd6c99977983854 lib/galaxy/model/migrate/versions/0121_workflow_uuids.py --- /dev/null +++ b/lib/galaxy/model/migrate/versions/0121_workflow_uuids.py @@ -0,0 +1,55 @@ +""" +Add UUIDs to workflows +""" + +from sqlalchemy import * +from sqlalchemy.orm import * +from migrate import * +from migrate.changeset import * +from galaxy.model.custom_types import UUIDType, TrimmedString + +import logging +log = logging.getLogger( __name__ ) + +metadata = MetaData() + + + +""" +Because both workflow and job requests can be determined +based the a fixed data structure, their IDs are based on +hashing the data structure +""" +workflow_uuid_column = Column( "uuid", UUIDType, nullable=True ) + + +def display_migration_details(): + print "This migration script adds a UUID column to workflows" + +def upgrade(migrate_engine): + print __doc__ + metadata.bind = migrate_engine + metadata.reflect() + + # Add the uuid colum to the workflow table + try: + workflow_table = Table( "workflow", metadata, autoload=True ) + workflow_uuid_column.create( workflow_table ) + assert workflow_uuid_column is workflow_table.c.uuid + except Exception, e: + print str(e) + log.error( "Adding column 'uuid' to workflow table failed: %s" % str( e ) ) + return + +def downgrade(migrate_engine): + metadata.bind = migrate_engine + metadata.reflect() + + # Drop the workflow table's uuid column. + try: + workflow_table = Table( "workflow", metadata, autoload=True ) + workflow_uuid = workflow_table.c.uuid + workflow_uuid.drop() + except Exception, e: + log.debug( "Dropping 'uuid' column from workflow table failed: %s" % ( str( e ) ) ) + diff -r b6ae7b6283c30bcb58e87003066102bfa5af5e11 -r e9152659a0be5e932e6eea591bd6c99977983854 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -1791,6 +1791,8 @@ data['format-version'] = "0.1" data['name'] = workflow.name data['annotation'] = annotation_str + if workflow.uuid is not None: + data['uuid'] = str(workflow.uuid) data['steps'] = {} # For each step, rebuild the form and encode the state for step in workflow.steps: diff -r b6ae7b6283c30bcb58e87003066102bfa5af5e11 -r e9152659a0be5e932e6eea591bd6c99977983854 lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -4,6 +4,7 @@ from __future__ import absolute_import +import uuid import logging from sqlalchemy import desc, or_ from galaxy import exceptions, util @@ -437,6 +438,17 @@ query = trans.sa_session.query( trans.app.model.StoredWorkflow ) stored_workflow = query.get( workflow_id ) except Exception: + try: + #see if they have passed in the UUID for a workflow that is attached to a stored workflow + workflow_uuid = uuid.UUID(workflow_id) + stored_workflow = trans.sa_session.query(trans.app.model.StoredWorkflow).filter( and_( + trans.app.model.StoredWorkflow.latest_workflow_id == trans.app.model.Workflow.id, + trans.app.model.Workflow.uuid == workflow_uuid + )).first() + if stored_workflow is None: + raise exceptions.ObjectNotFound( "Workflow not found: %s" % workflow_id ) + except: + pass #let the outer raise exception happen raise exceptions.ObjectNotFound( "No such workflow found - invalid workflow identifier." ) if stored_workflow is None: raise exceptions.ObjectNotFound( "No such workflow found." ) diff -r b6ae7b6283c30bcb58e87003066102bfa5af5e11 -r e9152659a0be5e932e6eea591bd6c99977983854 scripts/cleanup_datasets/populate_uuid.py --- a/scripts/cleanup_datasets/populate_uuid.py +++ b/scripts/cleanup_datasets/populate_uuid.py @@ -33,6 +33,12 @@ row.uuid = uuid.uuid4() print "Setting dataset:", row.id, " UUID to ", row.uuid model.context.flush() + + for row in model.context.query( model.Workflow ): + if row.uuid is None: + row.uuid = uuid.uuid4() + print "Setting Workflow:", row.id, " UUID to ", row.uuid + model.context.flush() if __name__ == "__main__": https://bitbucket.org/galaxy/galaxy-central/commits/80dfc96a9666/ Changeset: 80dfc96a9666 Branch: workflow-uuid User: kellrott Date: 2014-08-20 23:27:56 Summary: Fixing some small bugs to get the code to work Affected #: 1 file diff -r e9152659a0be5e932e6eea591bd6c99977983854 -r 80dfc96a96665052fdd213b77008d88c6935506b lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -6,7 +6,7 @@ import uuid import logging -from sqlalchemy import desc, or_ +from sqlalchemy import desc, or_, and_ from galaxy import exceptions, util from galaxy.model.item_attrs import UsesAnnotations from galaxy.managers import histories @@ -433,8 +433,8 @@ return stored_workflow def __get_stored_workflow( self, trans, workflow_id ): - workflow_id = self.__decode_id( trans, workflow_id ) try: + workflow_id = self.__decode_id( trans, workflow_id ) query = trans.sa_session.query( trans.app.model.StoredWorkflow ) stored_workflow = query.get( workflow_id ) except Exception: @@ -447,6 +447,7 @@ )).first() if stored_workflow is None: raise exceptions.ObjectNotFound( "Workflow not found: %s" % workflow_id ) + return stored_workflow except: pass #let the outer raise exception happen raise exceptions.ObjectNotFound( "No such workflow found - invalid workflow identifier." ) https://bitbucket.org/galaxy/galaxy-central/commits/b7fb63b19736/ Changeset: b7fb63b19736 User: dannon Date: 2014-08-26 17:26:31 Summary: Merged in kellrott/galaxy-farm/workflow-uuid (pull request #471) Workflow UUIDs Affected #: 6 files diff -r 3a51eaf209f2502bf32dbb421ecabb7fe46243ea -r b7fb63b197362424b39c2cc73d1589a0e383443e lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2974,6 +2974,7 @@ tag_str += ":" + tag.user_value tags_str_list.append( tag_str ) rval['tags'] = tags_str_list + rval['latest_workflow_uuid'] = ( lambda uuid: str( uuid ) if self.latest_workflow.uuid else None )( self.latest_workflow.uuid ) return rval @@ -2982,12 +2983,16 @@ dict_collection_visible_keys = ( 'name', 'has_cycles', 'has_errors' ) dict_element_visible_keys = ( 'name', 'has_cycles', 'has_errors' ) - def __init__( self ): + def __init__( self, uuid=None ): self.user = None self.name = None self.has_cycles = None self.has_errors = None self.steps = [] + if uuid is None: + self.uuid = uuid4() + else: + self.uuid = UUID(str(uuid)) def has_outputs_defined(self): """ @@ -2998,6 +3003,11 @@ return True return False + def to_dict( self, view='collection', value_mapper=None): + rval = super( Workflow, self ).to_dict( view=view, value_mapper = value_mapper ) + rval['uuid'] = ( lambda uuid: str( uuid ) if uuid else None )( self.uuid ) + return rval + class WorkflowStep( object ): diff -r 3a51eaf209f2502bf32dbb421ecabb7fe46243ea -r b7fb63b197362424b39c2cc73d1589a0e383443e lib/galaxy/model/mapping.py --- a/lib/galaxy/model/mapping.py +++ b/lib/galaxy/model/mapping.py @@ -690,7 +690,8 @@ Column( "stored_workflow_id", Integer, ForeignKey( "stored_workflow.id" ), index=True, nullable=False ), Column( "name", TEXT ), Column( "has_cycles", Boolean ), - Column( "has_errors", Boolean ) + Column( "has_errors", Boolean ), + Column( "uuid", UUIDType, nullable=True ) ) model.WorkflowStep.table = Table( "workflow_step", metadata, diff -r 3a51eaf209f2502bf32dbb421ecabb7fe46243ea -r b7fb63b197362424b39c2cc73d1589a0e383443e lib/galaxy/model/migrate/versions/0121_workflow_uuids.py --- /dev/null +++ b/lib/galaxy/model/migrate/versions/0121_workflow_uuids.py @@ -0,0 +1,55 @@ +""" +Add UUIDs to workflows +""" + +from sqlalchemy import * +from sqlalchemy.orm import * +from migrate import * +from migrate.changeset import * +from galaxy.model.custom_types import UUIDType, TrimmedString + +import logging +log = logging.getLogger( __name__ ) + +metadata = MetaData() + + + +""" +Because both workflow and job requests can be determined +based the a fixed data structure, their IDs are based on +hashing the data structure +""" +workflow_uuid_column = Column( "uuid", UUIDType, nullable=True ) + + +def display_migration_details(): + print "This migration script adds a UUID column to workflows" + +def upgrade(migrate_engine): + print __doc__ + metadata.bind = migrate_engine + metadata.reflect() + + # Add the uuid colum to the workflow table + try: + workflow_table = Table( "workflow", metadata, autoload=True ) + workflow_uuid_column.create( workflow_table ) + assert workflow_uuid_column is workflow_table.c.uuid + except Exception, e: + print str(e) + log.error( "Adding column 'uuid' to workflow table failed: %s" % str( e ) ) + return + +def downgrade(migrate_engine): + metadata.bind = migrate_engine + metadata.reflect() + + # Drop the workflow table's uuid column. + try: + workflow_table = Table( "workflow", metadata, autoload=True ) + workflow_uuid = workflow_table.c.uuid + workflow_uuid.drop() + except Exception, e: + log.debug( "Dropping 'uuid' column from workflow table failed: %s" % ( str( e ) ) ) + diff -r 3a51eaf209f2502bf32dbb421ecabb7fe46243ea -r b7fb63b197362424b39c2cc73d1589a0e383443e lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -1791,6 +1791,8 @@ data['format-version'] = "0.1" data['name'] = workflow.name data['annotation'] = annotation_str + if workflow.uuid is not None: + data['uuid'] = str(workflow.uuid) data['steps'] = {} # For each step, rebuild the form and encode the state for step in workflow.steps: diff -r 3a51eaf209f2502bf32dbb421ecabb7fe46243ea -r b7fb63b197362424b39c2cc73d1589a0e383443e lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -4,8 +4,9 @@ from __future__ import absolute_import +import uuid import logging -from sqlalchemy import desc, or_ +from sqlalchemy import desc, or_, and_ from galaxy import exceptions, util from galaxy.model.item_attrs import UsesAnnotations from galaxy.managers import histories @@ -432,11 +433,23 @@ return stored_workflow def __get_stored_workflow( self, trans, workflow_id ): - workflow_id = self.__decode_id( trans, workflow_id ) try: + workflow_id = self.__decode_id( trans, workflow_id ) query = trans.sa_session.query( trans.app.model.StoredWorkflow ) stored_workflow = query.get( workflow_id ) except Exception: + try: + #see if they have passed in the UUID for a workflow that is attached to a stored workflow + workflow_uuid = uuid.UUID(workflow_id) + stored_workflow = trans.sa_session.query(trans.app.model.StoredWorkflow).filter( and_( + trans.app.model.StoredWorkflow.latest_workflow_id == trans.app.model.Workflow.id, + trans.app.model.Workflow.uuid == workflow_uuid + )).first() + if stored_workflow is None: + raise exceptions.ObjectNotFound( "Workflow not found: %s" % workflow_id ) + return stored_workflow + except: + pass #let the outer raise exception happen raise exceptions.ObjectNotFound( "No such workflow found - invalid workflow identifier." ) if stored_workflow is None: raise exceptions.ObjectNotFound( "No such workflow found." ) diff -r 3a51eaf209f2502bf32dbb421ecabb7fe46243ea -r b7fb63b197362424b39c2cc73d1589a0e383443e scripts/cleanup_datasets/populate_uuid.py --- a/scripts/cleanup_datasets/populate_uuid.py +++ b/scripts/cleanup_datasets/populate_uuid.py @@ -33,6 +33,12 @@ row.uuid = uuid.uuid4() print "Setting dataset:", row.id, " UUID to ", row.uuid model.context.flush() + + for row in model.context.query( model.Workflow ): + if row.uuid is None: + row.uuid = uuid.uuid4() + print "Setting Workflow:", row.id, " UUID to ", row.uuid + model.context.flush() if __name__ == "__main__": 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.