diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 4bdc69f49d3..df24eeed494 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -551,10 +551,16 @@ class Job( object, HasJobMetrics, Dictifiable ): input_dict = {} for i in self.input_datasets: if i.dataset is not None: - input_dict[i.name] = {"id" : i.dataset.id, "src" : "hda"} + input_dict[i.name] = { + "id" : i.dataset.id, "src" : "hda", + "uuid" : str(i.dataset.dataset.uuid) if i.dataset.dataset.uuid is not None else None + } for i in self.input_library_datasets: if i.dataset is not None: - input_dict[i.name] = {"id" : i.dataset.id, "src" : "ldda"} + input_dict[i.name] = { + "id" : i.dataset.id, "src" : "ldda", + "uuid": str(i.dataset.dataset.uuid) if i.dataset.dataset.uuid is not None else None + } for k in input_dict: if k in param_dict: del param_dict[k] @@ -563,10 +569,16 @@ class Job( object, HasJobMetrics, Dictifiable ): output_dict = {} for i in self.output_datasets: if i.dataset is not None: - output_dict[i.name] = {"id" : i.dataset.id, "src" : "hda"} + output_dict[i.name] = { + "id" : i.dataset.id, "src" : "hda", + "uuid" : str(i.dataset.dataset.uuid) if i.dataset.dataset.uuid is not None else None + } for i in self.output_library_datasets: if i.dataset is not None: - output_dict[i.name] = {"id" : i.dataset.id, "src" : "ldda"} + output_dict[i.name] = { + "id" : i.dataset.id, "src" : "ldda", + "uuid" : str(i.dataset.dataset.uuid) if i.dataset.dataset.uuid is not None else None + } rval['outputs'] = output_dict return rval @@ -3256,12 +3268,15 @@ class WorkflowInvocation( object, Dictifiable ): # is relatively intutitive. return map( lambda wi: wi.id, query.all() ) - def to_dict( self, view='collection', value_mapper=None ): + def to_dict( self, view='collection', value_mapper=None, step_details=False ): rval = super( WorkflowInvocation, self ).to_dict( view=view, value_mapper=value_mapper ) if view == 'element': steps = [] for step in self.steps: - v = step.to_dict() + if step_details: + v = step.to_dict(view='element') + else: + v = step.to_dict(view='collection') steps.append( v ) rval['steps'] = steps @@ -3274,7 +3289,10 @@ class WorkflowInvocation( object, Dictifiable ): 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": src } + inputs[str(step_input.output_step.order_index)] = { + "id": job_input.dataset_id, "src": src, + "uuid" : str(job_input.dataset.dataset.uuid) if job_input.dataset.dataset.uuid is not None else None + } rval['inputs'] = inputs return rval @@ -3313,7 +3331,24 @@ class WorkflowInvocationStep( object, Dictifiable ): def to_dict( self, view='collection', value_mapper=None ): rval = super( WorkflowInvocationStep, self ).to_dict( view=view, value_mapper=value_mapper ) rval['order_index'] = self.workflow_step.order_index + rval['workflow_step_label'] = self.workflow_step.label + rval['workflow_step_uuid'] = str(self.workflow_step.uuid) rval['state'] = self.job.state if self.job is not None else None + if self.job is not None and view=='element': + output_dict = {} + for i in self.job.output_datasets: + if i.dataset is not None: + output_dict[i.name] = { + "id" : i.dataset.id, "src" : "hda", + "uuid" : str(i.dataset.dataset.uuid) if i.dataset.dataset.uuid is not None else None + } + for i in self.job.output_library_datasets: + if i.dataset is not None: + output_dict[i.name] = { + "id" : i.dataset.id, "src" : "ldda", + "uuid" : str(i.dataset.dataset.uuid) if i.dataset.dataset.uuid is not None else None + } + rval['outputs'] = output_dict return rval diff --git a/lib/galaxy/webapps/galaxy/api/workflows.py b/lib/galaxy/webapps/galaxy/api/workflows.py index 25a5705fb3c..57196020f60 100644 --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -213,7 +213,7 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn # Newer version of this API just returns the invocation as a dict, to # facilitate migration - produce the newer style response and blend in # the older information. - invocation_response = self.__encode_invocation( trans, invocation ) + invocation_response = self.__encode_invocation( trans, invocation, step_details=kwd.get('step_details', False) ) invocation_response.update( rval ) return invocation_response @@ -463,7 +463,7 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn results = self.workflow_manager.build_invocations_query( trans, stored_workflow.id ) out = [] for r in results: - out.append( self.__encode_invocation( trans, r ) ) + out.append( self.__encode_invocation( trans, r, view="collection" ) ) return out @expose_api @@ -483,7 +483,7 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn decoded_workflow_invocation_id = self.decode_id( invocation_id ) workflow_invocation = self.workflow_manager.get_invocation( trans, decoded_workflow_invocation_id ) if workflow_invocation: - return self.__encode_invocation( trans, workflow_invocation ) + return self.__encode_invocation( trans, workflow_invocation, step_details=kwd.get('step_details', False) ) return None @expose_api @@ -596,9 +596,9 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn raise exceptions.ObjectNotFound( "No such workflow found." ) return stored_workflow - def __encode_invocation( self, trans, invocation, view="element" ): + def __encode_invocation( self, trans, invocation, view="element", step_details=False ): return self.encode_all_ids( trans, - invocation.to_dict( view ), + invocation.to_dict( view, step_details=step_details ), True )