-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Dt use patch #36977
base: main
Are you sure you want to change the base?
Dt use patch #36977
Conversation
...ation/azure-ai-translation-document/azure/ai/translation/document/_operations/_operations.py
Show resolved
Hide resolved
API change check APIView has identified API level changes in this PR and created following API reviews. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kristapratico can you open a draft pr for your typespec changes as well? I had a few comments about the changes.
...ation/azure-ai-translation-document/azure/ai/translation/document/_operations/_operations.py
Show resolved
Hide resolved
...ranslation/azure-ai-translation-document/azure/ai/translation/document/_operations/_patch.py
Show resolved
Hide resolved
sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_patch.py
Show resolved
Hide resolved
sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_patch.py
Outdated
Show resolved
Hide resolved
sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_patch.py
Show resolved
Hide resolved
...ranslation/azure-ai-translation-document/azure/ai/translation/document/_operations/_patch.py
Show resolved
Hide resolved
sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_patch.py
Show resolved
Hide resolved
@distributed_trace | ||
def get_document_status(self, translation_id: str, document_id: str, **kwargs: Any) -> DocumentStatus: | ||
def get_document_status( # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the generated client expose this method? And if so, do we still need to patch it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to rename the parameter id
to translation_id
in the GA version. I was told that with the way that id
is defined in the typespec, it does not allow us to rename it in the client.tsp.
The following did not work:
@@clientName(DocumentTranslationClient.getDocumentStatus::parameters.id,
"translation_id",
"python"
);
Let me know if you know a way! Would be great to not have to patch this, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see...yes that is an unfortunate limitation we've been dealing with, but since I think it's more noise to patch in a client library instead of just using the @clientName
decorator, I'd say just use the decorator over the typespec property inline in the code. And make sure to specify Python if it's the only language that renamed it.
@distributed_trace_async | ||
async def get_translation_status(self, translation_id: str, **kwargs: Any) -> TranslationStatus: | ||
async def get_translation_status(self, translation_id: str, **kwargs: Any) -> TranslationStatus: # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we specify the type suppression? I'm guessing it has something to do with the method signature differing from the inherited method.
async def get_translation_status(self, translation_id: str, **kwargs: Any) -> TranslationStatus: # type: ignore | |
async def get_translation_status(self, translation_id: str, **kwargs: Any) -> TranslationStatus: # type: ignore[...] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your guess is correct - I will add the error type for all instances.
@@ -30,9 +30,9 @@ class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): | |||
"""Succeeded""" | |||
FAILED = "Failed" | |||
"""Failed""" | |||
CANCELLED = "Cancelled" | |||
CANCELED = "Cancelled" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we changed this? (Assuming it was public. If it's not public I guess it doesn't matter so much....)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't expose this in the GA version, nor the last beta. It is public by default for the current version that leverages the codegen models.
The reason I renamed the statuses here was to have consistency throughout the library. In the GA version, we decided we were against "cancelled" with a double l
(don't ask me why, I don't remember 😆) and have a conversion function that changes any double l
cancel to a single l
in the response.
@@ -463,8 +463,8 @@ def callback(request): | |||
assert input.source.filter.prefix == "" | |||
assert input.source.filter.suffix == ".txt" | |||
assert input.storage_type == "File" | |||
assert input.targets[0].category == "fake" | |||
assert input.targets[0].glossaries[0].format == "txt" | |||
assert input.targets[0].category_id == "fake" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two attributes here are breaking API changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it seems in the APIview diff that these two properties were always called category_id
and file_format
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it's a bit confusing - we renamed a lot of things in the GA version of this library. StartTranslationDetails
(the type we're accessing here) was not exposed in the GA library. We didn't expose this in the beta release following the GA either, but it was used here in a test to verify deserialization.
In this PR, we make StartTranslationDetails public, as another input option to begin_translation. To be consistent with the renaming we did in the GA library, I've renamed these two properties to match.
from ._patch import __all__ as _patch_all | ||
from ._patch import * # pylint: disable=unused-wildcard-import | ||
from ._models import DocumentTranslationFileFormat | ||
from ._patch import TranslationGlossary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been manually edited?
"""Storage Source. \"AzureBlob\"""" | ||
|
||
@overload | ||
def __init__( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overload shouldn't be needed.
|
||
def convert_status(status, ll=False): | ||
if ll is False: | ||
if status == "Cancelled": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably make these checks case insensitive:
if status.lower() == 'cancelled'
"""Storage Source. \"AzureBlob\"""" | ||
|
||
@overload | ||
def __init__( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this overload isn't needed.
@@ -360,152 +508,207 @@ class StatusSummary(_model_base.Model): | |||
"""Number of in progress. Required.""" | |||
not_yet_started: int = rest_field(name="notYetStarted") | |||
"""Count of not yet started. Required.""" | |||
cancelled: int = rest_field() | |||
canceled: int = rest_field(name="cancelled") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't rename body parameters. Why was this changed?
typespec client.tsp changes: Azure/azure-rest-api-specs#30416