Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[translation] simplify input to translation #19060

Merged
merged 15 commits into from
Jun 3, 2021

Conversation

kristapratico
Copy link
Member

@kristapratico kristapratico commented Jun 3, 2021

@kristapratico kristapratico marked this pull request as ready for review June 3, 2021 15:46
)
]
except (AttributeError, TypeError, IndexError):
raise ValueError("Pass either 'inputs' or 'source_url', 'target_url', and 'target_language_code'")
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit: in the response you can say pass "inputs" for multiple inputs, or these for single

@@ -118,8 +146,41 @@ async def begin_translation(
:caption: Translate the documents in your storage container.
"""

continuation_token = kwargs.pop("continuation_token", None)

try:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since this code is the same, can you decompose into a helper?

)
]
document_translation_client = DocumentTranslationClient("<endpoint>", AzureKeyCredential("<api_key>"))
poller = document_translation_client.begin_translation("<sas_url_to_source>", "<sas_url_to_target", "fr")
Copy link
Member

Choose a reason for hiding this comment

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

nit: do you think it is worth creating a variable language_code="fr" and then use that variable so the user understands what fr is? or maybe just follow the same pattern you have and do <language_code>

Copy link
Member

Choose a reason for hiding this comment

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

saw we do this in .NET too. If you agree I can create an issue for .NET. If you think it is not important will leave as is :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I was trying to demonstrate that these can be passed positionally. I think I'll update to "<target_language_code>" here to be consistent. Thanks for pointing that out!

source_container_sas_url_en = "<sas-url-en>"
target_container_sas_url_es = "<sas-url-es>"
target_container_sas_url_fr = "<sas-url-fr>"
target_container_sas_url_ar = "<sas-url-fr>"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
target_container_sas_url_ar = "<sas-url-fr>"
target_container_sas_url_ar = "<sas-url-ar>"

@kristapratico kristapratico merged commit 338c6a9 into Azure:master Jun 3, 2021
@kristapratico kristapratico deleted the overload-input branch June 3, 2021 21:29
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.

[translation] consider simplifying input to translation
3 participants