MCPcopy
hub / github.com/deepnote/deepnote / outputDagDownstream

Function outputDagDownstream

packages/cli/src/commands/dag.ts:408–471  ·  view source on GitHub ↗
(
  dag: BlockDependencyDag,
  _blocks: DeepnoteBlock[],
  blockMap: BlockMap,
  options: DagDownstreamOptions
)

Source from the content-addressed store, hash-verified

406}
407
408function outputDagDownstream(
409 dag: BlockDependencyDag,
410 _blocks: DeepnoteBlock[],
411 blockMap: BlockMap,
412 options: DagDownstreamOptions
413): void {
414 // Find the block by ID or label
415 const blockId = findBlockId(options.block, dag.nodes, blockMap)
416
417 if (!blockId) {
418 if (options.output === 'json') {
419 outputJson({ success: false, error: `Block not found: ${options.block}` })
420 } else {
421 logError(`Block not found: ${options.block}`)
422 }
423 throw new DagHandledError(ExitCode.InvalidUsage)
424 }
425
426 const downstreamIds = getDownstreamBlocksForBlocksIds(dag, [blockId])
427 const sourceInfo = blockMap.get(blockId)
428
429 if (options.output === 'json') {
430 outputJson({
431 source: {
432 id: blockId,
433 label: sourceInfo?.label ?? blockId,
434 type: sourceInfo?.type ?? 'unknown',
435 notebook: sourceInfo?.notebookName ?? 'unknown',
436 },
437 downstream: downstreamIds.map(id => {
438 const info = blockMap.get(id)
439 return {
440 id,
441 label: info?.label ?? id,
442 type: info?.type ?? 'unknown',
443 notebook: info?.notebookName ?? 'unknown',
444 }
445 }),
446 count: downstreamIds.length,
447 })
448 return
449 }
450
451 const c = getChalk()
452
453 // Text output
454 const sourceLabel = sourceInfo?.label ?? blockId
455 output(`${c.bold('Downstream Impact')} for ${c.cyan(sourceLabel)}`)
456 output('')
457
458 if (downstreamIds.length === 0) {
459 output(c.dim('No downstream blocks depend on this block.'))
460 return
461 }
462
463 output(`${c.yellow(downstreamIds.length)} block${downstreamIds.length === 1 ? '' : 's'} will need to re-run:`)
464 output('')
465

Callers 1

Calls 5

outputJsonFunction · 0.90
getChalkFunction · 0.90
outputFunction · 0.90
findBlockIdFunction · 0.85

Tested by

no test coverage detected