commit/galaxy-central: jmchilton: Fix passing nested parameter replacements to the workflow run API.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/011c8b2118be/ Changeset: 011c8b2118be Branch: stable User: jmchilton Date: 2014-11-14 17:58:29+00:00 Summary: Fix passing nested parameter replacements to the workflow run API. Thanks to Nicola for finding the problem https://bitbucket.org/galaxy/galaxy-central/commits/fa92c5497232444ade0e7044.... Affected #: 3 files diff -r 9c1197f1e259f7925be467f2f6f92fa3e7a5e86c -r 011c8b2118be778eaf1ba952730ff876d6447ba9 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2556,14 +2556,20 @@ history = None value = input.test_param.get_initial_value( trans, context, history=history ) current_case = input.get_current_case( value, trans ) - if current_case != old_current_case: + case_changed = current_case != old_current_case + if case_changed: # Current case has changed, throw away old state group_state = state[input.name] = {} # TODO: we should try to preserve values if we can self.fill_in_new_state( trans, input.cases[current_case].inputs, group_state, context ) group_errors = dict() group_old_errors = dict() - else: + + # If we didn't just change the current case and are coming from HTML - the values + # in incoming represent the old values and should not be replaced. If being updated + # from the API (json) instead of HTML - form values below the current case + # may also be supplied and incoming should be preferred to case defaults. + if (not case_changed) or (source != "html"): # Current case has not changed, update children group_errors = self.update_state( trans, input.cases[current_case].inputs, diff -r 9c1197f1e259f7925be467f2f6f92fa3e7a5e86c -r 011c8b2118be778eaf1ba952730ff876d6447ba9 lib/galaxy/workflow/modules.py --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -609,7 +609,7 @@ old_errors = state.inputs.pop( "__errors__", {} ) # Update the state step_errors = tool.update_state( trans, tool.inputs, state.inputs, step_updates, - update_only=True, old_errors=old_errors ) + update_only=True, old_errors=old_errors, source="json" ) return state, step_errors def execute( self, trans, progress, invocation, step ): diff -r 9c1197f1e259f7925be467f2f6f92fa3e7a5e86c -r 011c8b2118be778eaf1ba952730ff876d6447ba9 lib/galaxy/workflow/run_request.py --- a/lib/galaxy/workflow/run_request.py +++ b/lib/galaxy/workflow/run_request.py @@ -111,7 +111,32 @@ param_dict[param_dict['param']] = param_dict['value'] del param_dict[ 'param' ] del param_dict[ 'value' ] - return param_dict + # Inputs can be nested dict, but Galaxy tool code wants nesting of keys (e.g. + # cond1|moo=4 instead of cond1: {moo: 4} ). + new_params = _flatten_step_params( param_dict ) + return new_params + + +def _flatten_step_params( param_dict, prefix="" ): + # TODO: Temporary work around until tool code can process nested data + # structures. This should really happen in there so the tools API gets + # this functionality for free and so that repeats can be handled + # properly. Also the tool code walks the tool inputs so it nows what is + # a complex value object versus something that maps to child parameters + # better than the hack or searching for src and id here. + new_params = {} + keys = param_dict.keys()[:] + for key in keys: + if prefix: + effective_key = "%s|%s" % ( prefix, key ) + else: + effective_key = key + value = param_dict[key] + if isinstance(value, dict) and not ('src' in value and 'id' in value): + new_params.update(_flatten_step_params( value, effective_key) ) + else: + new_params[effective_key] = value + return new_params def build_workflow_run_config( trans, workflow, payload ): 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.
participants (1)
-
commits-noreply@bitbucket.org