( dag: BlockDependencyDag, _blocks: DeepnoteBlock[], blockMap: BlockMap, options: DagOptions )
| 352 | } |
| 353 | |
| 354 | function outputDagVars( |
| 355 | dag: BlockDependencyDag, |
| 356 | _blocks: DeepnoteBlock[], |
| 357 | blockMap: BlockMap, |
| 358 | options: DagOptions |
| 359 | ): void { |
| 360 | if (options.output === 'json') { |
| 361 | outputJson({ |
| 362 | blocks: dag.nodes.map(node => ({ |
| 363 | id: node.id, |
| 364 | label: blockMap.get(node.id)?.label ?? node.id, |
| 365 | type: blockMap.get(node.id)?.type ?? 'unknown', |
| 366 | notebook: blockMap.get(node.id)?.notebookName ?? 'unknown', |
| 367 | defines: node.outputVariables, |
| 368 | uses: node.inputVariables, |
| 369 | imports: node.importedModules, |
| 370 | error: node.error, |
| 371 | })), |
| 372 | }) |
| 373 | return |
| 374 | } |
| 375 | |
| 376 | const c = getChalk() |
| 377 | |
| 378 | // Text output |
| 379 | output(`${c.bold('Variables by Block')} ${c.dim(`(${dag.nodes.length} blocks)`)}`) |
| 380 | output('') |
| 381 | |
| 382 | for (const node of dag.nodes) { |
| 383 | const info = blockMap.get(node.id) |
| 384 | const label = info?.label ?? node.id |
| 385 | |
| 386 | output(`${c.cyan(label)} ${c.dim(`(${info?.type ?? 'unknown'})`)}`) |
| 387 | |
| 388 | if (node.error) { |
| 389 | output(` ${c.red('Error:')} ${node.error.message}`) |
| 390 | } else { |
| 391 | if (node.outputVariables.length > 0) { |
| 392 | output(` ${c.green('Defines:')} ${node.outputVariables.join(', ')}`) |
| 393 | } |
| 394 | if (node.inputVariables.length > 0) { |
| 395 | output(` ${c.yellow('Uses:')} ${node.inputVariables.join(', ')}`) |
| 396 | } |
| 397 | if (node.importedModules.length > 0) { |
| 398 | output(` ${c.blue('Imports:')} ${node.importedModules.join(', ')}`) |
| 399 | } |
| 400 | if (node.outputVariables.length === 0 && node.inputVariables.length === 0 && node.importedModules.length === 0) { |
| 401 | output(c.dim(' (no variables)')) |
| 402 | } |
| 403 | } |
| 404 | output('') |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | function outputDagDownstream( |
| 409 | dag: BlockDependencyDag, |
no test coverage detected