fix: detect modern Python agents for code deploy#9171
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
Pull request overview
Centralizes project-language detection and adds pyproject.toml support for Python code deployment.
Changes:
- Shares Python/.NET/Node detection across initialization and local-run flows.
- Adds regression tests for supported and unsupported projects.
- Documents the fix in the extension changelog.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
init.go |
Uses shared code-deploy detection. |
init_from_code.go |
Replaces legacy language detectors. |
init_adopt.go |
Applies shared detection during adoption. |
helpers.go |
Implements consolidated language detection. |
helpers_test.go |
Adds language-detection coverage. |
CHANGELOG.md |
Documents the Python detection fix. |
The branch is already up-to-date with |
jongio
left a comment
There was a problem hiding this comment.
Heads up on the diff scope: most of what shows in "Files changed" here isn't part of this change. The local-preflight to arm-provision rename, the telemetry event/field renames, the core CLI version bump, and the extension changelog/version bumps all come from already-merged PRs (#8844, #9163, #9182), not from this branch.
Diffed against current main, this PR is 6 files, all under extensions/azure.ai.agents/internal/cmd/:
helpers.gohelpers_test.goinit.goinit_adopt.goinit_adopt_deploymode_test.goinit_from_code.go
The PR's recorded base is 168f02a (before those merges), which is why the bot flagged an arm-provision gRPC contract break, telemetry-name breakage, and unrelated version bumps. None of those files are in the actual change, so those aren't action items on this PR. Re-syncing the base so the bot and reviewers stop re-reviewing already-merged code would help.
On the real change: the lone-.py fallback is gated by languages.python && !languages.node, and detectProjectType checks node before the standalone main.py, so a Node agent carrying an incidental helper like tools.py stays on container deploy. Recognizing pyproject.toml as a code-deploy signal is the #9123 fix.
The open items are @trangevi's two questions on helpers.go (the warning log and the conditional). Those are what need resolving before this merges.
0449907 to
5013818
Compare
jongio
left a comment
There was a problem hiding this comment.
The two items I flagged on helpers.go are now addressed in 5013818:
- The failed
os.ReadDirindetectProjectLanguageslogs a warning instead of silently returning an empty result.logis already imported. supportsCodeDeployis split out with a comment explaining that Python metadata is authoritative and a lone.pyfile only counts as a fallback when there is nopackage.json. Behavior is unchanged from the inlined condition, just readable.
The new table tests cover the node-plus-python-helper and standalone-python cases, and CI is green. The remaining unresolved threads (validation_provider, events, CHANGELOG, config_options) are outdated against the pre-rebase base and are not part of this diff anymore.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 132 out of 139 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
cli/azd/extensions/azure.ai.projects/internal/provisioning/foundry_provisioning_provider.go:157
- azd-code-reviewer:
ProjectEndpointnow recognizes anendpointsupplied through a service$ref, butResourceGroupLocationCheck.isBrownfieldFoundryProjectstill calls the non-ref-awarefoundryServiceEndpoint(resource_group_location_check.go:286). Such a project is provisioned as brownfield here but validated as greenfield, so a stale resource group in another region can incorrectly block provisioning. Use the same ref-aware endpoint resolution in the validation check.
95e9de1 to
07cee3f
Compare
jongio
left a comment
There was a problem hiding this comment.
Left one inline note on the new detection-failure warning about stdout vs stderr, so the message that explains why code deploy was not offered actually reaches the user.
jongio
left a comment
There was a problem hiding this comment.
Re-reviewed after the rebase to 07cee3f. One item from my earlier pass is still open: warnProjectInspectionFailure writes to os.Stderr, but the other user-facing warnings in this extension (init_copy.go, init_models.go) send WithWarningFormat output to stdout via fmt.Print*. This warning is what tells the user why code deploy wasn't offered and what to check, so route it to stdout instead of stderr so extension-host routing doesn't swallow it.
The rest of the actual change checks out: supportsCodeDeploy keeps a Node project with an incidental .py helper on container deploy (python && !node), Main.py no longer false-sets the python-main start command, and init_adopt.go now resolves the service path with paths.JoinAllowRoot so <project>/<service>/pyproject.toml is detected. No new issues from the rebase.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fixes: #9123
Why
The "Use the code in the current directory" flow used a separate, older language detector that did not recognize
pyproject.toml. Modern Python projects could therefore be treated as unsupported, silently routed to container deployment, and prompted for an unnecessary Azure Container Registry.What changed
pyproject.tomlas a Python code-deploy signal while preserving existingrequirements.txt,*.py, and*.csprojbehavior.Why this approach
Sharing one set of project signals prevents init and local-run behavior from drifting again. The change stays shallow and uses the selected source directory as the deployment root, avoiding false positives from nested projects whose entry point and service path would not match the chosen root.
Validation
go test ./internal/cmdgo test ./...PR extension validation
azure.ai.agentsextension and packaged it as a self-contained bundle.azd extension installinto an isolatedAZD_CONFIG_DIR;azd ai agent versionreported PR commitc68cc1106.azd ai agent,azd ai agent init --help, andazd ai agent code --helpthrough the azd host.azd ai agent init --no-prompt --deploy-mode codepath for Python code deployment. It correctly reached the extension.