Skip to content

Commit

Permalink
🚧 WIP callback pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
eff-kay committed May 11, 2021
1 parent 5f12807 commit dbea778
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
1 change: 0 additions & 1 deletion dash-renderer/src/TreeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class BaseTreeContainer extends Component {
newProps
);

console.log("props", newProps, "old", oldProps);
if (!isEmpty(changedProps)) {
// Identify the modified props that are required for callbacks
const watchedKeys = getWatchedKeys(
Expand Down
25 changes: 12 additions & 13 deletions dash-renderer/src/actions/dependencies_ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,17 @@ export function callbackPathExists(graphs:any, paths:any, fromCallback:ICallback
))

if (!callbacks.length){
//we have reached the end of the DAG
//we have reached the end of the graph
return false;
}

// not exactly clear why this extra step was required
const matches: ICallback[] = [];
callbacks.forEach(
addAllResolvedFromOutputs(resolveDeps(), paths, matches)
);

const exists = matches.some((cb)=>{return callbackPathExists(graphs, paths, cb, toCallback)})
console.log('CALLDAG:callbackPathExists callbacks',exists);
return exists;
return matches.some((cb)=>{return callbackPathExists(graphs, paths, cb, toCallback)})
}

export function getCallbacksByInput(
Expand Down Expand Up @@ -345,15 +344,15 @@ export function includeObservers(

var validCbs = [... flattenedCbs];

//TODO: not sure if this is optimal
// for(let i=0; i<validCbs.length; i++) {
// for (let j=i+1; j<validCbs.length; j++) {
// if (callbackPathExists(graphs, paths, validCbs[i], flattenedCbs[j])) {
// //path exists remove the extra cb
// validCbs.splice(j,1);
// }
// }
// }
//TODO: not sure if this is optimal, maybe some information already exists in graphs DS
for(let i=0; i<validCbs.length; i++) {
for (let j=i+1; j<validCbs.length; j++) {
if (callbackPathExists(graphs, paths, validCbs[i], validCbs[j])) {
//path exists remove the extra cb
validCbs.splice(j,1);
}
}
}

console.log('CALLDAG:includeObservers: validCbs', validCbs);

Expand Down
12 changes: 5 additions & 7 deletions dash-renderer/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cookie from 'cookie';
import {validateCallbacksToLayout} from './dependencies';
import {includeObservers, getLayoutCallbacks} from './dependencies_ts';
import {getPath} from './paths';
import callbacks from '../reducers/callbacks';
// import callbacks from '../reducers/callbacks';

export const onError = createAction(getAction('ON_ERROR'));
export const setAppLifecycle = createAction(getAction('SET_APP_LIFECYCLE'));
Expand Down Expand Up @@ -66,12 +66,10 @@ function triggerDefaultState(dispatch, getState) {
})
);
}
let callbacks = getLayoutCallbacks(graphs, paths, layout, {
const callbacks = getLayoutCallbacks(graphs, paths, layout, {
outputsOnly: true
})

console.log('CALLDAG:triggerDefaultState getLayoutCallbacks', callbacks)

dispatch(
addRequestedCallbacks(
callbacks
Expand Down Expand Up @@ -106,11 +104,11 @@ function moveHistory(changeType) {
}

export function notifyObservers({id, props}) {
console.log(':notifyObservers, updating observers', props);
// console.log(':notifyObservers, updating observers', props);
return async function(dispatch, getState) {
const {graphs, paths} = getState();
let callbacks = includeObservers(id, props, graphs, paths)
console.log('CALLDAG: notification', callbacks)
const callbacks = includeObservers(id, props, graphs, paths)

dispatch(
addRequestedCallbacks(callbacks)
);
Expand Down

0 comments on commit dbea778

Please sign in to comment.