[ContentUnderstanding] Expose usage property on AnalyzeLROPoller#46278
Open
chienyuanchang wants to merge 16 commits intomainfrom
Open
[ContentUnderstanding] Expose usage property on AnalyzeLROPoller#46278chienyuanchang wants to merge 16 commits intomainfrom
chienyuanchang wants to merge 16 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Exposes the Content Understanding analyze LRO response envelope’s usage field via a new usage property on the custom sync/async analyze pollers, and updates samples/tests to demonstrate and validate the new surface area.
Changes:
- Added
usageproperty toAnalyzeLROPollerandAnalyzeAsyncLROPoller, deserializing intoUsageDetails. - Updated sync/async invoice samples (and sample tests) to show how to read
poller.usageafter completion. - Added/updated unit + recorded tests and bumped package version/docs/changelog for the fix.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/contentunderstanding/azure-ai-contentunderstanding/azure/ai/contentunderstanding/models/_patch.py | Adds sync poller .usage property reading/deserializing usage from final polling response. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/azure/ai/contentunderstanding/aio/models/_patch.py | Adds async poller .usage property reading/deserializing usage from final polling response. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/tests/test_analyzer_operation_id.py | Adds unit tests for usage deserialization and missing usage scenarios. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/tests/test_helpers.py | Adds shared helper assertion for .usage presence on completed pollers. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/tests/test_content_understanding_content_analyzers_operations.py | Adds recorded-test assertions that .usage is available after analyze completes (sync). |
| sdk/contentunderstanding/azure-ai-contentunderstanding/tests/test_content_understanding_content_analyzers_operations_async.py | Adds recorded-test assertions that .usage is available after analyze completes (async). |
| sdk/contentunderstanding/azure-ai-contentunderstanding/samples/sample_analyze_invoice.py | Adds snippet showing how to access/print .usage in sync sample. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/samples/async_samples/sample_analyze_invoice_async.py | Adds snippet showing how to access/print .usage in async sample. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/tests/samples/test_sample_analyze_invoice.py | Adds sample test assertions validating .usage is present and has expected metrics (sync). |
| sdk/contentunderstanding/azure-ai-contentunderstanding/tests/samples/test_sample_analyze_invoice_async.py | Adds sample test assertions validating .usage is present and has expected metrics (async). |
| sdk/contentunderstanding/azure-ai-contentunderstanding/samples/README.md | Notes usage access as part of the invoice sample coverage. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/azure/ai/contentunderstanding/_version.py | Bumps package version to 1.0.2. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/README.md | Updates SDK↔service API version mapping table with 1.0.2. |
| sdk/contentunderstanding/azure-ai-contentunderstanding/CHANGELOG.md | Adds 1.0.2 changelog entry describing the fix. |
...ntunderstanding/azure-ai-contentunderstanding/azure/ai/contentunderstanding/models/_patch.py
Outdated
Show resolved
Hide resolved
...derstanding/azure-ai-contentunderstanding/azure/ai/contentunderstanding/aio/models/_patch.py
Outdated
Show resolved
Hide resolved
sdk/contentunderstanding/azure-ai-contentunderstanding/tests/test_analyzer_operation_id.py
Outdated
Show resolved
Hide resolved
sdk/contentunderstanding/azure-ai-contentunderstanding/samples/sample_analyze_invoice.py
Outdated
Show resolved
Hide resolved
...standing/azure-ai-contentunderstanding/samples/async_samples/sample_analyze_invoice_async.py
Outdated
Show resolved
Hide resolved
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
...derstanding/azure-ai-contentunderstanding/azure/ai/contentunderstanding/aio/models/_patch.py
Outdated
Show resolved
Hide resolved
...standing/azure-ai-contentunderstanding/samples/async_samples/sample_analyze_invoice_async.py
Outdated
Show resolved
Hide resolved
yungshinlintw
approved these changes
Apr 14, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #46249
The Content Understanding REST API returns a
usagefield as a sibling ofresultin the LRO response envelope (ContentAnalyzerAnalyzeOperationStatus). The generatedget_long_running_outputcallback only extracts theresultfield, discardingusage. This PR adds ausageproperty to bothAnalyzeLROPoller(sync) andAnalyzeAsyncLROPoller(async) that reads the usage data directly from the final polling response and deserializes it into aUsageDetailsmodel.Changes
Bug fix
models/_patch.py/aio/models/_patch.py: Addedusageproperty toAnalyzeLROPollerandAnalyzeAsyncLROPoller. The property readsusagefrom the final HTTP response JSON and deserializes it intoUsageDetails. ReturnsNoneif unavailable.Samples
samples/sample_analyze_invoice.py/samples/async_samples/sample_analyze_invoice_async.py: Added# [START get_usage]/# [END get_usage]snippet demonstrating how to access billing and token consumption details after analysis completes.Tests
tests/test_analyzer_operation_id.py: AddedTestAnalyzeLROPollerUsagewith 4 unit tests covering usage deserialization, missing usage, and malformed response handling.tests/test_helpers.py: Addedassert_analyze_poller_usage()shared helper for live/recorded test assertions.tests/test_content_understanding_content_analyzers_operations.py: Added usage assertions to 3 sync recorded tests.tests/test_content_understanding_content_analyzers_operations_async.py: Added usage assertions to 3 async recorded tests.tests/samples/test_sample_analyze_invoice.py/test_sample_analyze_invoice_async.py: Added usage assertions to sample tests.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines