Azure / Azure/azure-sdk-for-python

Polling for document intelligence batch analysis result is broken

Open
#47,972 3 comments 13 reactions 1 assignee Claimed by @bojunehsu View on GitHub
Client customer-reported Document Intelligence needs-team-attention question
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

Description

- **package: azure-ai-documentintelligence**:
- **version: 1.0.2**:
- **os: macOS Tahoe 26.5.2**:
- **Python Version 3.11.11**:

**Describe the bug**
I am setting up a batch request to azure document intelligence using the async interface like the following and saving the continuation token.
```python
batch_request = AnalyzeBatchDocumentsRequest(
azure_blob_source=azure_blob_source,
result_container_url=container_url_with_sas,
result_prefix=result_prefix,
overwrite_existing=True,
)

poller = await self._document_intelligence_client.begin_analyze_batch_documents("prebuilt-layout", batch_request, locale="en")

continuation_token = poller.continuation_token()
```
Then in a queue I poll the job using the previously saved continuation token and print out all the statuses.
```python
poller = await self._document_intelligence_client.get_analyze_batch_result(continuation_token)
print(f"Poller done: {poller.done()}")
print(f"Poller status: {poller.status()}")

result: AnalyzeBatchResult = await poller.result()
print(f"Poller succeeded count: {result.succeeded_count}")
print(f"Poller failed count: {result.failed_count}")
print(f"Poller skipped count: {result.skipped_count}")
```
However even when the result is present, and therefore the analysis job is completed, the done() still returns False and status() still says InProgress.
```
Poller done: False
Poller status: InProgress
Poller succeeded count: 5
Poller failed count: 0
Poller skipped count: 0
```

**To Reproduce**
Steps to reproduce the behavior:
1. Create a begin_analyze_batch_documents request
2. Save the continuation token
3. Run poller.done() and poller.status(), poller.done() will be false and poller.status() will be InProgress even after the images have finished transcribing. poller.result() will return the successful files even when the other two method claim it isn't complete.

**Expected behavior**
I expect to be able to kick off a batch process and poll it for being done and once it is complete then get the result rather than having to call the blocking result() method and waiting.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.