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

Function maybeOpenRunResultInCloud

packages/cli/src/commands/run.ts:1382–1437  ·  view source on GitHub ↗
({
  absolutePath,
  convertedFile,
  file,
  isMachineOutput,
  options,
  summary,
}: {
  absolutePath: string
  convertedFile: LoadedRunnableFile
  file: DeepnoteFile
  isMachineOutput: boolean
  options: RunOptions
  summary: ExecutionSummary
})

Source from the content-addressed store, hash-verified

1380}
1381
1382async function maybeOpenRunResultInCloud({
1383 absolutePath,
1384 convertedFile,
1385 file,
1386 isMachineOutput,
1387 options,
1388 summary,
1389}: {
1390 absolutePath: string
1391 convertedFile: LoadedRunnableFile
1392 file: DeepnoteFile
1393 isMachineOutput: boolean
1394 options: RunOptions
1395 summary: ExecutionSummary
1396}): Promise<void> {
1397 if (!options.open || summary.failedBlocks > 0) {
1398 return
1399 }
1400
1401 let fileToOpen = absolutePath
1402 let tempFile: string | null = null
1403
1404 if (convertedFile.wasConverted) {
1405 const tempDir = await fs.mkdtemp(join(os.tmpdir(), 'deepnote-run-'))
1406 const rawName = file.project.name || 'project'
1407 const safeName = rawName.replace(/[/\\]/g, '_').replace(/\.\./g, '_').replace(/^\.+/, '') || 'project'
1408 tempFile = join(tempDir, `${safeName}.deepnote`)
1409 const yamlContent = serializeDeepnoteFile(file)
1410 await fs.writeFile(tempFile, yamlContent, 'utf-8')
1411 fileToOpen = tempFile
1412 debug(`Created temp file for upload: ${tempFile}`)
1413 }
1414
1415 try {
1416 const c = getChalk()
1417 if (!isMachineOutput) {
1418 output('')
1419 }
1420 const result = await openDeepnoteFileInCloud(fileToOpen, { quiet: isMachineOutput })
1421 if (!isMachineOutput) {
1422 output(`${c.green('✓')} Opened in Deepnote Cloud`)
1423 output(`${c.dim('URL:')} ${result.url}`)
1424 }
1425 } finally {
1426 if (tempFile) {
1427 try {
1428 await fs.rm(dirname(tempFile), { recursive: true })
1429 debug(`Cleaned up temp directory: ${dirname(tempFile)}`)
1430 } catch (cleanupError) {
1431 debug(
1432 `Failed to clean up temp directory ${dirname(tempFile)}: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`
1433 )
1434 }
1435 }
1436 }
1437}

Callers 1

runDeepnoteProjectFunction · 0.85

Calls 5

serializeDeepnoteFileFunction · 0.90
debugFunction · 0.90
getChalkFunction · 0.90
outputFunction · 0.90
openDeepnoteFileInCloudFunction · 0.90

Tested by

no test coverage detected