Update workflow invocation to_dict for recent collection workflow changes.

There may now be multiple WorkflowInvocationSteps for each WorkflowStep for steps that are mapped over collections - so to_dict creating a dictionary of this information indexed on order step is problematic because only one WorkflowInvocationStep will be represented per step. Instead now just returning a big list of all of the invocations - which contains all of the same information. This is a backward incompatible API change for the workflow invocation API.

Also update the input mapping stuff with logic for dealing with data collection inputs.
This commit is contained in:
John Chilton
2014-09-05 18:55:21 -04:00
parent 342b7b7117
commit ac2c46029a
2 changed files with 8 additions and 6 deletions
+6 -4
View File
@@ -3081,20 +3081,22 @@ class WorkflowInvocation( object, Dictifiable ):
def to_dict( self, view='collection', value_mapper=None ):
rval = super( WorkflowInvocation, self ).to_dict( view=view, value_mapper=value_mapper )
if view == 'element':
steps = {}
steps = []
for step in self.steps:
v = step.to_dict()
steps[str(v['order_index'])] = v
steps.append( v )
rval['steps'] = steps
inputs = {}
for step in self.steps:
if step.workflow_step.type == 'tool':
for step_input in step.workflow_step.input_connections:
if step_input.output_step.type == 'data_input':
output_step_type = step_input.output_step.type
if output_step_type in [ 'data_input', 'data_collection_input' ]:
src = "hda" if output_step_type == 'data_input' else 'hdca'
for job_input in step.job.input_datasets:
if job_input.name == step_input.input_name:
inputs[str(step_input.output_step.order_index)] = { "id": job_input.dataset_id, "src": "hda"}
inputs[str(step_input.output_step.order_index)] = { "id": job_input.dataset_id, "src": src }
rval['inputs'] = inputs
return rval
+2 -2
View File
@@ -520,8 +520,8 @@ class WorkflowsApiTestCase( api.ApiTestCase ):
usage_details = usage_details_response.json()
# Assert some high-level things about the structure of data returned.
self._assert_has_keys( usage_details, "inputs", "steps" )
for step in usage_details[ "steps" ].values():
self._assert_has_keys( step, "workflow_step_id", "order_index" )
for step in usage_details[ "steps" ]:
self._assert_has_keys( step, "workflow_step_id", "order_index", "id" )
@skip_without_tool( "cat1" )
def test_post_job_action( self ):