Skip to main content

JupyterKernelInterpreter

A class for executing code strings in a Jupyter Kernel. Parameters:
  • require_confirm (bool, optional): If True, prompt user before running code strings for security. Defaults to True.
  • print_stdout (bool, optional): If True, print the standard output of the executed code. Defaults to False.
  • print_stderr (bool, optional): If True, print the standard error of the executed code. Defaults to True.

init

del

Clean up the kernel and client.

_initialize_if_needed

Initialize the kernel manager and client if they are not already initialized.

_clean_ipython_output

Remove ANSI escape sequences from the output.

_execute

Execute the code in the Jupyter kernel and return the result.

run

Executes the given code in the Jupyter kernel. Parameters:
  • code (str): The code string to execute.
  • code_type (str): The type of code to execute (e.g., ‘python’, ‘bash’). (default: obj:python)
Returns: str: A string containing the captured result of the executed code.

execute_command

Executes a shell command in the Jupyter kernel. Parameters:
  • command (str): The shell command to execute.
Returns: str: A string containing the captured result of the executed command.

supported_code_types

Returns: List[str]: Supported code types.

update_action_space

Updates the action space for the interpreter. Parameters:
  • action_space (Dict[str, Any]): A dictionary representing the new or updated action space.