Skip to content

[Translation] Update azure-ai-translation-document to 2026-03-01 API version#47837

Open
jrjrguo wants to merge 8 commits into
Azure:mainfrom
jrjrguo:translation/document-2026-03-01
Open

[Translation] Update azure-ai-translation-document to 2026-03-01 API version#47837
jrjrguo wants to merge 8 commits into
Azure:mainfrom
jrjrguo:translation/document-2026-03-01

Conversation

@jrjrguo

@jrjrguo jrjrguo commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

Updates azure-ai-translation-document to the Document Translation 2026-03-01 service API version, mirroring the .NET regeneration in Azure/azure-sdk-for-net#60219. Released as the 2.0.0 GA for Python.

Features Added

  • Custom translation model deployment name support:
    • deployment_name on TranslationTarget and as a keyword on begin_translation (batch).
    • deployment_name keyword on SingleDocumentTranslationClient.translate (single document).
    • deployment_name on DocumentStatus (the deployment used).
  • Image translation support:
    • translate_text_within_image keyword on begin_translation and translate.
    • New BatchOptions model (carries translate_text_within_image) on StartTranslationDetails.options.
    • Image-scan reporting on DocumentStatus (image_characters_detected, images_charged, total_image_scans_succeeded, total_image_scans_failed) and TranslationStatusSummary (total_image_scans_succeeded, total_image_scans_failed, total_images_charged).

Breaking Changes

  • Default service API version changed from 2024-05-01 to 2026-03-01. Pass api_version="2024-05-01" to retain the previous behavior.

Other

  • New samples (custom-model deployment + image translation, sync/async) and README updates.
  • New unit tests for the added model fields/serialization.
  • Version bumped to 2.0.0 (GA); tsp-location.yaml updated to the 2026-03-01 spec. Note: Python follows its own version line (previous GA was 1.1.0), so this is 2.0.0 rather than matching .NET's 3.0.0.

Notes for reviewers

  • Applied as a targeted delta on the existing generated + customization layer rather than a full re-emit, because the currently pinned typespec-python emitter restructures the client and would break this package's customizations. A follow-up full regeneration will require aligning the emitter with the customization layer.
  • Recorded tests will need re-recording against the service due to the api-version change (test assets).

Adds custom translation model deployment name support (deployment_name on
TranslationTarget/begin_translation, DocumentStatus, and single-document
translate) and image translation support (translate_text_within_image plus
image-scan reporting fields). Introduces the BatchOptions model, sets the
default service API version to 2026-03-01, adds samples and unit tests, and
bumps the version to 1.2.0b1.
Jiarui Guo added 5 commits July 4, 2026 17:10
… test harness

Adds deployment_name and image-translation live tests (sync + async) and the
image test document. Refactors the test storage helpers to authenticate to
Azure Storage with a token credential (DefaultAzureCredential) and pass plain
container URLs to the Document Translation service (accessed via the Translator
resource's managed identity), so tests run without account-key/shared-key
access.
…key preparer var

Lowers operation/document counts in the list_translations and
list_document_statuses tests (no tests removed, assertions unchanged) to cut
live re-recording time, and removes the now-unused DOCUMENT_TRANSLATION_STORAGE_KEY
requirement from the preparer (storage now uses Entra ID auth).
…it tests

Removes the overloaded-inputs, overloaded-single-input, and single-input-with-kwargs
live tests (which validate SDK request dispatch/serialization, not service behavior)
and re-adds them as fast unit tests over the shared get_translation_input builder.
Mirrors the .NET suite (DocumentTranslationMockTests) and trims live re-recording
time. No SDK coverage lost.
…s skip; drop obsolete unsupported-files test

- Publish re-recorded live-test sessions (assets.json -> new tag)

- Fix async test_list_document_statuses_mixed_filters (skip 3->1 for docs_count=5)

- Remove test_use_supported_and_unsupported_files (sync+async): .jpg is now a supported image format and unsupported files are no longer silently dropped under api-version 2026-03-01, so the scenario is obsolete
@jrjrguo jrjrguo marked this pull request as ready for review July 7, 2026 05:49
@jrjrguo jrjrguo requested a review from zhangeugenia as a code owner July 7, 2026 05:50
Copilot AI review requested due to automatic review settings July 7, 2026 05:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates azure-ai-translation-document to the Document Translation 2026-03-01 service API version (now the default) and releases it as the 2.0.0 GA. It surfaces two new service capabilities — custom-model deployment name routing and image translation — across the sync/async clients, models, samples, tests, and docs. The change is applied as a targeted delta on top of the generated + _patch.py customization layer rather than a full re-emit.

Changes:

  • Bumped default API version 2024-05-012026-03-01 (breaking) and version to 2.0.0; added deployment_name (on TranslationTarget, begin_translation, translate, and DocumentStatus) and translate_text_within_image support plus the new BatchOptions model and image-scan reporting fields.
  • Migrated storage-dependent tests from account-key SAS to Entra ID (DefaultAzureCredential) plain container URLs, replaced live overload/serialization tests with offline dispatch/model tests, reduced list operation counts, and added image/deployment tests.
  • Added sync + async samples and README entries for the two new features.

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.../document/_patch.py Adds deployment_name/translate_text_within_image to begin_translation + get_translation_input; new API-version enum value
.../document/aio/_patch.py Async begin_translation keywords + api-version docstring
.../document/_operations/_patch.py, aio/_operations/_patch.py translate single-doc keywords wired to request builder
.../document/_operations/_operations.py Serializes new query params; default api-version bump
.../document/models/_models.py, models/_patch.py, models/__init__.py BatchOptions, new DocumentStatus/TranslationTarget/TranslationStatusSummary fields + exports
.../document/_configuration.py, aio/_configuration.py, _client.py, aio/_client.py Default api-version → 2026-03-01
.../document/_version.py, CHANGELOG.md, tsp-location.yaml, assets.json Version 2.0.0, changelog, spec pointer, recordings tag
tests/testcase.py, preparer.py Entra-ID storage auth; drop storage-key/SAS helpers
tests/test_translation*.py, test_model_updates.py, test_list_* New deployment/image tests, offline dispatch tests, reduced counts
samples/**, samples/README.md New deployment + image translation samples (sync/async)

Comment on lines +132 to +136
options=(
BatchOptions(translate_text_within_image=translate_text_within_image)
if translate_text_within_image is not None
else None
),
# list translations - unable to assert skip!!
all_translations = client.list_translation_statuses()
all_operations_count = 0
all_operations_count = 2
Jiarui Guo added 2 commits July 7, 2026 00:32
…r batch list inputs; fix async list-skip test counter

- get_translation_input: apply BatchOptions(translate_text_within_image=...) for the List[DocumentTranslationInput] batch form (was only read on the single-URL form and silently dropped otherwise)

- Add offline regression test for the batch-form image-translation option

- Fix accidental all_operations_count init (2 -> 0) in async test_list_translations_with_skip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants