Repository navigation
feat(cli): add keecas edit --sandbox for notebooks with inline dependencies - #137
Merged
Merged
Conversation
…encies A notebook declares extra packages in a PEP 723 '# /// script' block in a comment-only code cell. 'keecas edit --sandbox' parses it and relaunches itself through 'uv run --isolated --no-project' with keecas plus those dependencies, so the Jupyter server and kernel can import them. Without the flag, a notebook that declares dependencies prompts for sandbox mode (interactive terminals with uv only); --no-sandbox skips the prompt. uv stays optional: --sandbox fails with an install hint when it is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqdUYGn85WvQvuEjFX6ADn
Jupyter resolves kernels by name through its kernel directories, so a user-registered python3 kernel (with JUPYTER_PREFER_ENV_PATH=0) or a notebook naming another registered environment would run the notebook outside the sandbox, without its declared dependencies. Inside the sandbox, keecas edit now writes a temporary python3 kernelspec for sys.executable, puts it first on JUPYTER_PATH, and starts the server with KernelSpecManager.allowed_kernelspecs=python3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqdUYGn85WvQvuEjFX6ADn
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.
A notebook declares extra packages in a PEP 723 '# /// script' block in a
comment-only code cell. 'keecas edit --sandbox' parses it and relaunches
itself through 'uv run --isolated --no-project' with keecas plus those
dependencies, so the Jupyter server and kernel can import them. Without the
flag, a notebook that declares dependencies prompts for sandbox mode
(interactive terminals with uv only); --no-sandbox skips the prompt.
uv stays optional: --sandbox fails with an install hint when it is missing.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01HqdUYGn85WvQvuEjFX6ADn