-
Notifications
You must be signed in to change notification settings - Fork 4
fix: migrate venv paths for cross-editor compatibility and legacy naming #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughAdds runtime validation in the toolkit installer to ensure venv paths are under the extension's globalStorageUri and throws/logs on mismatch. Environment manager now detects outdated venv paths (hash-based or stored under the wrong global storage), migrates them to an ID-based path under globalStorageUri, clears toolkitVersion, and persists changes when migrations occur. Kernel auto-selector validates a controller's interpreter path against the expected venv and disposes mismatched controllers to force recreation. Unit tests cover migration scenarios and save behavior. Sequence Diagram(s)sequenceDiagram
participant Init as Initialization
participant EnvMgr as DeepnoteEnvironmentManager
participant Installer as DeepnoteToolkitInstaller
participant Selector as DeepnoteKernelAutoSelector
rect rgb(230,240,255)
Note over Init,EnvMgr: Environment migration
Init->>EnvMgr: initEnvironments()
EnvMgr->>EnvMgr: For each env: check venvPath basename and storage prefix
alt Outdated (hash-based or wrong storage)
EnvMgr->>EnvMgr: Compute ID-based path under globalStorageUri
EnvMgr->>EnvMgr: Clear toolkitVersion
EnvMgr->>EnvMgr: Mark for save
else Up-to-date
EnvMgr->>EnvMgr: No-op
end
EnvMgr->>EnvMgr: Persist if any migrations
end
rect rgb(220,255,230)
Note over Installer: Venv validation before install
Init->>Installer: ensureVenvAndToolkit(env)
Installer->>Installer: Generate venv key and candidate path
Installer->>Installer: Log base interpreter path
Installer->>Installer: Validate candidate under globalStorageUri
alt Invalid location
Installer->>Installer: Log error and throw (cross-editor mismatch)
else Valid location
Installer->>Installer: Continue pending-install checks and install
end
end
rect rgb(255,245,215)
Note over Selector: Controller interpreter guard
Init->>Selector: ensureKernelSelectedWithConfiguration(env)
Selector->>Selector: Find existing controller for env
alt Controller found
Selector->>Selector: Compare controller.interpreterPath vs expected venv interpreter
alt Mismatch
Selector->>Selector: Dispose & remove controller -> force recreate
else Match
Selector->>Selector: Reuse controller
end
else No controller
Selector->>Selector: Create new controller
end
end
Possibly related PRs
Suggested reviewers
Pre-merge checks✅ Passed checks (2 passed)
Comment |
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts(1 hunks)src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts(2 hunks)src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts(1 hunks)src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/kernels/**/*.ts
📄 CodeRabbit inference engine (.github/instructions/kernel.instructions.md)
src/kernels/**/*.ts: Use event-driven updates (EventEmitter) for state changes
Monitor and dispose pending promises to prevent leaks during teardown
Use WeakRef/weak references for notebook/object backreferences to avoid memory leaks
Respect CancellationToken in all async operations
Files:
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.tssrc/kernels/deepnote/deepnoteToolkitInstaller.node.tssrc/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
In unit tests, when a mock is returned from a promise, ensure the mocked instance has an undefined
thenproperty to avoid hanging tests
Files:
src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
🧬 Code graph analysis (3)
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts (1)
src/platform/logging/index.ts (1)
logger(35-48)
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (1)
src/platform/logging/index.ts (1)
logger(35-48)
src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (1)
src/platform/logging/index.ts (1)
logger(35-48)
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #188 +/- ##
=====================================
Coverage 73% 73%
=====================================
Files 575 575
Lines 46923 47015 +92
Branches 5521 5527 +6
=====================================
+ Hits 34490 34572 +82
- Misses 10611 10621 +10
Partials 1822 1822
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts(2 hunks)src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/kernels/**/*.ts
📄 CodeRabbit inference engine (.github/instructions/kernel.instructions.md)
src/kernels/**/*.ts: Use event-driven updates (EventEmitter) for state changes
Monitor and dispose pending promises to prevent leaks during teardown
Use WeakRef/weak references for notebook/object backreferences to avoid memory leaks
Respect CancellationToken in all async operations
Files:
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.tssrc/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
In unit tests, when a mock is returned from a promise, ensure the mocked instance has an undefined
thenproperty to avoid hanging tests
Files:
src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
🧬 Code graph analysis (1)
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts (1)
src/platform/logging/index.ts (1)
logger(35-48)
🔇 Additional comments (4)
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts (1)
2-2: LGTM!Path module needed for basename/dirname operations in migration logic.
src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts (3)
304-336: Cross-editor storage migration test looks good.Validates VS Code→Cursor migration with a non-UUID ID, ensuring the logic works for arbitrary IDs. Regex match appropriately handles platform-specific paths.
338-405: No-op tests ensure efficiency.Both tests verify that environments with correct paths don't trigger unnecessary migrations or saves. Test 4 (custom ID) is particularly valuable—it confirms the migration logic works for any ID format, not just UUIDs.
407-452: Batch migration test validates efficiency.Confirms that multiple environments are migrated in a single pass with one save operation, not multiple saves.
src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
Show resolved
Hide resolved
src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
Show resolved
Hide resolved
| ); | ||
|
|
||
| config.venvPath = Uri.joinPath(this.context.globalStorageUri, 'deepnote-venvs', config.id); | ||
| config.toolkitVersion = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we cleaning the toolkit version?
This occurs because:
venv_*) instead of UUIDsSolution
1. Automatic Environment Migration (
deepnoteEnvironmentManager.node.ts)2. Controller Validation (
deepnoteKernelAutoSelector.node.ts)3. Path Validation (
deepnoteToolkitInstaller.node.ts)globalStorageUribefore use4. Enhanced Logging
Testing
Added comprehensive unit tests (all passing ✅):
Impact
✅ Fixes venv path errors when switching between editors
✅ Fixes compatibility issues with old extension versions
✅ Automatic migration - no user action required
✅ Clear error messages for better debugging
Summary by CodeRabbit
Bug Fixes
Tests