Execution

Represents the result of a cell execution.

Constructors

new Execution(
   results: Result[], 
   logs: Logs, 
   error?: ExecutionError, 
   executionCount?: number): Execution
Parameters
ParameterTypeDefault valueDescription
resultsResult[][]List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots).
logsLogs...Logs printed to stdout and stderr during execution.
error?ExecutionErrorundefinedAn Error object if an error occurred, null otherwise.
executionCount?numberundefinedExecution count of the cell.
Returns

Execution

Properties

PropertyModifierTypeDefault valueDescription
error?publicExecutionErrorundefinedAn Error object if an error occurred, null otherwise.
executionCount?publicnumberundefinedExecution count of the cell.
logspublicLogsundefinedLogs printed to stdout and stderr during execution.
resultspublicResult[][]List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots).

Accessors

text

Get Signature
get text(): undefined | string

Returns the text representation of the main result of the cell.

Returns

undefined | string

Methods

toJSON()

toJSON(): object

Returns the serializable representation of the execution result.

Returns

object

NameType
errorundefined | ExecutionError
logsLogs
resultsResult[]

ExecutionError

Represents an error that occurred during the execution of a cell. The error contains the name of the error, the value of the error, and the traceback.

Constructors

new ExecutionError(
   name: string, 
   value: string, 
   traceback: string): ExecutionError
Parameters
ParameterTypeDescription
namestringName of the error.
valuestringValue of the error.
tracebackstringThe raw traceback of the error.
Returns

ExecutionError

Properties

PropertyModifierTypeDescription
namepublicstringName of the error.
tracebackpublicstringThe raw traceback of the error.
valuepublicstringValue of the error.

OutputMessage

Represents an output message from the sandbox code execution.

Constructors

new OutputMessage(
   line: string, 
   timestamp: number, 
   error: boolean): OutputMessage
Parameters
ParameterTypeDescription
linestringThe output line.
timestampnumberUnix epoch in nanoseconds.
errorbooleanWhether the output is an error.
Returns

OutputMessage

Properties

PropertyModifierTypeDescription
errorreadonlybooleanWhether the output is an error.
linereadonlystringThe output line.
timestampreadonlynumberUnix epoch in nanoseconds.

Methods

toString()

toString(): string
Returns

string


Result

Represents the data to be displayed as a result of executing a cell in a Jupyter notebook. The result is similar to the structure returned by ipython kernel: https://ipython.readthedocs.io/en/stable/development/execution.html#execution-semantics

The result can contain multiple types of data, such as text, images, plots, etc. Each type of data is represented as a string, and the result can contain multiple types of data. The display calls don't have to have text representation, for the actual result the representation is always present for the result, the other representations are always optional.

Constructors

new Result(rawData: RawData, isMainResult: boolean): Result
Parameters
ParameterType
rawDataRawData
isMainResultboolean
Returns

Result

Properties

PropertyModifierTypeDescription
chart?readonlyChartTypesContains the chart data.
data?readonlyRecord<string, unknown>Contains the data from DataFrame.
extra?readonlyanyExtra data that can be included. Not part of the standard types.
html?readonlystringHTML representation of the data.
isMainResultreadonlyboolean-
javascript?readonlystringJavaScript representation of the data.
jpeg?readonlystringJPEG representation of the data.
json?readonlystringJSON representation of the data.
latex?readonlystringLaTeX representation of the data.
markdown?readonlystringMarkdown representation of the data.
pdf?readonlystringPDF representation of the data.
png?readonlystringPNG representation of the data.
rawreadonlyRawData-
svg?readonlystringSVG representation of the data.
text?readonlystringText representation of the result.

Methods

formats()

formats(): string[]

Returns all the formats available for the result.

Returns

string[]

Array of strings representing the formats available for the result.

toJSON()

toJSON(): object

Returns the serializable representation of the result.

Returns

object

NameType
extra?any
htmlundefined | string
javascriptundefined | string
jpegundefined | string
jsonundefined | string
latexundefined | string
markdownundefined | string
pdfundefined | string
pngundefined | string
svgundefined | string
textundefined | string

Type Aliases

Logs

type Logs: object;

Data printed to stdout and stderr during execution, usually by print statements, logs, warnings, subprocesses, etc.

Type declaration

NameTypeDescription
stderrstring[]List of strings printed to stderr by prints, subprocesses, etc.
stdoutstring[]List of strings printed to stdout by prints, subprocesses, etc.

MIMEType

type MIMEType: string;

Represents a MIME type.


RawData

type RawData: object & E2BData;

Dictionary that maps MIME types to their corresponding representations of the data.

Functions

extractError()

function extractError(res: Response): Promise<undefined | SandboxError>

Parameters

ParameterType
resResponse

Returns

Promise<undefined | SandboxError>


parseOutput()

function parseOutput(
   execution: Execution, 
   line: string, 
   onStdout?: (output: OutputMessage) => any, 
   onStderr?: (output: OutputMessage) => any, 
   onResult?: (data: Result) => any, 
onError?: (error: ExecutionError) => any): Promise<void>

Parameters

ParameterType
executionExecution
linestring
onStdout?(output: OutputMessage) => any
onStderr?(output: OutputMessage) => any
onResult?(data: Result) => any
onError?(error: ExecutionError) => any

Returns

Promise<void>