MCPcopy Create free account
hub / github.com/plotly/dash / validateDependencies

Function validateDependencies

dash/dash-renderer/src/actions/dependencies.js:212–284  ·  view source on GitHub ↗
(parsedDependencies, dispatchError)

Source from the content-addressed store, hash-verified

210}
211
212function validateDependencies(parsedDependencies, dispatchError) {
213 const outStrs = {};
214 const outObjs = [];
215
216 parsedDependencies.forEach(dep => {
217 const {inputs, outputs, state} = dep;
218 let hasOutputs = true;
219 if (outputs.length === 1 && !outputs[0].id && !outputs[0].property) {
220 hasOutputs = false;
221 }
222
223 const head =
224 'In the callback for output(s):\n ' +
225 outputs.map(combineIdAndProp).join('\n ');
226
227 if (!inputs.length && dep.prevent_initial_call) {
228 dispatchError('A callback is missing Inputs', [
229 head,
230 'there are no `Input` elements.',
231 'Without `Input` elements, it will never get called.',
232 '',
233 'Subscribing to `Input` components will cause the',
234 'callback to be called whenever their values change.',
235 '',
236 'If you want a callback without inputs that fires on initial load,',
237 'set prevent_initial_call=False.'
238 ]);
239 }
240
241 const spec = [
242 [outputs, 'Output'],
243 [inputs, 'Input'],
244 [state, 'State']
245 ];
246 spec.forEach(([args, cls]) => {
247 if (cls === 'Output' && !hasOutputs) {
248 // just a quirk of how we pass & parse outputs - if you don't
249 // provide one, it looks like a single blank output. This is
250 // actually useful for graceful failure, so we work around it.
251 return;
252 }
253
254 if (!Array.isArray(args)) {
255 dispatchError(`Callback ${cls}(s) must be an Array`, [
256 head,
257 `For ${cls}(s) we found:`,
258 JSON.stringify(args),
259 'but we expected an Array.'
260 ]);
261 }
262 args.forEach((idProp, i) => {
263 validateArg(idProp, head, cls, i, dispatchError);
264 });
265 });
266
267 if (hasOutputs) {
268 findDuplicateOutputs(
269 outputs,

Callers 1

computeGraphsFunction · 0.85

Calls 4

validateArgFunction · 0.85
findDuplicateOutputsFunction · 0.85
findMismatchedWildcardsFunction · 0.85
dispatchErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…