Repository navigation
PythonAppHost Code Generator - #13947
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13947Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13947" |
|
@dotnet-policy-service agree company="Microsoft" |
There was a problem hiding this comment.
Pull request overview
This is a work-in-progress PR that adds Python language support to Aspire's AppHost code generation system. It introduces a complete Python code generator with transport layer, base classes, and scaffolding support, along with necessary infrastructure changes to the CLI and type scanning system.
Changes:
- Added Python language support infrastructure (PythonLanguageSupport, PythonModuleBuilder) with scaffolding, detection, and runtime configuration for Python AppHosts
- Enhanced ATS capability scanner to track complete type hierarchies including implemented interfaces and base types, improving code generation accuracy
- Removed async callback exports (withEnvironmentCallbackAsync, withArgsCallbackAsync, withUrlsCallbackAsync) from ResourceBuilderExtensions to simplify the API surface
- Updated CLI to support Python with custom generated folder name ("aspyre") and pass-through of debug flags and additional command-line arguments
- Added comprehensive Python transport layer (_transport.py) and base classes (_base.py) with 1,300+ lines of implementation
- Updated test snapshots to reflect new type hierarchy information in generated TypeScript code
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/*.verified.txt | Updated test snapshots with ImplementedInterfaces and BaseType hierarchy information |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts | Removed async callback methods from generated TypeScript |
| tests/Aspire.Cli.Tests/Projects/DefaultLanguageDiscoveryTests.cs | Changed test case from "apphost.py" to "script.py" since apphost.py is now valid |
| src/Aspire.Hosting/ResourceBuilderExtensions.cs | Removed [AspireExport] attributes for async callback overloads |
| src/Aspire.Hosting/Ats/AtsCapabilityScanner.cs | Added CreateHandleTypeRef helper and enhanced type hierarchy collection |
| src/Aspire.Hosting/Ats/AtsCapabilityInfo.cs | Added ImplementedInterfaces and BaseType properties to AtsTypeRef |
| src/Aspire.Hosting/Aspire.Hosting.csproj | Added InternalsVisibleTo for Python code generation assemblies |
| src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs | Removed blank line (whitespace cleanup) |
| src/Aspire.Hosting.CodeGeneration.Python/* | Added complete Python code generator implementation (3 new files) |
| src/Aspire.Cli/Projects/* | Updated CLI infrastructure to support Python with custom folder names and argument passing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Exclude Azure.Sql, Foundry, and Maui from Python polyglot playground validation until Python code generation supports their current API surface. Co-authored-by: Copilot <[email protected]>
Sanitize Python identifiers derived from capability parameters and derive generic Python type names without leaking CLR assembly metadata so the Python playground validation can cover Azure.Sql, Foundry, and Maui again. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Remove the stale .modules sys.path bootstrap from the generated Python playground ValidationAppHosts so they match the shared Python scaffold, and add a regression test to keep new scaffolds importing aspire_app directly. Co-authored-by: Copilot <[email protected]>
Drop the implementation-shaped Python scaffold test and rely on the existing generated-output verification for this area. Co-authored-by: Copilot <[email protected]>
Create a Python AppHost playground that orchestrates a Redis cache, a Uvicorn-hosted Python app, and a Vite frontend that references the Python service. Co-authored-by: Copilot <[email protected]>
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Re-running the failed jobs in the CI workflow for this pull request because 2 jobs were identified as retry-safe transient failures in the CI run attempt.
|
|
🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23569697285 |
* Start porting over Python API * Merged latest changes * Update to module builder * Support recursive interface collection * Fix interfaces * Support sync and async variants * More merging * Fixed merge * Updates * Updates * Fixed generic interface * Update AspireList * Cached properties * Added resource constructors with kwargs * Fixed ABCs and list/dict registration * Fix handles and logging * Fix some tests * More test fixes * Update python lookup * Fix Python CodeGeneration build errors and update tests - Add XML documentation to AtsPythonCodeGenerator class - Remove unused 'using System.Text;' and 'using Aspire.Hosting.ApplicationModel;' directives - Update test file key from 'aspire.py' to '__init__.py' to match generator output - Update test assertions to use actual generated method names (with_env instead of with_environment) - Update verified snapshots to match new generator output * Patch files * Fix Python polyglot validation test to match scaffold output The scaffold generates 'builder.run()' but the validation test was looking for 'builder.build().run()'. Updated the grep/sed pattern to match the actual scaffold output. * Update Go, Java, and Rust CodeGeneration test snapshots Updated verified snapshots to match current scanner output after main merge. * Fix Python validation test indentation The inserted Redis code needs proper 4-space indentation to be valid inside the Python 'with' block. * Improvements to errors + rename * Regenerate snapshots * Revert fallback cast error handling * Add missing XML documentation to PythonModuleBuilder public members (microsoft#14743) * Initial plan * Add missing XML documentation to MethodParameters property and DistributedApplicationBuilder constant Co-authored-by: annatisch <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: annatisch <[email protected]> * Add comprehensive XML documentation to PythonLanguageSupport public API (microsoft#14744) * Initial plan * Add comprehensive XML documentation to PythonLanguageSupport public members Co-authored-by: annatisch <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: annatisch <[email protected]> * Add descriptive XML documentation for AtsTypeRef.ImplementedInterfaces and AtsTypeRef.BaseType (microsoft#14746) * Initial plan * Improve XML documentation for ImplementedInterfaces and BaseType on AtsTypeRef Co-authored-by: annatisch <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: annatisch <[email protected]> * Re-record tests * Remove extra project reference * Re-record tests * Re-record tests * Restructure packaging * Refactored aspire module to single file * Generate to .modules * Generate modules before installing * Support conditional ref expr * Remove additionalArgs * Tests * Renames to prevent naming conflicts * Group similar overloads * Support param defaults * Update Python codegen snapshots Accept regenerated Python snapshots after the cancellation token and process timeout fixes. Co-authored-by: Copilot <[email protected]> * Fix polyglot and CLI template validation Co-authored-by: Copilot <[email protected]> * Add Python polyglot playground validation Co-authored-by: Copilot <[email protected]> * Skip unsupported Python SDK playgrounds Exclude Azure.Sql, Foundry, and Maui from Python polyglot playground validation until Python code generation supports their current API surface. Co-authored-by: Copilot <[email protected]> * Fix Python codegen naming conflicts Sanitize Python identifiers derived from capability parameters and derive generic Python type names without leaking CLR assembly metadata so the Python playground validation can cover Azure.Sql, Foundry, and Maui again. Co-authored-by: Copilot <[email protected]> * Address PR review feedback Co-authored-by: Copilot <[email protected]> * Refresh Python playground apphosts Remove the stale .modules sys.path bootstrap from the generated Python playground ValidationAppHosts so they match the shared Python scaffold, and add a regression test to keep new scaffolds importing aspire_app directly. Co-authored-by: Copilot <[email protected]> * Remove Python scaffold assertion test Drop the implementation-shaped Python scaffold test and rely on the existing generated-output verification for this area. Co-authored-by: Copilot <[email protected]> * Add PythonAppHost playground Create a Python AppHost playground that orchestrates a Redis cache, a Uvicorn-hosted Python app, and a Vite frontend that references the Python service. Co-authored-by: Copilot <[email protected]> * Update Python codegen snapshot Co-authored-by: Copilot <[email protected]> * Fix Java validation selection Co-authored-by: Copilot <[email protected]> * Fix describe replica test Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Sebastien Ros <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
|
Warning The Documentation updates have been drafted for this PR. 📝 A draft docs PR has been opened against What was documented
|
No description provided.