Commit d20f98f
committed
fix(nodes): deep copy graph inputs
The change to memory session storage brings a subtle behaviour change.
Previously, we serialized and deserialized everything (e.g. field state, invocation outputs, etc) constantly. The meant we were effectively working with deep-copied objects at all time. We could mutate objects freely without worrying about other references to the object.
With memory storage, objects are now passed around by reference, and we cannot handle them in the same way.
This is problematic for nodes that mutate their own inputs. There are two ways this causes a problem:
- An output is used as input for multiple nodes. If the first node mutates the output object while `invoke`ing, the next node will get the mutated object.
- The invocation cache stores live python objects. When a node mutates an output pulled from the cache, the next node that uses the cached object will get the mutated object.
The solution is to deep-copy a node's inputs as they are set, effectively reproducing the same behaviour as we had with the SQLite session storage. Nodes can safely mutate their inputs and those changes never leave the node's scope.
Closes #56651 parent c9c150f commit d20f98f
File tree
1 file changed
+19
-4
lines changed1 file changed
+19
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
144 | 154 | | |
145 | 155 | | |
146 | 156 | | |
| |||
1118 | 1128 | | |
1119 | 1129 | | |
1120 | 1130 | | |
| 1131 | + | |
| 1132 | + | |
1121 | 1133 | | |
1122 | 1134 | | |
1123 | | - | |
| 1135 | + | |
1124 | 1136 | | |
1125 | 1137 | | |
1126 | 1138 | | |
1127 | 1139 | | |
1128 | 1140 | | |
1129 | 1141 | | |
1130 | | - | |
1131 | | - | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1132 | 1147 | | |
1133 | 1148 | | |
1134 | 1149 | | |
| |||
0 commit comments