-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
aa8334c
b79d0ef
60cab8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { generateUuid as uuid } from '../../../platform/common/uuid'; | |
| import { IExtensionContext, IOutputChannel } from '../../../platform/common/types'; | ||
| import { IExtensionSyncActivationService } from '../../../platform/activation/types'; | ||
| import { logger } from '../../../platform/logging'; | ||
| import { IFileSystem } from '../../../platform/common/platform/types'; | ||
| import { DeepnoteEnvironmentStorage } from './deepnoteEnvironmentStorage.node'; | ||
| import { | ||
| CreateDeepnoteEnvironmentOptions, | ||
|
|
@@ -31,7 +32,8 @@ export class DeepnoteEnvironmentManager implements IExtensionSyncActivationServi | |
| @inject(DeepnoteEnvironmentStorage) private readonly storage: DeepnoteEnvironmentStorage, | ||
| @inject(IDeepnoteToolkitInstaller) private readonly toolkitInstaller: IDeepnoteToolkitInstaller, | ||
| @inject(IDeepnoteServerStarter) private readonly serverStarter: IDeepnoteServerStarter, | ||
| @inject(IOutputChannel) @named(STANDARD_OUTPUT_CHANNEL) private readonly outputChannel: IOutputChannel | ||
| @inject(IOutputChannel) @named(STANDARD_OUTPUT_CHANNEL) private readonly outputChannel: IOutputChannel, | ||
| @inject(IFileSystem) private readonly fileSystem: IFileSystem | ||
| ) {} | ||
|
|
||
| /** | ||
|
|
@@ -191,6 +193,17 @@ export class DeepnoteEnvironmentManager implements IExtensionSyncActivationServi | |
|
|
||
| Cancellation.throwIfCanceled(token); | ||
|
|
||
| // Delete the virtual environment directory from disk | ||
| try { | ||
| await this.fileSystem.delete(config.venvPath); | ||
| logger.info(`Deleted virtual environment directory: ${config.venvPath.fsPath}`); | ||
| } catch (error) { | ||
| // Log but don't fail - the directory might not exist or might already be deleted | ||
| logger.warn(`Failed to delete virtual environment directory: ${config.venvPath.fsPath}`, error); | ||
| } | ||
|
Comment on lines
208
to
215
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider implications of graceful failure. The catch block logs a warning but doesn't fail, which is reasonable for idempotency. However, if deletion consistently fails (e.g., permissions, locked files), disk space won't be reclaimed while the environment is removed from the manager's state. Consider whether this tradeoff is acceptable or if a more prominent warning to the user is warranted. 🤖 Prompt for AI Agents |
||
|
|
||
| Cancellation.throwIfCanceled(token); | ||
|
|
||
| this.environments.delete(id); | ||
| await this.persistEnvironments(); | ||
| this._onDidChangeEnvironments.fire(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.