MCPcopy
hub / github.com/deepnote/deepnote / runProject

Method runProject

packages/runtime-core/src/execution-engine.ts:159–426  ·  view source on GitHub ↗

* Run a parsed DeepnoteFile.

(file: DeepnoteFile, options: ExecutionOptions = {})

Source from the content-addressed store, hash-verified

157 * Run a parsed DeepnoteFile.
158 */
159 async runProject(file: DeepnoteFile, options: ExecutionOptions = {}): Promise<ExecutionSummary> {
160 const kernel = this.kernel
161 if (kernel == null) {
162 throw new Error('Engine not started. Call start() first.')
163 }
164
165 // Inject input values before execution
166 if (options.inputs && Object.keys(options.inputs).length > 0) {
167 await this.injectInputs(options.inputs)
168 }
169
170 const startTime = Date.now()
171 let executedBlocks = 0
172 let failedBlocks = 0
173
174 // Filter notebooks if specified
175 const notebooks = options.notebookName
176 ? file.project.notebooks.filter(n => n.name === options.notebookName)
177 : file.project.notebooks
178
179 if (options.notebookName && notebooks.length === 0) {
180 throw new Error(`Notebook "${options.notebookName}" not found in project`)
181 }
182
183 // Build block ID filter set: blockIds takes precedence over blockId
184 const blockIdFilter = options.blockIds
185 ? new Set(options.blockIds)
186 : options.blockId
187 ? new Set([options.blockId])
188 : null
189
190 // Collect all executable blocks, tracking their notebook and position
191 const allExecutableBlocks: Array<{
192 block: DeepnoteBlock
193 notebookName: string
194 notebookIndex: number
195 }> = []
196 for (const notebook of notebooks) {
197 const sortedBlocks = this.sortBlocks(notebook.blocks)
198 for (const block of sortedBlocks) {
199 if (isExecutableBlock(block)) {
200 if (blockIdFilter && !blockIdFilter.has(block.id)) {
201 continue
202 }
203 allExecutableBlocks.push({
204 block,
205 notebookName: notebook.name,
206 notebookIndex: file.project.notebooks.indexOf(notebook),
207 })
208 }
209 }
210 }
211
212 // Validate blockIds when the filter yields no executable blocks.
213 if (options.blockIds && allExecutableBlocks.length === 0 && options.blockIds.length > 0) {
214 for (const blockId of options.blockIds) {
215 this.assertExecutableBlockExists(blockId, notebooks)
216 }

Callers 5

runDeepnoteProjectFunction · 0.95
handleRunFunction · 0.95
handleRunBlockFunction · 0.95
runFileMethod · 0.95

Calls 10

injectInputsMethod · 0.95
sortBlocksMethod · 0.95
isExecutableBlockFunction · 0.90
isAgentBlockFunction · 0.90
serializeNotebookContextFunction · 0.90
executeAgentBlockFunction · 0.90
createPythonCodeFunction · 0.90
createErrorOutputFunction · 0.85
executeMethod · 0.80

Tested by

no test coverage detected