Skip to content

Commit c284ff0

Browse files
committed
fix: clarify kernel spec strategy
1 parent 81b5d7b commit c284ff0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

DEEPNOTE_KERNEL_IMPLEMENTATION.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This implementation adds automatic kernel selection and startup for `.deepnote`
2626
- Creates a dedicated virtual environment per `.deepnote` file
2727
- Checks if `deepnote-toolkit` is installed in the venv
2828
- Installs the toolkit and `ipykernel` from the hardcoded S3 wheel URL
29-
- **Registers a kernel spec** that points to the venv's Python interpreter
29+
- **Registers a kernel spec** using `ipykernel install --user --name deepnote-venv-<hash>` that points to the venv's Python interpreter
3030
- This ensures packages installed via `pip` are available to the kernel
3131
- Outputs installation progress to the output channel
3232
- Verifies successful installation
@@ -72,7 +72,7 @@ This implementation adds automatic kernel selection and startup for `.deepnote`
7272
- Activation service that listens for notebook open events and controller selection changes
7373
- Automatically selects Deepnote kernel for `.deepnote` files
7474
- Queries the Deepnote server for available kernel specs
75-
- **Prefers the venv kernel spec** (`deepnote-venv-<hash>`) that uses the venv's Python interpreter
75+
- **Prefers the venv kernel spec** (`deepnote-venv-<hash>`) that was registered by the installer and uses the venv's Python interpreter
7676
- This ensures the kernel uses the same environment where packages are installed
7777
- Falls back to other Python kernel specs if venv kernel not found
7878
- Registers the server with the server provider
@@ -294,13 +294,13 @@ The implementation uses VSCode's Jupyter server provider API to properly integra
294294

295295
### Kernel Spec Resolution
296296

297-
Instead of creating custom kernel specs, the implementation:
297+
The implementation uses a hybrid approach:
298298

299-
1. Connects to the running Deepnote server using `JupyterLabHelper`
300-
2. Queries the server for available kernel specs via `getKernelSpecs()`
301-
3. Selects the first Python kernel spec (or falls back to `python3-venv`)
302-
4. Uses this existing spec when creating the kernel connection metadata
303-
5. This ensures compatibility with the Deepnote server's kernel configuration
299+
1. **Registers per-venv kernel specs**: The installer registers kernel specs using `ipykernel install --user --name deepnote-venv-<hash>` that point to each venv's Python interpreter
300+
2. **Queries server for available specs**: Connects to the running Deepnote server using `JupyterLabHelper` and queries available kernel specs via `getKernelSpecs()`
301+
3. **Prefers venv kernel specs**: Looks for the registered venv kernel spec (`deepnote-venv-<hash>`) first
302+
4. **Falls back gracefully**: Falls back to other Python kernel specs (like `python3-venv`) if the venv kernel spec is not found
303+
5. **Uses server-compatible specs**: This ensures compatibility with the Deepnote server's kernel configuration while maintaining venv isolation
304304

305305
### Virtual Environment Path Handling
306306

@@ -378,8 +378,8 @@ These changes ensure that Deepnote notebooks can execute cells reliably by:
378378
**Solution**: Two-part fix:
379379
1. **Kernel spec registration** (ensures kernel uses venv Python):
380380
- Install `ipykernel` in the venv along with deepnote-toolkit
381-
- Use `python -m ipykernel install --user --name deepnote-venv-<hash>` to register a kernel spec
382-
- In the kernel selection logic, prefer the venv kernel spec (`deepnote-venv-<hash>`)
381+
- Use `python -m ipykernel install --user --name deepnote-venv-<hash>` to register a kernel spec that points to the venv's Python interpreter
382+
- In the kernel selection logic, prefer the venv kernel spec (`deepnote-venv-<hash>`) when querying the server for available specs
383383

384384
2. **Environment variable configuration** (ensures shell commands use venv Python):
385385
- When starting the Jupyter server, set environment variables:

0 commit comments

Comments
 (0)