From ac2c46029acd187612b4eeba685dffcca285eee8 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 5 Sep 2014 18:55:21 -0400 Subject: [PATCH] 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. --- lib/galaxy/model/__init__.py | 10 ++++++---- test/api/test_workflows.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 9b0b2d63b89..b1b3e738b4c 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -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 diff --git a/test/api/test_workflows.py b/test/api/test_workflows.py index afeaab66b4c..e714f93688f 100644 --- a/test/api/test_workflows.py +++ b/test/api/test_workflows.py @@ -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 ):