Redo API for subcollection mapping steps in tools.

Like the reductions - was previously constrained by sequeezing these values into simple strings - now the tool form will target the API I think this expanded version is a little more straight-forward (though verbose). Adds consistency with rest of the tool form API changes.
This commit is contained in:
John Chilton
2014-09-16 11:57:48 -04:00
parent 864ab4b70c
commit a1b72d5bf0
2 changed files with 40 additions and 3 deletions
+2 -1
View File
@@ -106,9 +106,10 @@ def __expand_collection_parameter( trans, input_key, incoming_val, collections_t
if src != "hdca":
raise exceptions.ToolMetaParameterException( "Invalid dataset collection source type %s" % src )
encoded_hdc_id = incoming_val[ "id" ]
subcollection_type = incoming_val.get( 'map_over_type', None )
except TypeError:
encoded_hdc_id = incoming_val
subcollection_type = None
subcollection_type = None
hdc_id = trans.app.security.decode_id( encoded_hdc_id )
hdc = trans.sa_session.query( model.HistoryDatasetCollectionAssociation ).get( hdc_id )
collections_to_match.add( input_key, hdc, subcollection_type=subcollection_type )
+38 -2
View File
@@ -492,12 +492,27 @@ class ToolsTestCase( api.ApiTestCase ):
assert len( output2_content.strip().split("\n") ) == 3, output2_content
@skip_without_tool( "collection_paired_test" )
def test_subcollection_mapping( self ):
def test_subcollection_mapping_legacy( self ):
history_id = self.dataset_populator.new_history()
hdca_list_id = self.__build_nested_list( history_id )
inputs = {
"f1|__collection_multirun__": "%s|paired" % hdca_list_id
}
self._check_simple_subcollection_mapping( history_id, inputs )
@skip_without_tool( "collection_paired_test" )
def test_subcollection_mapping( self ):
history_id = self.dataset_populator.new_history()
hdca_list_id = self.__build_nested_list( history_id )
inputs = {
"f1": {
'batch': True,
'values': [ { 'src': 'hdca', 'map_over_type': 'paired', 'id': hdca_list_id }],
}
}
self._check_simple_subcollection_mapping( history_id, inputs )
def _check_simple_subcollection_mapping( self, history_id, inputs ):
# Following wait not really needed - just getting so many database
# locked errors with sqlite.
self.dataset_populator.wait_for_history( history_id, assert_ok=True )
@@ -511,7 +526,7 @@ class ToolsTestCase( api.ApiTestCase ):
assert output2_content.strip() == "789\n0ab", output2_content
@skip_without_tool( "collection_mixed_param" )
def test_combined_mapping_and_subcollection_mapping( self ):
def test_combined_mapping_and_subcollection_mapping_legacy( self ):
history_id = self.dataset_populator.new_history()
nested_list_id = self.__build_nested_list( history_id )
create_response = self.dataset_collection_populator.create_list_in_history( history_id, contents=["xxx", "yyy"] )
@@ -520,6 +535,27 @@ class ToolsTestCase( api.ApiTestCase ):
"f1|__collection_multirun__": "%s|paired" % nested_list_id,
"f2|__collection_multirun__": list_id,
}
self._check_combined_mapping_and_subcollection_mapping( history_id, inputs )
@skip_without_tool( "collection_mixed_param" )
def test_combined_mapping_and_subcollection_mapping( self ):
history_id = self.dataset_populator.new_history()
nested_list_id = self.__build_nested_list( history_id )
create_response = self.dataset_collection_populator.create_list_in_history( history_id, contents=["xxx", "yyy"] )
list_id = create_response.json()[ "id" ]
inputs = {
"f1": {
'batch': True,
'values': [ { 'src': 'hdca', 'map_over_type': 'paired', 'id': nested_list_id }],
},
"f2": {
'batch': True,
'values': [ { 'src': 'hdca', 'id': list_id }],
},
}
self._check_combined_mapping_and_subcollection_mapping( history_id, inputs )
def _check_combined_mapping_and_subcollection_mapping( self, history_id, inputs ):
self.dataset_populator.wait_for_history( history_id, assert_ok=True )
outputs = self._run_and_get_outputs( "collection_mixed_param", history_id, inputs )
assert len( outputs ), 2