enh: sandbox client - #12
Merged
Merged
Conversation
There was a problem hiding this comment.
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
KernelClienttoJupyterKernelClient. - Introduce
ISandboxClient/IJupyterKernelClienttyping protocols and add akernel_clientproperty to kernel-backed sandboxes (and a defaultNoneinSandbox). - Export the new interfaces from
code_sandboxesand 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 importsJupyterKernelClientdirectly, butpyproject.tomldoes not pin a minimumjupyter-kernel-clientversion. If a user has an older version installed that only exportsKernelClient, this will raiseImportErroreven 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 importsJupyterKernelClientdirectly, but dependencies are not version-pinned. To avoid breaking environments that have an olderjupyter-kernel-client(exportingKernelClientbut notJupyterKernelClient), 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.