Merge pull request #2570 from abretaud/identifier_bug

Fix element_identifier unavailable with data_collection input param
This commit is contained in:
Nicola Soranzo
2016-07-07 16:47:35 +01:00
committed by GitHub
5 changed files with 51 additions and 1 deletions
+1
View File
@@ -2152,6 +2152,7 @@ class DataCollectionToolParameter( BaseDataToolParameter ):
return field
def from_json( self, value, trans, other_values={} ):
rval = None
if trans.workflow_building_mode is workflow_building_modes.ENABLED:
return None
if not value and not self.optional:
+1 -1
View File
@@ -365,7 +365,7 @@ class DatasetCollectionWrapper( ToolParameterValueWrapper, HasDatasets ):
if dataset_collection_element.is_collection:
element_wrapper = DatasetCollectionWrapper(job_working_directory, dataset_collection_element, dataset_paths, **kwargs )
else:
element_wrapper = self._dataset_wrapper( element_object, dataset_paths, **kwargs)
element_wrapper = self._dataset_wrapper( element_object, dataset_paths, identifier=element_identifier, **kwargs)
element_instances[element_identifier] = element_wrapper
element_instance_list.append( element_wrapper )
+33
View File
@@ -1,5 +1,6 @@
# Test tools API.
from base import api
import json
from operator import itemgetter
from .helpers import DatasetPopulator
from .helpers import DatasetCollectionPopulator
@@ -805,6 +806,38 @@ class ToolsTestCase( api.ApiTestCase ):
output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 )
self.assertEquals( output1_content.strip(), "Pasted Entry\nPasted Entry" )
@skip_without_tool( "identifier_collection" )
def test_identifier_with_data_collection( self ):
history_id = self.dataset_populator.new_history()
element_identifiers = self.dataset_collection_populator.list_identifiers( history_id )
payload = dict(
instance_type="history",
history_id=history_id,
element_identifiers=json.dumps(element_identifiers),
collection_type="list",
)
create_response = self._post( "dataset_collections", payload )
dataset_collection = create_response.json()
inputs = {
"input1": {'src': 'hdca', 'id': dataset_collection['id']},
}
self.dataset_populator.wait_for_history( history_id, assert_ok=True )
create_response = self._run( "identifier_collection", history_id, inputs )
self._assert_status_code_is( create_response, 200 )
create = create_response.json()
outputs = create[ 'outputs' ]
jobs = create[ 'jobs' ]
self.assertEquals( len( jobs ), 1 )
self.assertEquals( len( outputs ), 1 )
output1 = outputs[ 0 ]
output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 )
self.assertEquals( output1_content.strip(), '\n'.join([d['name'] for d in element_identifiers]) )
@skip_without_tool( "cat1" )
def test_map_over_nested_collections( self ):
history_id = self.dataset_populator.new_history()
@@ -0,0 +1,15 @@
<tool id="identifier_collection" name="identifier_collection">
<command>
#for $input in $input1:
echo '$input.element_identifier' >> 'output1';
#end for
</command>
<inputs>
<param type="data_collection" collection_type="list" name="input1" label="Input 1" />
</inputs>
<outputs>
<data name="output1" type="tabular" from_work_dir="output1" />
</outputs>
<tests>
</tests>
</tool>
@@ -64,6 +64,7 @@
<tool file="validation_empty_dataset.xml" />
<tool file="identifier_single.xml" />
<tool file="identifier_multiple.xml" />
<tool file="identifier_collection.xml" />
<tool file="tool_directory.xml" />
<tool file="output_action_change_format.xml" />
<tool file="collection_paired_test.xml" />