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

Function outputDagShow

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

Source from the content-addressed store, hash-verified

144}
145
146function outputDagShow(
147 dag: BlockDependencyDag,
148 _blocks: DeepnoteBlock[],
149 blockMap: BlockMap,
150 options: DagOptions
151): void {
152 if (options.output === 'dot') {
153 outputDot(dag, blockMap)
154 return
155 }
156
157 if (options.output === 'json') {
158 outputJson({
159 nodes: dag.nodes.map(node => ({
160 id: node.id,
161 label: blockMap.get(node.id)?.label ?? node.id,
162 type: blockMap.get(node.id)?.type ?? 'unknown',
163 notebook: blockMap.get(node.id)?.notebookName ?? 'unknown',
164 order: node.order,
165 inputVariables: node.inputVariables,
166 outputVariables: node.outputVariables,
167 importedModules: node.importedModules,
168 error: node.error,
169 })),
170 edges: dag.edges.map(edge => ({
171 from: edge.from,
172 fromLabel: blockMap.get(edge.from)?.label ?? edge.from,
173 to: edge.to,
174 toLabel: blockMap.get(edge.to)?.label ?? edge.to,
175 variables: edge.inputVariables,
176 })),
177 })
178 return
179 }
180
181 const c = getChalk()
182
183 // Text output - tree style visualization
184 output(`${c.bold('Dependency Graph')} ${c.dim(`(${dag.nodes.length} blocks, ${dag.edges.length} edges)`)}`)
185 output('')
186
187 if (dag.edges.length === 0) {
188 output(c.dim('No dependencies found between blocks.'))
189 return
190 }
191
192 // Build adjacency structures
193 const childrenMap = buildChildrenMap(dag)
194 const nodeMap = buildNodeMap(dag)
195 const rootNodes = findRootNodes(dag)
196
197 // Track which nodes have been fully rendered
198 const rendered = new Set<string>()
199
200 // Render each root and its subtree
201 for (let i = 0; i < rootNodes.length; i++) {
202 const isLast = i === rootNodes.length - 1
203 renderTreeNode(rootNodes[i], '', isLast, childrenMap, nodeMap, blockMap, rendered, c)

Callers 1

createDagShowActionFunction · 0.85

Calls 8

outputJsonFunction · 0.90
getChalkFunction · 0.90
outputFunction · 0.90
outputDotFunction · 0.85
buildChildrenMapFunction · 0.85
buildNodeMapFunction · 0.85
findRootNodesFunction · 0.85
renderTreeNodeFunction · 0.85

Tested by

no test coverage detected