-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Delete python virtual environment directory when removing deepnote environment #150
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
…ote environment Signed-off-by: Tomas Kislan <tomas@kislan.sk>
📝 WalkthroughWalkthroughDeepnoteEnvironmentManager constructor now accepts an IFileSystem dependency (imported and publicly exposed). deleteEnvironment adds Cancellation.throwIfCanceled checks and attempts to remove the venv directory via fileSystem.delete(...). Disk errors are caught: success is logged, failures emit a warning and an output message but do not fail the overall delete flow. Tests were updated to inject a mock IFileSystem that performs real deletions, create a temporary global storage dir, verify on-disk venv removal, and clean up the temp directory in teardown. Sequence DiagramsequenceDiagram
participant Caller as Caller
participant Manager as DeepnoteEnvironmentManager\n(+ IFileSystem)
participant FS as IFileSystem
Caller->>Manager: deleteEnvironment(envId, token)
Note over Manager: Pre-check cancellation
Manager->>Manager: Cancellation.throwIfCanceled(token)
Note over Manager: Existing cleanup (persistence/events)
Manager->>Manager: persistence.delete(envId)
Manager->>Manager: fire events
Note over Manager: Post-cleanup cancellation check
Manager->>Manager: Cancellation.throwIfCanceled(token)
rect rgb(220,245,225)
Note over Manager,FS: NEW — guarded disk deletion via injected IFileSystem
Manager->>FS: delete(environmentDirectory)
FS-->>Manager: success
alt delete throws
FS-->>Manager: error
Manager->>Manager: log warning & write to outputChannel
end
end
Note over Manager: Errors logged and swallowed (do not rethrow)
Manager-->>Caller: complete
Pre-merge checks✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts (2)
🔇 Additional comments (7)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #150 +/- ##
===========================
===========================
🚀 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: 4
📜 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(3 hunks)src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.node.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use
*.node.tsfor Desktop-specific implementations that require full file system access and Python environments
Files:
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Inject interfaces, not concrete classes
Avoid circular dependencies
Usel10n.t()for user-facing strings
Use typed error classes fromsrc/platform/errors/when throwing or handling errors
Use theILoggerservice instead ofconsole.log
Preserve error details while scrubbing PII in messages and telemetry
Include the Microsoft copyright header in source files
Prefer async/await and handle cancellation withCancellationToken
Files:
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.tssrc/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
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
**/!(*.node|*.web).ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Place shared cross-platform logic in common
.tsfiles (not suffixed with.nodeor.web)
Files:
src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
**/*.unit.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Place unit tests in files matching
*.unit.test.ts
Files:
src/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 (1)
src/kernels/deepnote/environments/deepnoteEnvironmentManager.node.ts (1)
35-36: IFileSystem injection added correctly.The dependency injection follows coding guidelines by injecting the interface rather than a concrete implementation.
src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
Show resolved
Hide resolved
src/kernels/deepnote/environments/deepnoteEnvironmentManager.unit.test.ts
Show resolved
Hide resolved
Signed-off-by: Tomas Kislan <tomas@kislan.sk>
…ironmentManager. Added detailed message output when deletion fails, improving debugging capabilities. Updated unit test comment for clarity. Signed-off-by: Tomas Kislan <tomas@kislan.sk>
Artmann
left a 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.
🚀
Signed-off-by: Tomas Kislan tomas@kislan.sk
Fixes #
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.