MCPcopy Index your code
hub / github.com/deepnote/deepnote / getDownstreamBlocks

Function getDownstreamBlocks

packages/reactivity/src/dag.ts:79–108  ·  view source on GitHub ↗
(
  blocks: DeepnoteBlock[],
  blocksToExecute: DeepnoteBlock[],
  options: { pythonInterpreter?: string } = {}
)

Source from the content-addressed store, hash-verified

77 * @param options Options for DAG generation
78 */
79export async function getDownstreamBlocks(
80 blocks: DeepnoteBlock[],
81 blocksToExecute: DeepnoteBlock[],
82 options: { pythonInterpreter?: string } = {}
83): Promise<GetDownstreamBlocksResult> {
84 try {
85 const { dag, blocksWithErrorInContentDeps, newlyComputedBlocksContentDeps } = await getDagForBlocks(blocks, {
86 acceptPartialDAG: true,
87 pythonInterpreter: options.pythonInterpreter,
88 })
89 const downstreamBlocks = getDownstreamBlocksForBlocksIds(
90 dag,
91 blocksToExecute.map(cell => cell.id)
92 )
93 // Merge the blocks we want to execute (input blocks) with the blocks that depend on them
94 const blocksToExecuteWithDeps = blocks.filter(
95 block => blocksToExecute.find(b => b.id === block.id) || downstreamBlocks.includes(block.id)
96 )
97
98 const status = blocksWithErrorInContentDeps.length === 0 ? 'success' : 'missing-deps'
99
100 return { status, blocksToExecuteWithDeps, newlyComputedBlocksContentDeps }
101 } catch (error) {
102 if (error instanceof DagError || error instanceof SyntaxError) {
103 return { status: 'fatal', error }
104 }
105
106 return { status: 'fatal', error: new DagError(error instanceof Error ? error.message : String(error)) }
107 }
108}
109
110/**
111 * Takes blocks, creates DAG and returns blocks that should be executed based in blocksToExecute for upstream execution.

Callers 1

dag.test.tsFile · 0.90

Calls 2

getDagForBlocksFunction · 0.85

Tested by

no test coverage detected