Skip to content

Commit f4c254d

Browse files
authored
Merge pull request #1879 from plotly/cleaned-pmc
Delete redundancy in pattern-matching callback resolution
2 parents 8d59373 + e6889e2 commit f4c254d

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
178178
```
179179

180180
### Fixed
181+
- [#1879](https://github.com/plotly/dash/pull/1879) Delete redundancy in pattern-matching callback implementation, specifically when `ALL` and `MATCH` wildcards are used together. This patch was submitted by an anonymous Dash Enterprise customer. Many thanks!
182+
181183
- [#1858](https://github.com/plotly/dash/pull/1858) Support `mini-css-extract-plugin` Webpack plugin with `@plotly/webpack-dash-dynamic-import` node package - used by components to support dash async chunks. Updated dependencies of other `@plotly` node packages.
182184

183185
- [#1836](https://github.com/plotly/dash/pull/1836) Fix `__all__` in dcc and table for extras: dcc download helpers and table format helpers. This also restores this functionality to the obsolete top-level packages `dash_core_components` and `dash_table`.
@@ -187,7 +189,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
187189
- [#1779](https://github.com/plotly/dash/pull/1779):
188190
- Clean up our handling of serialization problems, including fixing `orjson` for Python 3.6
189191
- Added the ability for `dash.testing` `percy_snapshot` methods to choose widths to generate.
190-
192+
191193
- [#1778](https://github.com/plotly/dash/pull/1778) DataTable: Fix React warnings stating
192194
that each child in a list should have a unique "key" prop
193195

dash/dash-renderer/src/actions/dependencies.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1036,15 +1036,19 @@ function getCallbackByOutput(graphs, paths, id, prop) {
10361036
function addResolvedFromOutputs(callback, outPattern, outs, matches) {
10371037
const out0Keys = Object.keys(outPattern.id).sort();
10381038
const out0PatternVals = props(out0Keys, outPattern.id);
1039+
const foundCbIds = {};
10391040
outs.forEach(({id: outId}) => {
10401041
const outVals = props(out0Keys, outId);
1041-
matches.push(
1042-
makeResolvedCallback(
1043-
callback,
1044-
resolveDeps(out0Keys, outVals, out0PatternVals),
1045-
getAnyVals(out0PatternVals, outVals)
1046-
)
1042+
const resolved = makeResolvedCallback(
1043+
callback,
1044+
resolveDeps(out0Keys, outVals, out0PatternVals),
1045+
getAnyVals(out0PatternVals, outVals)
10471046
);
1047+
const {resolvedId} = resolved;
1048+
if (!foundCbIds[resolvedId]) {
1049+
matches.push(resolved);
1050+
foundCbIds[resolvedId] = true;
1051+
}
10481052
});
10491053
}
10501054

dash/dash-renderer/src/actions/dependencies_ts.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,23 @@ export function getPriority(
102102
callback: ICallback
103103
): string {
104104
let callbacks: ICallback[] = [callback];
105-
let touchedOutputs: {[key: string]: boolean} = {};
105+
const touchedOutputs: {[key: string]: boolean} = {};
106+
const touchedCbIds: {[key: string]: boolean} = {};
106107
const priority: number[] = [];
107108

108109
while (callbacks.length) {
110+
callbacks = filter(c => {
111+
const touched = touchedCbIds[c.resolvedId];
112+
touchedCbIds[c.resolvedId] = true;
113+
return touched;
114+
}, callbacks);
115+
109116
const outputs = filter(
110117
o => !touchedOutputs[combineIdAndProp(o)],
111118
flatten(map(cb => flatten(cb.getOutputs(paths)), callbacks))
112119
);
113120

114-
touchedOutputs = reduce(
115-
(touched, o) => assoc(combineIdAndProp(o), true, touched),
116-
touchedOutputs,
117-
outputs
118-
);
121+
outputs.forEach(o => (touchedOutputs[combineIdAndProp(o)] = true));
119122

120123
callbacks = flatten(
121124
map(

0 commit comments

Comments
 (0)