( path: string | undefined, options: DagOptions )
| 97 | type BlockMap = Map<string, BlockInfo> |
| 98 | |
| 99 | async 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 | |
| 146 | function outputDagShow( |
| 147 | dag: BlockDependencyDag, |
no test coverage detected