MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / executeSilently

Function executeSilently

src/kernels/helpers.ts:656–748  ·  view source on GitHub ↗
(
    kernelConnection: Kernel.IKernelConnection,
    code: string,
    errorOptions?: SilentExecutionErrorOptions
)

Source from the content-addressed store, hash-verified

654};
655
656export async function executeSilently(
657 kernelConnection: Kernel.IKernelConnection,
658 code: string,
659 errorOptions?: SilentExecutionErrorOptions
660): Promise<nbformat.IOutput[]> {
661 logger.trace(
662 `Executing silently Code (${kernelConnection.status}) = ${splitLines(code.substring(0, 100)).join('\\n')}`
663 );
664
665 const request = kernelConnection.requestExecute(
666 {
667 code: code.replace(/\r\n/g, '\n'),
668 silent: false,
669 stop_on_error: false,
670 allow_stdin: true,
671 store_history: false
672 },
673 true
674 );
675 const outputs: nbformat.IOutput[] = [];
676 request.onIOPub = (msg) => {
677 if (jupyterLab.KernelMessage.isStreamMsg(msg)) {
678 logger.ci(`Got io pub message (stream), ${splitLines(msg.content.text.substr(0, 100)).join('\\n')}`);
679 if (
680 outputs.length > 0 &&
681 outputs[outputs.length - 1].output_type === 'stream' &&
682 outputs[outputs.length - 1].name === msg.content.name
683 ) {
684 const streamOutput = outputs[outputs.length - 1] as nbformat.IStream;
685 streamOutput.text += msg.content.text;
686 } else {
687 const streamOutput: nbformat.IStream = {
688 name: msg.content.name,
689 text: msg.content.text,
690 output_type: 'stream'
691 };
692 outputs.push(streamOutput);
693 }
694 } else if (jupyterLab.KernelMessage.isExecuteResultMsg(msg)) {
695 logger.ci(`Got io pub message (execresult)}`);
696 const output: nbformat.IExecuteResult = {
697 data: msg.content.data,
698 execution_count: msg.content.execution_count,
699 metadata: msg.content.metadata,
700 output_type: 'execute_result'
701 };
702 outputs.push(output);
703 } else if (jupyterLab.KernelMessage.isDisplayDataMsg(msg)) {
704 logger.ci(`Got io pub message (displaydata)}`);
705 const output: nbformat.IDisplayData = {
706 data: msg.content.data,
707 metadata: msg.content.metadata,
708 output_type: 'display_data'
709 };
710 outputs.push(output);
711 } else if (jupyterLab.KernelMessage.isErrorMsg(msg)) {
712 logger.ci(
713 `Got io pub message (error), ${msg.content.ename},${msg.content.evalue}, ${msg.content.traceback

Callers 15

deleteDumpedFilesFunction · 0.90
executeCommandMethod · 0.90
getCWDMethod · 0.90
safeExecuteSilentlyFunction · 0.90
api.vscode.test.tsFile · 0.90
executeHiddenMethod · 0.90
executeSilentlyFunction · 0.90
enableMethod · 0.90
disableMethod · 0.90
startDebugSessionMethod · 0.90

Calls 9

splitLinesFunction · 0.90
joinMethod · 0.80
traceMethod · 0.65
ciMethod · 0.65
pushMethod · 0.65
errorMethod · 0.65
requestExecuteMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected