Add virtual environment validation notification for Python resources#12086
Closed
Add virtual environment validation notification for Python resources#12086
Conversation
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
- Add Location property to VirtualEnvironment class to expose venv path - Add OnBeforeResourceStarted callback to check if virtual environment exists - Show error notification when venv is missing using IInteractionService - Skip check when IInteractionService is not available - Skip check when using UV environment (WithUvEnvironment) - Add comprehensive tests for notification scenarios - Link to https://aka.ms/aspire/python for documentation Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add error notification for missing virtual environment
Add virtual environment validation notification for Python resources
Oct 16, 2025
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12086Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12086" |
| }; | ||
|
|
||
| // Show notification without blocking (fire and forget) | ||
| _ = interactionService.PromptNotificationAsync(title, message, options, ct); |
Member
There was a problem hiding this comment.
@davidfowl This will create a new prompt every time the resource is started even if a prompt is already visible. If there are multiple Python resources in this state, you'll get a separate prompt for each. It seems we really want this coalescing notification capability in the core so all these integrations don't need to keep implementing it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a non-blocking error notification when a Python resource attempts to start without a virtual environment being created. This helps developers quickly identify and resolve configuration issues with Python applications in Aspire.
Changes
Virtual Environment Detection
Locationproperty toVirtualEnvironmentclass to expose the virtual environment path without requiring recalculationOnBeforeResourceStartedevent handler inPythonAppResourceBuilderExtensionsto check for virtual environment existence before Python resources startIInteractionService.IsAvailableistrue(i.e., when the dashboard is enabled)WithUvEnvironment()since UV creates the virtual environment automaticallyUser Notification
When a missing virtual environment is detected, an error notification is displayed with:
https://aka.ms/aspire/pythonfor documentation on configuring Python apps in AspireThe notification is non-blocking (fire-and-forget) to avoid preventing the resource from starting, allowing developers to see the error and take corrective action.
Example
When running a Python resource without creating the virtual environment:
The dashboard will display an error notification pointing to the missing virtual environment location, helping developers quickly understand what needs to be fixed.
Testing
Added comprehensive test coverage:
Fixes #issue_number
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.