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

Function getUpstreamBlocks

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

Source from the content-addressed store, hash-verified

114 * @param options Options for DAG generation
115 */
116export async function getUpstreamBlocks(
117 blocks: DeepnoteBlock[],
118 blocksToExecute: DeepnoteBlock[],
119 options: { pythonInterpreter?: string } = {}
120): Promise<GetUpstreamBlocksResult> {
121 try {
122 const { dag, blocksWithErrorInContentDeps, newlyComputedBlocksContentDeps } = await getDagForBlocks(blocks, {
123 acceptPartialDAG: true,
124 pythonInterpreter: options.pythonInterpreter,
125 })
126 const upstreamBlocks = getUpstreamBlocksForBlocksIds(
127 dag,
128 blocksToExecute.map(cell => cell.id)
129 )
130 // Merge the blocks we want to execute with the blocks they depend on.
131 const blocksToExecuteWithDeps = blocks.filter(
132 block => blocksToExecute.find(b => b.id === block.id) || upstreamBlocks.includes(block.id)
133 )
134
135 const status = blocksWithErrorInContentDeps.length === 0 ? 'success' : 'missing-deps'
136
137 return { status, blocksToExecuteWithDeps, newlyComputedBlocksContentDeps }
138 } catch (error) {
139 if (error instanceof DagError || error instanceof SyntaxError) {
140 return { status: 'fatal', error }
141 }
142
143 return { status: 'fatal', error: new DagError(error instanceof Error ? error.message : String(error)) }
144 }
145}

Callers 2

dag.test.tsFile · 0.90

Calls 2

getDagForBlocksFunction · 0.85

Tested by

no test coverage detected