Skip to content

Commit c6f9af1

Browse files
Generating document translation SDK from typespec for both single and batch translation. (#35298)
* Generated SDK from typespec latest commit ID. Added single document translation tests - sync and async. Fixed getsupportedformat tests- sync and async. * restoring dt client + models behavior * Restored async document translation operations under aio folder and validated that sync and async test cases work except for 1 failure * Skipping a test scenario that is no longer valid * Marking Single document test to run in Live mode only and uploaded test recordings to assets repo * Updated typeSpec commitID with rest-api repo. Updated test cases w.r.t removal of $, orderby and FileFormatType changes. * Fixed failing test case. Added sample test for SDT. All tests are now passing in Live and Record/playback mode, hence pushed recordings to assets repo and uupdated assets.json * Adding words to be ignored for spellcheck during builds * Fixing pylint and mypy issues * Addressing review comments on ChangeLog.md * Fixing a build error in pyproject.toml * Fixing some build failures * Fixing build error w.r.t samples * Addressing review comments * Moving the model definitions from models/_patch.py to azure/ai/translation/document/_patch.py and fixing references * Another attempt to fix sphinx errors * Fixing a test failure * Regenerating the SDK after making the models internal and updating all references. * Regenerating the SDK with DocumentTranslateContent not internal * Updating version to 1.1.0b1 * run post-processing * Fixing mypy issues * some fixes, reenable checks * verifytypes passing * remove comments * Addressing review comments * Addressing review comments * missed pushing this update to address review comments --------- Co-authored-by: Krista Pratico <[email protected]>
1 parent cd59798 commit c6f9af1

File tree

103 files changed

+8948
-6452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+8948
-6452
lines changed

.vscode/cspell.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,15 @@
17721772
"wday"
17731773
]
17741774
},
1775+
{
1776+
"filename": "sdk/translation/azure-ai-translation-document/azure/ai/translation/document/*.py",
1777+
"words": [
1778+
"mros",
1779+
"Nify",
1780+
"ctxt",
1781+
"wday"
1782+
]
1783+
},
17751784
{
17761785
"filename": "sdk/healthinsights/azure-healthinsights-radiologyinsights/**",
17771786
"words": [

sdk/translation/azure-ai-translation-document/CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Release History
22

3-
## 1.0.1 (Unreleased)
3+
## 1.1.0b1 (Unreleased)
44

55
### Features Added
6+
- Added SingleDocumentTranslationClient that is used to invoke `document_translate` API.
7+
- `document_translate` is the method added to submit a single/synchronous document translation request to the Document Translation service.
8+
- `DocumentTranslateContent` has been added to specify the `document_translate` request content.
69

710
### Breaking Changes
8-
9-
### Bugs Fixed
11+
- Version `v1.0` is not supported
1012

1113
### Other Changes
1214

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
recursive-include tests *.py
2-
recursive-include samples *.py *.md
31
include *.md
42
include LICENSE
3+
include azure/ai/translation/document/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
56
include azure/__init__.py
67
include azure/ai/__init__.py
7-
include azure/ai/translation/__init__.py
8-
include azure/ai/translation/document/py.typed
8+
include azure/ai/translation/__init__.py

sdk/translation/azure-ai-translation-document/README.md

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For
2121
## Getting started
2222

2323
### Prerequisites
24-
* Python 3.7 or later is required to use this package.
24+
* Python 3.8 or later is required to use this package.
2525
* You must have an [Azure subscription][azure_subscription] and a
2626
[Translator resource][DT_resource] to use this package.
2727

@@ -30,10 +30,10 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For
3030
Install the Azure Document Translation client library for Python with [pip][pip]:
3131

3232
```bash
33-
pip install azure-ai-translation-document
33+
pip install --pre azure-ai-translation-document
3434
```
3535

36-
> Note: This version of the client library defaults to the v1.0 version of the service
36+
> Note: This version of the client library defaults to the v2024-05-01 version of the service
3737
3838
#### Create a Translator resource
3939

@@ -179,11 +179,7 @@ poller = document_translation_client.begin_translation("<sas_url_to_source>", "<
179179
```python
180180
import os
181181
from azure.core.credentials import AzureKeyCredential
182-
from azure.ai.translation.document import (
183-
DocumentTranslationClient,
184-
DocumentTranslationInput,
185-
TranslationTarget
186-
)
182+
from azure.ai.translation.document import DocumentTranslationClient, DocumentTranslationInput, TranslationTarget
187183

188184
endpoint = os.environ["AZURE_DOCUMENT_TRANSLATION_ENDPOINT"]
189185
key = os.environ["AZURE_DOCUMENT_TRANSLATION_KEY"]
@@ -195,29 +191,19 @@ target_container_url_es = os.environ["AZURE_TARGET_CONTAINER_URL_ES"]
195191

196192
client = DocumentTranslationClient(endpoint, AzureKeyCredential(key))
197193

198-
poller = client.begin_translation(inputs=[
194+
poller = client.begin_translation(
195+
inputs=[
199196
DocumentTranslationInput(
200197
source_url=source_container_url_1,
201198
targets=[
202-
TranslationTarget(
203-
target_url=target_container_url_fr,
204-
language="fr"
205-
),
206-
TranslationTarget(
207-
target_url=target_container_url_ar,
208-
language="ar"
209-
)
210-
]
199+
TranslationTarget(target_url=target_container_url_fr, language="fr"),
200+
TranslationTarget(target_url=target_container_url_ar, language="ar"),
201+
],
211202
),
212203
DocumentTranslationInput(
213204
source_url=source_container_url_2,
214-
targets=[
215-
TranslationTarget(
216-
target_url=target_container_url_es,
217-
language="es"
218-
)
219-
]
220-
)
205+
targets=[TranslationTarget(target_url=target_container_url_es, language="es")],
206+
),
221207
]
222208
)
223209
result = poller.result()
@@ -316,11 +302,7 @@ Begin translating with documents in multiple source containers to multiple targe
316302
```python
317303
import os
318304
from azure.core.credentials import AzureKeyCredential
319-
from azure.ai.translation.document import (
320-
DocumentTranslationClient,
321-
DocumentTranslationInput,
322-
TranslationTarget
323-
)
305+
from azure.ai.translation.document import DocumentTranslationClient, DocumentTranslationInput, TranslationTarget
324306

325307
endpoint = os.environ["AZURE_DOCUMENT_TRANSLATION_ENDPOINT"]
326308
key = os.environ["AZURE_DOCUMENT_TRANSLATION_KEY"]
@@ -332,29 +314,19 @@ target_container_url_es = os.environ["AZURE_TARGET_CONTAINER_URL_ES"]
332314

333315
client = DocumentTranslationClient(endpoint, AzureKeyCredential(key))
334316

335-
poller = client.begin_translation(inputs=[
317+
poller = client.begin_translation(
318+
inputs=[
336319
DocumentTranslationInput(
337320
source_url=source_container_url_1,
338321
targets=[
339-
TranslationTarget(
340-
target_url=target_container_url_fr,
341-
language="fr"
342-
),
343-
TranslationTarget(
344-
target_url=target_container_url_ar,
345-
language="ar"
346-
)
347-
]
322+
TranslationTarget(target_url=target_container_url_fr, language="fr"),
323+
TranslationTarget(target_url=target_container_url_ar, language="ar"),
324+
],
348325
),
349326
DocumentTranslationInput(
350327
source_url=source_container_url_2,
351-
targets=[
352-
TranslationTarget(
353-
target_url=target_container_url_es,
354-
language="es"
355-
)
356-
]
357-
)
328+
targets=[TranslationTarget(target_url=target_container_url_es, language="es")],
329+
),
358330
]
359331
)
360332
result = poller.result()
@@ -391,7 +363,6 @@ Enumerate over the translation operations submitted for the resource.
391363
from azure.core.credentials import AzureKeyCredential
392364
from azure.ai.translation.document import DocumentTranslationClient
393365

394-
395366
endpoint = os.environ["AZURE_DOCUMENT_TRANSLATION_ENDPOINT"]
396367
key = os.environ["AZURE_DOCUMENT_TRANSLATION_KEY"]
397368

sdk/translation/azure-ai-translation-document/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/translation/azure-ai-translation-document",
5-
"Tag": "python/translation/azure-ai-translation-document_a26c6e3759"
5+
"Tag": "python/translation/azure-ai-translation-document_cf5e8aa525"
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,44 @@
1-
# ------------------------------------
2-
# Copyright (c) Microsoft Corporation.
3-
# Licensed under the MIT License.
4-
# ------------------------------------
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
58

9+
from ._patch import DocumentTranslationClient
10+
from ._client import SingleDocumentTranslationClient
611
from ._version import VERSION
7-
from ._client import DocumentTranslationClient
8-
from ._generated.models import (
9-
StorageInputType,
10-
)
11-
from ._api_version import DocumentTranslationApiVersion
12-
from ._polling import DocumentTranslationLROPoller
13-
from ._models import (
14-
TranslationTarget,
15-
TranslationStatus,
16-
DocumentStatus,
17-
DocumentTranslationError,
18-
TranslationGlossary,
19-
DocumentTranslationInput,
20-
DocumentTranslationFileFormat,
21-
)
2212

23-
__VERSION__ = VERSION
13+
__version__ = VERSION
2414

2515

16+
from ._patch import DocumentTranslationApiVersion
17+
from ._patch import DocumentTranslationLROPoller
18+
from ._patch import TranslationGlossary
19+
from ._patch import TranslationTarget
20+
from ._patch import DocumentTranslationInput
21+
from ._patch import TranslationStatus
22+
from ._patch import DocumentStatus
23+
from ._patch import DocumentTranslationError
24+
from ._patch import DocumentTranslationFileFormat
25+
from ._patch import StorageInputType
26+
from ._patch import patch_sdk as _patch_sdk
27+
2628
__all__ = [
27-
"DocumentTranslationClient",
2829
"DocumentTranslationApiVersion",
29-
"DocumentTranslationInput",
30+
"DocumentTranslationLROPoller",
3031
"TranslationGlossary",
31-
"StorageInputType",
32-
"DocumentTranslationFileFormat",
3332
"TranslationTarget",
33+
"DocumentTranslationInput",
3434
"TranslationStatus",
3535
"DocumentStatus",
3636
"DocumentTranslationError",
37-
"DocumentTranslationLROPoller",
37+
"DocumentTranslationFileFormat",
38+
"StorageInputType",
39+
"DocumentTranslationClient",
40+
"SingleDocumentTranslationClient",
3841
]
42+
43+
44+
_patch_sdk()

sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_api_version.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)