[21.05] Do not persist tool state when invoking workflow #12141
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
If the
tool_inputscolumn of theworkflow_stepis loaded asMutableJSONTypeany "accidental" change of values in the dict marks theobject as "dirty" in the sqlalchemy session it is attached to and will
be persisted when the session is being flushed.
Making the column type
JSONTypeinstead ofMutableJSONTypemeansthat the object is not marked as dirty and will not be persisted in that
case. The correct method to use to actually persist step inputs is
WorkflowModule.save_to_step or setting step.tool_inputs directly. This
fixes #9886 and (probably, wasn't able to reproduce myself) #12081 (comment)
The issue in #9886 is that
when you submit a workflow the step state is converted to a tool state
in
https://github.com/mvdbeek/galaxy/blob/90dff9af5bec8bed1258620e5351d0350e284206/lib/galaxy/workflow/modules.py#L661:
and safe_loads just returns the same object if the object that is passed
in is not actually a JSON string. So
state["format"] = formatsmanipulates the step state in place and that gets committed when
flushing the new invocation.
How to test the changes?
(Select all options that apply)
This is tricky to write good tests for. You could revert #9884 and run @dannon's workflow in https://gist.github.com/dannon/d8abf15c848405a7dc15a792149087d3 and make sure that after running it once you don't see
"tool_state": "{\"optional\": false, \"format\": [\"f\", \"\", \"\", \"a\", \"\", \"\", \"s\", \"\", \"\", \"t\", \"\", \"\", \"a\"]}",in the tool state. That's what I used to figure out how to fix this.License
The text was updated successfully, but these errors were encountered: