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 <223556219+Copilot@users.noreply.github.com>
Exclude Azure.Sql, Foundry, and Maui from Python polyglot playground validation until Python code generation supports their current API surface. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
Drop the implementation-shaped Python scaffold test and rely on the existing generated-output verification for this area. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
|
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 <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
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 <8689453+annatisch@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: annatisch <8689453+annatisch@users.noreply.github.com> * Add comprehensive XML documentation to PythonLanguageSupport public API (microsoft#14744) * Initial plan * Add comprehensive XML documentation to PythonLanguageSupport public members Co-authored-by: annatisch <8689453+annatisch@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: annatisch <8689453+annatisch@users.noreply.github.com> * 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 <8689453+annatisch@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: annatisch <8689453+annatisch@users.noreply.github.com> * 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 <223556219+Copilot@users.noreply.github.com> * Fix polyglot and CLI template validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add Python polyglot playground validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * 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 <223556219+Copilot@users.noreply.github.com> * 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 <223556219+Copilot@users.noreply.github.com> * Address PR review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * 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 <223556219+Copilot@users.noreply.github.com> * 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 <223556219+Copilot@users.noreply.github.com> * 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 <223556219+Copilot@users.noreply.github.com> * Update Python codegen snapshot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix Java validation selection Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix describe replica test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Sebastien Ros <sebastienros@gmail.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Warning The Documentation updates have been drafted for this PR. 📝 A draft docs PR has been opened against What was documented
|
No description provided.