MCPcopy
hub / github.com/deepnote/deepnote / analyzeDag

Function analyzeDag

packages/cli/src/commands/dag.ts:99–144  ·  view source on GitHub ↗
(
  path: string | undefined,
  options: DagOptions
)

Source from the content-addressed store, hash-verified

97type BlockMap = Map<string, BlockInfo>
98
99async function analyzeDag(
100 path: string | undefined,
101 options: DagOptions
102): Promise<{ dag: BlockDependencyDag; blocks: DeepnoteBlock[]; blockMap: BlockMap }> {
103 const { absolutePath } = await resolvePathToDeepnoteFile(path)
104
105 const { file: deepnoteFile, warnings } = await loadAndResolveDeepnoteFile(absolutePath)
106 emitInitResolverWarnings(warnings, options.output !== undefined)
107
108 // Collect all blocks, optionally filtering by notebook
109 const allBlocks: DeepnoteBlock[] = []
110 const blockMap: BlockMap = new Map()
111
112 for (const notebook of deepnoteFile.project.notebooks) {
113 if (options.notebook && notebook.name !== options.notebook) {
114 continue
115 }
116
117 for (const block of notebook.blocks) {
118 allBlocks.push(block)
119 blockMap.set(block.id, {
120 id: block.id,
121 label: getBlockLabel(block),
122 type: block.type,
123 notebookName: notebook.name,
124 })
125 }
126 }
127
128 if (allBlocks.length === 0) {
129 if (options.notebook) {
130 throw new Error(`No blocks found in notebook "${options.notebook}"`)
131 }
132 throw new Error('No blocks found in the project')
133 }
134
135 debug(`Analyzing ${allBlocks.length} blocks...`)
136
137 const pythonInterpreter = options.python ? await resolvePythonExecutable(options.python) : undefined
138 const { dag } = await getDagForBlocks(allBlocks, {
139 acceptPartialDAG: true,
140 pythonInterpreter,
141 })
142
143 return { dag, blocks: allBlocks, blockMap }
144}
145
146function outputDagShow(
147 dag: BlockDependencyDag,

Callers 3

createDagShowActionFunction · 0.85
createDagVarsActionFunction · 0.85

Calls 7

emitInitResolverWarningsFunction · 0.90
getBlockLabelFunction · 0.90
debugFunction · 0.90
resolvePythonExecutableFunction · 0.90
getDagForBlocksFunction · 0.90

Tested by

no test coverage detected