feat(runtimed-py): add dependency management and kernel restart#586
Merged
feat(runtimed-py): add dependency management and kernel restart#586
Conversation
Add comprehensive dependency management to runtimed-py Python bindings: - Get/add/remove UV and Conda dependencies from notebook metadata - Restart kernel with new environment configuration - Hot-install UV packages via sync_environment() without restart New methods on Session and AsyncSession: - get_uv_dependencies() / add_uv_dependency() / remove_uv_dependency() - get_conda_dependencies() / add_conda_dependency() / remove_conda_dependency() - restart_kernel(wait_for_ready=true) - sync_environment() -> SyncEnvironmentResult Dependencies stored in notebook metadata (metadata.runt.uv.dependencies etc), read/written through daemon metadata system. Exact string matching for add/remove. Kernel restart uses shutdown + start with "auto" env_source to pick up inline deps. Sync environment implements daemon protocol for hot-install (UV additions only).
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.
Summary
Add comprehensive dependency management to the runtimed-py Python bindings, enabling agents to programmatically manage notebook environments just like the frontend does.
New capabilities:
sync_environment()(UV additions only, no restart needed)Changes
New Output Type
SyncEnvironmentResult: Represents outcome of environment sync operation withsuccess,synced_packages,error, andneeds_restartfieldsNew Methods on Session and AsyncSession (8 methods each)
get_uv_dependencies()- Get current UV dependency listadd_uv_dependency(package)- Add UV dependency (exact match), returns updated listremove_uv_dependency(package)- Remove UV dependency (exact match), returns updated listget_conda_dependencies()- Get current Conda dependency listadd_conda_dependency(package)- Add Conda dependency (exact match), returns updated listremove_conda_dependency(package)- Remove Conda dependency (exact match), returns updated listrestart_kernel(wait_for_ready=true)- Shutdown kernel and start new one with "auto" environment detection (picks up inline deps)sync_environment()- Hot-install UV packages via daemon sync protocol, returnsSyncEnvironmentResultImplementation Details
Dependency management:
metadata.runt.uv.dependenciesandmetadata.runt.conda.dependenciesKernel restart:
shutdown_kernel()thenstart_kernel()with "auto" env_sourceSync environment:
Dependencies
Added
notebook-doccrate forNotebookMetadataSnapshottypes needed to read/write metadata.API Example
Test Plan
cargo check -p runtimed-pycargo fmt -p runtimed-py