1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/d896ca45280f/ Changeset: d896ca45280f User: jmchilton Date: 2013-11-22 06:37:22 Summary: Fixes related to implicit defaults of param values. Logic errors related to them being contained in repeat blocks and to picking the top value in a select by default when no other value is marked as default. Other small adjustments - add another sample tool demonstrating the problem and clean up error messages. Affected #: 3 files diff -r 1c306a40b1c3f6f3abc51f44d2bc77a5bb1d6695 -r d896ca45280fbc7764fa2fe82fe10d7537d858dc lib/galaxy/tools/test.py --- a/lib/galaxy/tools/test.py +++ b/lib/galaxy/tools/test.py @@ -78,13 +78,15 @@ if selected: default_option = name else: - default_option = test_param.static_options[0] + first_option = test_param.static_options[0] + first_option_value = first_option[1] + default_option = first_option_value matches_declared_value = lambda case_value: case_value == default_option else: # No explicit value for this param and cannot determine a # default - give up. Previously this would just result in a key # error exception. - msg = "Failed to find test parameter specification required for conditional %s" % cond + msg = "Failed to find test parameter value specification required for conditional %s" % cond.name raise Exception( msg ) # Check the tool's defined cases against predicate to determine @@ -93,7 +95,9 @@ if matches_declared_value( case.value ): return case else: - log.info("Failed to find case matching test parameter specification for cond %s. Remainder of test behavior is unspecified." % cond) + msg_template = "%s - Failed to find case matching value (%s) for test parameter specification for conditional %s. Remainder of test behavior is unspecified." + msg = msg_template % ( self.tool.id, declared_value, cond.name ) + log.info( msg ) def __split_if_str( self, value ): split = isinstance(value, str) @@ -143,10 +147,20 @@ case_value = raw_input[ 1 ] if raw_input else None case = self.__matching_case_for_value( value, case_value ) if case: - expanded_value = self.__split_if_str( case.value ) - expanded_inputs[ case_context.for_state() ] = expanded_value for input_name, input_value in case.inputs.items(): - expanded_inputs.update( self.__process_raw_inputs( { input_name: input_value }, raw_inputs, parent_context=cond_context ) ) + case_inputs = self.__process_raw_inputs( { input_name: input_value }, raw_inputs, parent_context=cond_context ) + expanded_inputs.update( case_inputs ) + expanded_case_value = self.__split_if_str( case.value ) + if case_value is not None: + # A bit tricky here - we are growing inputs with value + # that may be implicit (i.e. not defined by user just + # a default defined in tool). So we do not want to grow + # expanded_inputs and risk repeat block viewing this + # as a new instance with value defined and hence enter + # an infinite loop - hence the "case_value is not None" + # check. + expanded_inputs[ case_context.for_state() ] = expanded_case_value + elif isinstance( value, grouping.Repeat ): repeat_index = 0 while True: diff -r 1c306a40b1c3f6f3abc51f44d2bc77a5bb1d6695 -r d896ca45280fbc7764fa2fe82fe10d7537d858dc test/functional/tools/implicit_default_conds.xml --- /dev/null +++ b/test/functional/tools/implicit_default_conds.xml @@ -0,0 +1,49 @@ +<tool id="implicit_default_conds" name="implicit_default_conds"> + <command> + echo "$param_group[0].p1.val" >> $out_file1; + echo "$param_group[0].p2.val" >> $out_file1; + </command> + <inputs> + <repeat name="param_group" title="Param Group" min="1"> + <conditional name="p1"> + <param name="type" type="select"> + <option value="default">THE DEFAULT</option> + <option value="different">A different value</option> + </param> + <when value="default"> + <param name="val" value="p1default" type="text" /> + </when> + <when value="different"> + <param name="val" value="p1different" type="text" /> + </when> + </conditional> + <conditional name="p2"> + <param name="type" type="select"> + <option value="default">THE DEFAULT</option> + <option value="different" selected="true">A different value</option> + </param> + <when value="default"> + <param name="val" value="p2default" type="text" /> + </when> + <when value="different"> + <param name="val" value="p2different" type="text" /> + </when> + </conditional> + <param name="int_param" type="integer" value="8" /> + </repeat> + </inputs> + <outputs> + <data name="out_file1" format="txt" /> + </outputs> + <tests> + <test> + <param name="int_param" value="7" /><!-- Specify at least one value in repeat to force one instance. --> + <output name="out_file1"> + <assert_contents> + <has_line line="p1default" /> + <has_line line="p2different" /> + </assert_contents> + </output> + </test> + </tests> +</tool> diff -r 1c306a40b1c3f6f3abc51f44d2bc77a5bb1d6695 -r d896ca45280fbc7764fa2fe82fe10d7537d858dc test/functional/tools/samples_tool_conf.xml --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -13,4 +13,5 @@ <tool file="output_order.xml" /><tool file="disambiguate_repeats.xml" /><tool file="min_repeat.xml" /> + <tool file="implicit_default_conds.xml" /></toolbox> \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.