Skip to content

Commit

Permalink
Rebase into sub workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Dec 1, 2015
1 parent b4f6ed5 commit 9befc72
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
32 changes: 31 additions & 1 deletion lib/galaxy/managers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,16 @@ def update_workflow_from_dict(self, trans, stored_workflow, workflow_data, from_
steps.append( step )
steps_by_external_id[ step_dict['id' ] ] = step
if 'workflow_outputs' in step_dict:
for output_name in step_dict['workflow_outputs']:
workflow_outputs = step_dict['workflow_outputs']
for output_name in workflow_outputs:
m = model.WorkflowOutput(workflow_step=step, output_name=output_name)
if isinstance(workflow_outputs, dict):
uuid = workflow_outputs.get("uuid", None)
label = workflow_outputs.get("label", None)
if uuid is not None:
m.uuid = uuid
if label is not None:
m.label = label
trans.sa_session.add(m)
if step.tool_errors:
# DBTODO Check for conditional inputs here.
Expand Down Expand Up @@ -628,6 +636,9 @@ def __walk_step_dicts( self, data ):
discovered_labels = set()
discovered_uuids = set()

discovered_output_labels = set()
discovered_output_uuids = set()

# First pass to build step objects and populate basic values
for step_index in step_indices:
step_dict = supplied_steps[ step_index ]
Expand All @@ -642,6 +653,25 @@ def __walk_step_dicts( self, data ):
raise exceptions.DuplicatedIdentifierException("Duplicated step label in request.")
discovered_labels.add(label)

if 'workflow_outputs' in step_dict:
outputs = step_dict['workflow_outputs']
# outputs may be list of name (deprecated legacy behavior)
# or dictionary of names to {uuid: <uuid>, label: <label>}
if isinstance(outputs, dict):
for output_name in outputs:
output_dict = outputs[output_name]
output_label = output_dict.get("label", None)
if output_label:
if label in discovered_output_labels:
raise exceptions.DuplicatedIdentifierException("Duplicated workflow output label in request.")
discovered_output_labels.add(label)

output_uuid = step_dict.get("output_uuid", None)
if output_uuid:
if output_uuid in discovered_output_uuids:
raise exceptions.DuplicatedIdentifierException("Duplicate workflow output UUID in request.")
discovered_output_uuids.add(uuid)

yield step_dict

def __module_from_dict( self, trans, step_dict, secure ):
Expand Down
6 changes: 5 additions & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3538,9 +3538,13 @@ def non_data_connection(self):

class WorkflowOutput(object):

def __init__( self, workflow_step, output_name):
def __init__( self, workflow_step, output_name, uuid=None):
self.workflow_step = workflow_step
self.output_name = output_name
if uuid is None:
self.uuid = uuid4()
else:
self.uuid = UUID(str(uuid))


class StoredWorkflowUserShareAssociation( object ):
Expand Down
5 changes: 4 additions & 1 deletion lib/galaxy/model/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,10 @@
"workflow_output", metadata,
Column( "id", Integer, primary_key=True ),
Column( "workflow_step_id", Integer, ForeignKey("workflow_step.id"), index=True, nullable=False ),
Column( "output_name", String(255), nullable=True ) )
Column( "output_name", String(255), nullable=True ),
Column( "label", Unicode(255) ),
Column( "uuid", UUIDType ),
)

model.WorkflowInvocation.table = Table(
"workflow_invocation", metadata,
Expand Down
12 changes: 12 additions & 0 deletions lib/galaxy/model/migrate/versions/0132_subworkflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from sqlalchemy import Column, Integer, ForeignKey, MetaData, Table

from galaxy.model.custom_types import TrimmedString, UUIDType

now = datetime.datetime.utcnow
log = logging.getLogger( __name__ )
metadata = MetaData()
Expand All @@ -22,6 +24,13 @@ def upgrade(migrate_engine):
parent_workflow_id_column = Column( "parent_workflow_id", Integer, ForeignKey("workflow.id"), nullable=True )
__add_column( parent_workflow_id_column, "workflow", metadata )

workflow_output_label_column = Column( "label", TrimmedString(255) )
workflow_output_uuid_column = Column( "uuid", UUIDType, nullable=True )
__add_column( workflow_output_label_column, "workflow_output", metadata )
__add_column( workflow_output_uuid_column, "workflow_output", metadata )

# Make stored_workflow_id nullable, since now workflows can belong to either
# a stored workflow or a parent workflow.
__alter_column("workflow", "stored_workflow_id", metadata, nullable=True)


Expand All @@ -32,6 +41,9 @@ def downgrade(migrate_engine):
__drop_column( "subworkflow_id", "workflow_step", metadata )
__drop_column( "parent_workflow_id", "workflow_step", metadata )

__drop_column( "label", "workflow_output", metadata )
__drop_column( "uuid", "workflow_output", metadata )

__alter_column("workflow", "stored_workflow_id", metadata, nullable=False)


Expand Down

0 comments on commit 9befc72

Please sign in to comment.