enh: providers - #18
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the Code Sandboxes surface around “providers” by adding a central provider/credential registry, enhancing remote-provider session behavior (Kaggle batch sessions + Kaggle live sessions + Modal stateful sessions), and standardizing the Jupyter variant name to jupyter-server across the library, CLI, docs, examples, and tests.
Changes:
- Introduces
code_sandboxes.providersto describe each provider’s requirements, availability, and environments for cataloging/UX use. - Renames the canonical Jupyter variant string from
jupytertojupyter-serverand updates call sites/docs/tests accordingly. - Adds stateful execution improvements: Modal gets a persistent “driver” process; Kaggle gets batch-session replay and an opt-in live persistent-kernel mode via a dataset “bus”.
Reviewed changes
Copilot reviewed 44 out of 44 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_sandboxes.py | Updates Jupyter variant enum expectation and sandbox class name. |
| tests/test_models.py | Updates Jupyter variant enum expectation. |
| tests/test_modal_session.py | Adds subprocess-based tests validating Modal driver session semantics. |
| tests/test_manage.py | Updates manager coverage for jupyter-server. |
| tests/test_kernel_client_compatibility.py | Adds protocol/signature compatibility tests against jupyter_kernel_client. |
| tests/test_kaggle_session.py | Adds tests for Kaggle batch session replay/sentinel trimming. |
| tests/test_kaggle_live.py | Adds end-to-end-ish tests for Kaggle live dataset bus behavior using fakes. |
| tests/test_jupyter_server.py | Renames test imports/fixtures from JupyterSandbox to JupyterServerSandbox. |
| tests/test_factory.py | Updates factory tests for the renamed Jupyter server variant/class. |
| tests/test_cli_repl.py | Updates CLI REPL tests to use jupyter-server. |
| examples/repl/Makefile | Renames jupyter target to jupyter-server; adds Kaggle live/batch GPU targets. |
| examples/repl/kaggle_sandbox_example.py | Adds KAGGLE_LIVE and KAGGLE_GPU flows and clarifies batch session behavior. |
| examples/repl/jupyter_server_sandbox_example.py | Updates example to use variant="jupyter-server". |
| examples/exec/monty_sandbox_example.py | Aligns output formatting with shared exec example helper. |
| examples/exec/modal_sandbox_example.py | Improves example output semantics and validates error-path behavior. |
| examples/exec/Makefile | Renames jupyter target to jupyter-server. |
| examples/exec/kaggle_sandbox_example.py | Improves readability by printing code first; aligns output conventions. |
| examples/exec/jupyter_server_sandbox_example.py | Renames variant to jupyter-server and updates example commentary. |
| examples/exec/google_colab_sandbox_example.py | Aligns output conventions with shared exec helper. |
| examples/exec/exec_common.py | Refactors example helper to print code + normalized results consistently. |
| examples/exec/eval_sandbox_example.py | Aligns output conventions with shared exec helper. |
| examples/exec/docker_sandbox_example.py | Aligns output conventions with shared exec helper. |
| examples/exec/datalayer_sandbox_example.py | Aligns output conventions with shared exec helper. |
| docs/docs/sandboxes/kaggle.mdx | Documents batch sessions (replay) and opt-in live mode tradeoffs. |
| docs/docs/sandboxes/jupyter-server.mdx | Updates docs to reference JupyterServerSandbox and jupyter-server variant. |
| docs/docs/sandboxes/index.mdx | Updates canonical variant list and module import examples. |
| docs/docs/index.mdx | Updates variants table to jupyter-server. |
| docs/docs/examples/index.mdx | Updates example link to jupyter server example path. |
| docs/docs/comparison/index.mdx | Updates variant list string to jupyter-server. |
| docs/docs/cli/management.mdx | Updates manager usage examples/table for jupyter-server. |
| docs/docs/cli/index.mdx | Updates CLI supported variants and variant-specific behavior section. |
| docs/docs/api-reference/index.mdx | Updates API reference to list jupyter-server as supported variant. |
| code_sandboxes/providers.py | Adds provider registry, requirement checks, availability + catalog helpers. |
| code_sandboxes/models.py | Renames SandboxVariant.JUPYTER value to jupyter-server. |
| code_sandboxes/modal_sandbox.py | Adds persistent session driver + new Modal environments; updates var get/set messaging. |
| code_sandboxes/manage.py | Renames Jupyter manager and updates manager mapping + normalization. |
| code_sandboxes/kaggle_sandbox.py | Adds batch session replay and opt-in live session mode. |
| code_sandboxes/kaggle_live.py | Adds dataset-bus transport and live agent kernel implementation. |
| code_sandboxes/kaggle_execute.py | Renames internal prefixes/slugs for code-sandbox naming consistency. |
| code_sandboxes/jupyter_server_sandbox.py | Renames class to JupyterServerSandbox and updates variant/env metadata. |
| code_sandboxes/cli.py | Updates CLI defaults and variant handling for jupyter-server. |
| code_sandboxes/base.py | Updates factory/list_environments dispatch to jupyter_server. |
| code_sandboxes/version.py | Bumps version to 1.0.10. |
| code_sandboxes/init.py | Exports JupyterServerSandbox and provider registry symbols. |
Suppressed comments (1)
code_sandboxes/base.py:387
Sandbox.list_environments()no longer recognizes the legacyvariant="jupyter"spelling after the rename tojupyter-server. If any callers still pass"jupyter"(there are in-repo examples), this will now raiseValueErrorinstead of listing the Jupyter server environments. Consider accepting both spellings here for backward compatibility.
if variant_value == "jupyter_server":
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+289
to
295
| # In one normal form, as every dispatcher here reads it: the value of | ||
| # a variant may carry a dash — `jupyter-server` — and callers type | ||
| # either spelling. | ||
| variant_value = ( | ||
| variant.value if isinstance(variant, SandboxVariant) else variant | ||
| ).replace("-", "_") | ||
|
|
Comment on lines
+559
to
+562
| else: | ||
| # Only a snippet that completed joins the session — see the batch | ||
| # path, which records under the same condition. | ||
| self._record_session(code) |
Comment on lines
+128
to
+132
| def read() -> list[SandboxEnvironment]: | ||
| from .base import Sandbox | ||
|
|
||
| return Sandbox.list_environments(variant=variant) | ||
|
|
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.