Skip to content

feat(toolkit): Simplify deepnote toolkit kernel management, to not use deepnote environments#376

Draft
tkislan wants to merge 3 commits intomainfrom
tk/simplify-deepnote-toolkit-kernel
Draft

feat(toolkit): Simplify deepnote toolkit kernel management, to not use deepnote environments#376
tkislan wants to merge 3 commits intomainfrom
tk/simplify-deepnote-toolkit-kernel

Conversation

@tkislan
Copy link
Copy Markdown
Contributor

@tkislan tkislan commented Apr 2, 2026

  • Enhanced the logic for clearing notebook controllers to ensure only tracked controllers are unselected.
  • Updated the clearControllerForEnvironment method to clean up associated metadata correctly.
  • Added unit tests to verify the behavior of environment configuration and controller unselection for Deepnote kernels.
  • Ensured that the system correctly handles cases where the active interpreter differs from the cached interpreter.

Summary by CodeRabbit

  • New Features

    • Streamlined Deepnote notebook setup to automatically use the active Python interpreter without manual environment selection.
  • Bug Fixes

    • Improved reliability of kernel selection and server startup by consolidating to interpreter-based tracking.
  • Documentation

    • Updated server initialization documentation to reflect active interpreter-based approach.

tkislan added 3 commits April 1, 2026 21:21
- Updated DeepnoteServerStarter to improve context management and error handling during server startup.
- Refactored cancellation token handling to ensure proper disposal and prevent memory leaks.
- Enhanced logging for notebook closure to include cleanup of associated metadata.
- Added unit tests for controller unselection logic to ensure correct behavior with Deepnote kernels.
- Enhanced the logic for clearing notebook controllers to ensure only tracked controllers are unselected.
- Updated the `clearControllerForEnvironment` method to clean up associated metadata correctly.
- Added unit tests to verify the behavior of environment configuration and controller unselection for Deepnote kernels.
- Ensured that the system correctly handles cases where the active interpreter differs from the cached interpreter.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

The PR refactors Deepnote server management from environment-based tracking to interpreter-based tracking. The DeepnoteServerStarter.startServer method signature is simplified, removing venvPath, managedVenv, additionalPackages, and environmentId parameters. Server startup now uses IInstaller instead of IDeepnoteToolkitInstaller. The DeepnoteKernelAutoSelector replaces environment selection UI with interpreter-based kernel selection, tracking notebooks by interpreter ID. Product infrastructure is extended with Product.deepnoteToolkit, including mappings in ProductNames, ProductService, and special pip installation logic. Related tests are updated accordingly.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Updates Docs ⚠️ Warning Documentation files were not updated despite significant architectural changes from environment-based to interpreter-based kernel tracking. Update specs/DEEPNOTE_KERNEL_IMPLEMENTATION.md and specs/DEBUGGING_KERNEL_MANAGEMENT.md to reflect the new interpreter-centric architecture.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: refactoring deepnote toolkit kernel management to use Python interpreters instead of deepnote environments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0%. Comparing base (eb8d457) to head (7740937).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #376   +/-   ##
===========================
===========================
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/kernels/deepnote/deepnoteServerStarter.node.ts (1)

397-401: 🧹 Nitpick | 🔵 Trivial

Parameter name mismatch.

Parameter is environmentId but caller passes interpreterId. Rename for clarity.

Rename suggestion
     private async gatherSqlIntegrationEnvVars(
         deepnoteFileUri: Uri,
-        environmentId: string,
+        interpreterId: string,
         token?: CancellationToken
     ): Promise<Record<string, string>> {

Also update the log at line 412.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/kernels/deepnote/deepnoteServerStarter.node.ts` around lines 397 - 401,
Rename the parameter environmentId to interpreterId in the method
gatherSqlIntegrationEnvVars(deepnoteFileUri: Uri, environmentId: string, token?:
CancellationToken) to match callers, update all references inside that function
to use interpreterId, and adjust the log invocation that mentions the
environment id (the log near the top of gatherSqlIntegrationEnvVars) to
reference interpreterId instead; also update any call sites that pass
interpreterId to this function to match the new parameter name if they rely on
named arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/platform/interpreter/installer/pipInstaller.node.ts`:
- Around line 18-19: The import of DEEPNOTE_TOOLKIT_VERSION in
pipInstaller.node.ts violates layering; move the DEEPNOTE_TOOLKIT_VERSION
constant out of the kernels layer into a platform-level constants file (e.g.,
create or update src/platform/interpreter/installer/constants.ts to export
DEEPNOTE_TOOLKIT_VERSION), then update the import in pipInstaller.node.ts to
import DEEPNOTE_TOOLKIT_VERSION from that new installer constants module so the
platform layer no longer depends on kernels.

---

Outside diff comments:
In `@src/kernels/deepnote/deepnoteServerStarter.node.ts`:
- Around line 397-401: Rename the parameter environmentId to interpreterId in
the method gatherSqlIntegrationEnvVars(deepnoteFileUri: Uri, environmentId:
string, token?: CancellationToken) to match callers, update all references
inside that function to use interpreterId, and adjust the log invocation that
mentions the environment id (the log near the top of
gatherSqlIntegrationEnvVars) to reference interpreterId instead; also update any
call sites that pass interpreterId to this function to match the new parameter
name if they rely on named arguments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d77ef41f-6739-4534-b695-1cdfc5c8abc0

📥 Commits

Reviewing files that changed from the base of the PR and between eb8d457 and 7740937.

📒 Files selected for processing (12)
  • src/kernels/deepnote/deepnoteServerStarter.node.ts
  • src/kernels/deepnote/deepnoteServerStarter.unit.test.ts
  • src/kernels/deepnote/types.ts
  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.unit.test.ts
  • src/platform/interpreter/installer/pipInstaller.node.ts
  • src/platform/interpreter/installer/productInstaller.node.ts
  • src/platform/interpreter/installer/productInstaller.unit.test.ts
  • src/platform/interpreter/installer/productNames.ts
  • src/platform/interpreter/installer/productService.node.ts
  • src/platform/interpreter/installer/types.ts
  • src/platform/interpreter/installer/utils.ts

Comment on lines +18 to +19
import { DEEPNOTE_TOOLKIT_VERSION } from '../../../kernels/deepnote/types';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Restricted import: platform layer importing from kernels layer.

Static analysis correctly flags this. DEEPNOTE_TOOLKIT_VERSION should live in platform (e.g., src/platform/interpreter/installer/constants.ts) or a shared location to avoid the dependency inversion.

Proposed fix

Move DEEPNOTE_TOOLKIT_VERSION to a platform-level constants file:

-import { DEEPNOTE_TOOLKIT_VERSION } from '../../../kernels/deepnote/types';
+import { DEEPNOTE_TOOLKIT_VERSION } from './constants';

Then create/update a constants file in the installer directory with the version export.

🧰 Tools
🪛 GitHub Check: Lint & Format

[failure] 18-18:
Unexpected path "../../../kernels/deepnote/types" imported in restricted zone. Importing non-platform modules into platform files is not allowed

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/platform/interpreter/installer/pipInstaller.node.ts` around lines 18 -
19, The import of DEEPNOTE_TOOLKIT_VERSION in pipInstaller.node.ts violates
layering; move the DEEPNOTE_TOOLKIT_VERSION constant out of the kernels layer
into a platform-level constants file (e.g., create or update
src/platform/interpreter/installer/constants.ts to export
DEEPNOTE_TOOLKIT_VERSION), then update the import in pipInstaller.node.ts to
import DEEPNOTE_TOOLKIT_VERSION from that new installer constants module so the
platform layer no longer depends on kernels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant