Skip to content

enh: sandbox client - #12

Merged
echarles merged 4 commits into
mainfrom
enh/sandbox-client
Jul 26, 2026
Merged

enh: sandbox client#12
echarles merged 4 commits into
mainfrom
enh/sandbox-client

Conversation

@echarles

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 26, 2026 10:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the sandbox “client” surface by standardizing exposure of the underlying kernel client across sandbox variants and aligning Jupyter/Docker sandboxes with the jupyter_kernel_client.JupyterKernelClient API.

Changes:

  • Switch Jupyter/Docker sandboxes from KernelClient to JupyterKernelClient.
  • Introduce ISandboxClient/IJupyterKernelClient typing protocols and add a kernel_client property to kernel-backed sandboxes (and a default None in Sandbox).
  • Export the new interfaces from code_sandboxes and bump the package version.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_jupyter.py Updates test stubs/expectations to patch JupyterKernelClient.
code_sandboxes/interfaces.py Adds typing protocols for sandbox kernel clients with optional-dependency fallback.
code_sandboxes/base.py Adds a default kernel_client property returning None for non-kernel sandboxes.
code_sandboxes/jupyter_sandbox.py Uses JupyterKernelClient, types _client, and exposes it via kernel_client.
code_sandboxes/docker_sandbox.py Uses JupyterKernelClient and exposes it via kernel_client.
code_sandboxes/colab_sandbox.py Exposes the underlying Colab client via kernel_client.
code_sandboxes/kaggle_sandbox.py Exposes the underlying Kaggle client via kernel_client.
code_sandboxes/init.py Re-exports IJupyterKernelClient and ISandboxClient.
code_sandboxes/version.py Updates the package version to 0.16.0.
Comments suppressed due to low confidence (2)

code_sandboxes/jupyter_sandbox.py:348

  • JupyterSandbox.start() now imports JupyterKernelClient directly, but pyproject.toml does not pin a minimum jupyter-kernel-client version. If a user has an older version installed that only exports KernelClient, this will raise ImportError even though the package is present. Consider a backward-compatible import fallback (or pin a minimum version).
        try:
            from jupyter_kernel_client import JupyterKernelClient
        except ImportError as exc:
            raise SandboxConfigurationError(
                "jupyter-kernel-client is required for JupyterSandbox. "
                "Install it with: pip install code-sandboxes[test]"
            ) from exc

code_sandboxes/docker_sandbox.py:133

  • DockerSandbox.start() now imports JupyterKernelClient directly, but dependencies are not version-pinned. To avoid breaking environments that have an older jupyter-kernel-client (exporting KernelClient but not JupyterKernelClient), add an import fallback (or pin a minimum version).
        self._ensure_docker()
        try:
            from jupyter_kernel_client import JupyterKernelClient
        except ImportError as exc:  # pragma: no cover - optional dependency
            raise SandboxConfigurationError(
                "jupyter-kernel-client is required for DockerSandbox. "
                "Install it with: pip install code-sandboxes"
            ) from exc

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread code_sandboxes/interfaces.py Outdated
@echarles
echarles merged commit a3f641c into main Jul 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants