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] consider simplifying input to translation #17916

Closed
kristapratico opened this issue Apr 8, 2021 · 3 comments · Fixed by #19060
Closed

[translation] consider simplifying input to translation #17916

kristapratico opened this issue Apr 8, 2021 · 3 comments · Fixed by #19060

Comments

@kristapratico
Copy link
Member

Consult user data available and any findings from user studies to determine if we should simplify our input to create_translation_job to optimize for the use case of only one source and target.

This currently requires you to import and instantiate a few objects

    from azure.ai.translation.document import (
        DocumentTranslationClient,
        DocumentTranslationInput,
        TranslationTarget
    )

    client = DocumentTranslationClient(endpoint, AzureKeyCredential(key))

    job = client.create_translation_job(inputs=[
            DocumentTranslationInput(
                source_url=source_container_url,
                targets=[
                    TranslationTarget(
                        target_url=target_container_url,
                        language_code="es"
                    )
                ]
            )
        ]
    )

Some ideas - we could consider "overloading" the method itself or accepting additional kwargs in DocumentTranslationInput.

  1. def create_translation_job(**kwargs):
  • requires inputs. Must pass inputs if you need to pass more than one source and/or target.
  • requires source_url, target_url, and language_code along with any other optional kwargs
  1. DocumentTranslationInput takes kwargs target_url and language_code. Consider other optional kwargs. Must supply targets if planning on passing more than one target in.
@mshaban-msft
Copy link
Contributor

@kristapratico
i don't quite get it!
correct me if i'm wrong ..

so for the 1st option, it should be something like this
create_translation_job(source_url, target_url, language_code, inputs=None)

and for the 2nd option
job = client.create_translation_job(inputs=[ DocumentTranslationInput( source_url=source_container_url, target_url=target_container_url, language_code="es" ) ] )

@kristapratico
Copy link
Member Author

@mohamedshabanofficial These are just ideas... nothing concrete yet.

For the first option - might be easiest to look at this example: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_client.py#L441

L441 defines the method that the user will call. For typing, we define "overloads" that show the different sets of required params on L391 and L419. In the method we do client side validation to ensure the correct subset of required parameters are passed for either "overload". So it would be like what you wrote, but minus the inputs:

create_translation_job(source_url, target_url, language_code)

or

create_translation_job(inputs)

Second option - yes, that would be the idea. This would align closer with what .NET has too.

@kristapratico
Copy link
Member Author

Option 1 seems like the way to go.

In this case, we can probably do an overload based on number of parameters.
Three parameters, source, target, language.
Single parameter that is list-like (or enumerable), we assume that it is input jobs. (maybe call actions to align with TA?)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants