Fix for KeyError in templates/show_params.mako
A user encountered a KeyError when clicking the "View Details" icon from an older Cuffdiff history item: File '/galaxy/PRODUCTION/database/compiled_templates/show_params.mako.py', line 106 in render_body __M_writer(unicode( inputs_recursive(tool.inputs, params_objects, depth=1) )) File '/galaxy/PRODUCTION/database/compiled_templates/show_params.mako.py', line 33 in inputs_recursive return render_inputs_recursive(context.locals_(__M_locals),input_params,param_values,depth) File '/galaxy/PRODUCTION/database/compiled_templates/show_params.mako.py', line 202 in render_inputs_recursive __M_writer(unicode(input.value_to_display_text(param_values[input.name], trans.app))) KeyError: 'multiread_correct' This can be fixed in templates/show_params.mako by checking if the input.name key exists in the param_values, surrounding the contents of the for loop with: %if input.name in param_values: %endif $ hg diff templates/show_params.mako diff -r 340438c62171 templates/show_params.mako --- a/templates/show_params.mako Wed Nov 14 18:50:20 2012 -0500 +++ b/templates/show_params.mako Thu Nov 15 08:15:47 2012 -0600 @@ -12,23 +12,25 @@ <%def name="inputs_recursive( input_params, param_values, depth=1 )"> %for input_index, input in enumerate( input_params.itervalues() ): - %if input.type == "repeat": - %for i in range( len(param_values[input.name]) ): - ${ inputs_recursive(input.inputs, param_values[input.name][i], depth=depth+1) } - %endfor - %elif input.type == "conditional": - <% current_case = param_values[input.name]['__current_case__'] %> + %if input.name in param_values: + %if input.type == "repeat": + %for i in range( len(param_values[input.name]) ): + ${ inputs_recursive(input.inputs, param_values[input.name][i], depth=depth+1) } + %endfor + %elif input.type == "conditional": + <% current_case = param_values[input.name]['__current_case__'] %> + <tr> + ${ inputs_recursive_indent( text=input.test_param.label,depth=depth )} + <!-- Get the value of the current Conditonal parameter --> + <td>${input.cases[current_case].value}</td> + </tr> + ${ inputs_recursive(input.cases[current_case].inputs, param_values[input.name], depth=depth+1) } + %elif getattr(input, "label", None): <tr> - ${ inputs_recursive_indent( text=input.test_param.label,depth=depth )} - <!-- Get the value of the current Conditonal parameter --> - <td>${input.cases[current_case].value}</td> + ${inputs_recursive_indent( text=input.label,depth=depth )} + <td>${input.value_to_display_text(param_values[input.name], trans.app)}</td> </tr> - ${ inputs_recursive(input.cases[current_case].inputs, param_values[input.name], depth=depth+1) } - %elif getattr(input, "label", None): - <tr> - ${inputs_recursive_indent( text=input.label,depth=depth )} - <td>${input.value_to_display_text(param_values[input.name], trans.app)}</td> - </tr> + %endif %endif %endfor </%def>
Thanks for reporting this. I used your patch as inspiration to create the final fix, which is a bit more user friendly as it shows the parameter and explains that it was not used: https://bitbucket.org/galaxy/galaxy-central/changeset/ad6c2f4b3433/ J. On Nov 15, 2012, at 9:38 AM, Jim Johnson wrote:
A user encountered a KeyError when clicking the "View Details" icon from an older Cuffdiff history item:
File '/galaxy/PRODUCTION/database/compiled_templates/show_params.mako.py', line 106 in render_body __M_writer(unicode( inputs_recursive(tool.inputs, params_objects, depth=1) )) File '/galaxy/PRODUCTION/database/compiled_templates/show_params.mako.py', line 33 in inputs_recursive return render_inputs_recursive(context.locals_(__M_locals),input_params,param_values,depth) File '/galaxy/PRODUCTION/database/compiled_templates/show_params.mako.py', line 202 in render_inputs_recursive __M_writer(unicode(input.value_to_display_text(param_values[input.name], trans.app))) KeyError: 'multiread_correct'
This can be fixed in templates/show_params.mako by checking if the input.name key exists in the param_values, surrounding the contents of the for loop with: %if input.name in param_values: %endif
$ hg diff templates/show_params.mako diff -r 340438c62171 templates/show_params.mako --- a/templates/show_params.mako Wed Nov 14 18:50:20 2012 -0500 +++ b/templates/show_params.mako Thu Nov 15 08:15:47 2012 -0600 @@ -12,23 +12,25 @@
<%def name="inputs_recursive( input_params, param_values, depth=1 )"> %for input_index, input in enumerate( input_params.itervalues() ): - %if input.type == "repeat": - %for i in range( len(param_values[input.name]) ): - ${ inputs_recursive(input.inputs, param_values[input.name][i], depth=depth+1) } - %endfor - %elif input.type == "conditional": - <% current_case = param_values[input.name]['__current_case__'] %> + %if input.name in param_values: + %if input.type == "repeat": + %for i in range( len(param_values[input.name]) ): + ${ inputs_recursive(input.inputs, param_values[input.name][i], depth=depth+1) } + %endfor + %elif input.type == "conditional": + <% current_case = param_values[input.name]['__current_case__'] %> + <tr> + ${ inputs_recursive_indent( text=input.test_param.label,depth=depth )} + <!-- Get the value of the current Conditonal parameter --> + <td>${input.cases[current_case].value}</td> + </tr> + ${ inputs_recursive(input.cases[current_case].inputs, param_values[input.name], depth=depth+1) } + %elif getattr(input, "label", None): <tr> - ${ inputs_recursive_indent( text=input.test_param.label,depth=depth )} - <!-- Get the value of the current Conditonal parameter --> - <td>${input.cases[current_case].value}</td> + ${inputs_recursive_indent( text=input.label,depth=depth )} + <td>${input.value_to_display_text(param_values[input.name], trans.app)}</td> </tr> - ${ inputs_recursive(input.cases[current_case].inputs, param_values[input.name], depth=depth+1) } - %elif getattr(input, "label", None): - <tr> - ${inputs_recursive_indent( text=input.label,depth=depth )} - <td>${input.value_to_display_text(param_values[input.name], trans.app)}</td> - </tr> + %endif %endif %endfor </%def>
___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at:
participants (2)
-
Jeremy Goecks
-
Jim Johnson