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

Function listInputs

packages/cli/src/commands/run.ts:669–711  ·  view source on GitHub ↗

* List all input blocks in a notebook file. * Supports .deepnote, .ipynb, .py, and .qmd formats. * For native `.deepnote` files, the sibling init notebook is composed in so its inputs are listed as a prelude.

(path: string, options: RunOptions)

Source from the content-addressed store, hash-verified

667 * For native `.deepnote` files, the sibling init notebook is composed in so its inputs are listed as a prelude.
668 */
669async function listInputs(path: string, options: RunOptions): Promise<void> {
670 const isMachineOutput = options.output !== undefined
671 const converted = await resolveAndConvertToDeepnote(path)
672 const { originalPath: absolutePath } = converted
673 const resolved = await resolveAndComposeInitIfNeeded(converted)
674 const file = resolved.file
675 emitInitResolverWarnings(resolved.warnings, isMachineOutput)
676
677 const inputs = getInputBlocks(file, options.notebook)
678
679 if (options.output === 'json') {
680 outputJson({
681 path: absolutePath,
682 inputs: inputs.map(i => ({
683 variableName: i.variableName,
684 type: i.type,
685 label: i.label,
686 currentValue: i.currentValue,
687 hasValue: i.hasValue,
688 })),
689 })
690 return
691 }
692
693 const c = getChalk()
694
695 if (inputs.length === 0) {
696 output(c.dim('No input blocks found.'))
697 return
698 }
699
700 output(c.bold('Input variables:'))
701 output('')
702 for (const input of inputs) {
703 const typeLabel = c.dim(`(${input.type})`)
704 const valueStr = input.hasValue ? c.green(JSON.stringify(input.currentValue)) : c.yellow('(no value)')
705 const labelStr = input.label ? ` - ${input.label}` : ''
706 output(` ${c.cyan(input.variableName)} ${typeLabel}${labelStr}`)
707 output(` Current value: ${valueStr}`)
708 }
709 output('')
710 output(c.dim('Use --input <name>=<value> to set values before running.'))
711}
712
713/**
714 * Perform a dry run: parse the file and show what would be executed without running.

Callers 1

createRunActionFunction · 0.85

Calls 7

emitInitResolverWarningsFunction · 0.90
outputJsonFunction · 0.90
getChalkFunction · 0.90
outputFunction · 0.90
getInputBlocksFunction · 0.85

Tested by

no test coverage detected