Skip to content

Commit 892002e

Browse files
authored
Users/singankit/update 1dp client (#40647)
* Add files via upload * Add files via upload
1 parent 4b4e38e commit 892002e

File tree

10 files changed

+223
-554
lines changed

10 files changed

+223
-554
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/onedp/_model_base.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# coding=utf-8
33
# --------------------------------------------------------------------------
44
# Copyright (c) Microsoft Corporation. All rights reserved.
5-
# Licensed under the MIT License. See License.txt in the project root for
6-
# license information.
5+
# Licensed under the MIT License. See License.txt in the project root for license information.
6+
# Code generated by Microsoft (R) Python Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
78
# --------------------------------------------------------------------------
89
# pylint: disable=protected-access, broad-except
910

@@ -21,18 +22,14 @@
2122
from datetime import datetime, date, time, timedelta, timezone
2223
from json import JSONEncoder
2324
import xml.etree.ElementTree as ET
25+
from collections.abc import MutableMapping
2426
from typing_extensions import Self
2527
import isodate
2628
from azure.core.exceptions import DeserializationError
2729
from azure.core import CaseInsensitiveEnumMeta
2830
from azure.core.pipeline import PipelineResponse
2931
from azure.core.serialization import _Null
3032

31-
if sys.version_info >= (3, 9):
32-
from collections.abc import MutableMapping
33-
else:
34-
from typing import MutableMapping
35-
3633
_LOGGER = logging.getLogger(__name__)
3734

3835
__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"]
@@ -347,7 +344,7 @@ def _get_model(module_name: str, model_name: str):
347344
_UNSET = object()
348345

349346

350-
class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object
347+
class _MyMutableMapping(MutableMapping[str, typing.Any]):
351348
def __init__(self, data: typing.Dict[str, typing.Any]) -> None:
352349
self._data = data
353350

@@ -407,13 +404,13 @@ def get(self, key: str, default: typing.Any = None) -> typing.Any:
407404
return default
408405

409406
@typing.overload
410-
def pop(self, key: str) -> typing.Any: ...
407+
def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ
411408

412409
@typing.overload
413-
def pop(self, key: str, default: _T) -> _T: ...
410+
def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs
414411

415412
@typing.overload
416-
def pop(self, key: str, default: typing.Any) -> typing.Any: ...
413+
def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs
417414

418415
def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
419416
"""
@@ -443,7 +440,7 @@ def clear(self) -> None:
443440
"""
444441
self._data.clear()
445442

446-
def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
443+
def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ
447444
"""
448445
Updates D from mapping/iterable E and F.
449446
:param any args: Either a mapping object or an iterable of key-value pairs.
@@ -454,7 +451,7 @@ def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
454451
def setdefault(self, key: str, default: None = None) -> None: ...
455452

456453
@typing.overload
457-
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...
454+
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs
458455

459456
def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
460457
"""
@@ -644,7 +641,7 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self:
644641
cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items())
645642
cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}")
646643

647-
return super().__new__(cls) # pylint: disable=no-value-for-parameter
644+
return super().__new__(cls)
648645

649646
def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
650647
for base in cls.__bases__:
@@ -680,7 +677,7 @@ def _deserialize(cls, data, exist_discriminators):
680677
discriminator_value = data.find(xml_name).text # pyright: ignore
681678
else:
682679
discriminator_value = data.get(discriminator._rest_name)
683-
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore
680+
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member
684681
return mapped_cls._deserialize(data, exist_discriminators)
685682

686683
def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]:

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/onedp/_patch.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
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+
# --------------------------------------------------------------------------
56
"""Customize generated code here.
67
78
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/onedp/_serialization.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
# pylint: disable=line-too-long,useless-suppression,too-many-lines
2+
# coding=utf-8
23
# --------------------------------------------------------------------------
3-
#
44
# Copyright (c) Microsoft Corporation. All rights reserved.
5-
#
6-
# The MIT License (MIT)
7-
#
8-
# Permission is hereby granted, free of charge, to any person obtaining a copy
9-
# of this software and associated documentation files (the ""Software""), to
10-
# deal in the Software without restriction, including without limitation the
11-
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12-
# sell copies of the Software, and to permit persons to whom the Software is
13-
# furnished to do so, subject to the following conditions:
14-
#
15-
# The above copyright notice and this permission notice shall be included in
16-
# all copies or substantial portions of the Software.
17-
#
18-
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24-
# IN THE SOFTWARE.
25-
#
5+
# Licensed under the MIT License. See License.txt in the project root for license information.
6+
# Code generated by Microsoft (R) Python Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
268
# --------------------------------------------------------------------------
279

2810
# pyright: reportUnnecessaryTypeIgnoreComment=false

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/onedp/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "1.0.0b10"
9+
VERSION = "1.0.0b1"

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/onedp/aio/_patch.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
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+
# --------------------------------------------------------------------------
56
"""Customize generated code here.
67
78
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/onedp/aio/operations/_operations.py

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# Code generated by Microsoft (R) Python Code Generator.
77
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
88
# --------------------------------------------------------------------------
9+
from collections.abc import MutableMapping
910
from io import IOBase
1011
import json
11-
import sys
1212
from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, overload
1313
import urllib.parse
1414

@@ -49,7 +49,7 @@
4949
build_deployments_list_request,
5050
build_evaluation_results_create_version_request,
5151
build_evaluation_results_delete_version_request,
52-
build_evaluation_results_fetch_asset_credentials_request,
52+
build_evaluation_results_get_credentials_request,
5353
build_evaluation_results_get_version_request,
5454
build_evaluation_results_list_latest_request,
5555
build_evaluation_results_list_versions_request,
@@ -58,6 +58,7 @@
5858
build_evaluations_create_run_request,
5959
build_evaluations_get_request,
6060
build_evaluations_list_request,
61+
build_evaluations_operation_results_request,
6162
build_evaluations_submit_annotation_request,
6263
build_evaluations_upload_run_request,
6364
build_evaluations_upload_update_run_request,
@@ -81,13 +82,9 @@
8182
)
8283
from .._configuration import AIProjectClientConfiguration
8384

84-
if sys.version_info >= (3, 9):
85-
from collections.abc import MutableMapping
86-
else:
87-
from typing import MutableMapping # type: ignore
8885
T = TypeVar("T")
8986
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
90-
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
87+
JSON = MutableMapping[str, Any]
9188

9289

9390
class ServicePatternsOperations:
@@ -883,6 +880,70 @@ async def submit_annotation(
883880

884881
return deserialized # type: ignore
885882

883+
@distributed_trace_async
884+
@api_version_validation(
885+
method_added_on="2025-05-15-preview",
886+
params_added_on={"2025-05-15-preview": ["api_version", "operation_id", "accept"]},
887+
)
888+
async def operation_results(self, operation_id: str, **kwargs: Any) -> Dict[str, Any]:
889+
"""Poll for the operation results.
890+
891+
:param operation_id: Operation ID for the polling operation. Required.
892+
:type operation_id: str
893+
:return: dict mapping str to any
894+
:rtype: dict[str, any]
895+
:raises ~azure.core.exceptions.HttpResponseError:
896+
"""
897+
error_map: MutableMapping = {
898+
401: ClientAuthenticationError,
899+
404: ResourceNotFoundError,
900+
409: ResourceExistsError,
901+
304: ResourceNotModifiedError,
902+
}
903+
error_map.update(kwargs.pop("error_map", {}) or {})
904+
905+
_headers = kwargs.pop("headers", {}) or {}
906+
_params = kwargs.pop("params", {}) or {}
907+
908+
cls: ClsType[Dict[str, Any]] = kwargs.pop("cls", None)
909+
910+
_request = build_evaluations_operation_results_request(
911+
operation_id=operation_id,
912+
api_version=self._config.api_version,
913+
headers=_headers,
914+
params=_params,
915+
)
916+
path_format_arguments = {
917+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
918+
}
919+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
920+
921+
_stream = kwargs.pop("stream", False)
922+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
923+
_request, stream=_stream, **kwargs
924+
)
925+
926+
response = pipeline_response.http_response
927+
928+
if response.status_code not in [202]:
929+
if _stream:
930+
try:
931+
await response.read() # Load the body in memory and close the socket
932+
except (StreamConsumedError, StreamClosedError):
933+
pass
934+
map_error(status_code=response.status_code, response=response, error_map=error_map)
935+
raise HttpResponseError(response=response)
936+
937+
if _stream:
938+
deserialized = response.iter_bytes()
939+
else:
940+
deserialized = _deserialize(Dict[str, Any], response.json())
941+
942+
if cls:
943+
return cls(pipeline_response, deserialized, {}) # type: ignore
944+
945+
return deserialized # type: ignore
946+
886947
@overload
887948
async def upload_run(
888949
self, evaluation: _models.EvaluationUpload, *, content_type: str = "application/json", **kwargs: Any
@@ -4267,7 +4328,7 @@ async def start_pending_upload(
42674328
return deserialized # type: ignore
42684329

42694330
@overload
4270-
async def fetch_asset_credentials(
4331+
async def get_credentials(
42714332
self,
42724333
name: str,
42734334
version: str,
@@ -4293,7 +4354,7 @@ async def fetch_asset_credentials(
42934354
"""
42944355

42954356
@overload
4296-
async def fetch_asset_credentials(
4357+
async def get_credentials(
42974358
self, name: str, version: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
42984359
) -> _models.AssetCredentialResponse:
42994360
"""Enable downloading json.
@@ -4313,7 +4374,7 @@ async def fetch_asset_credentials(
43134374
"""
43144375

43154376
@overload
4316-
async def fetch_asset_credentials(
4377+
async def get_credentials(
43174378
self, name: str, version: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
43184379
) -> _models.AssetCredentialResponse:
43194380
"""Enable downloading json.
@@ -4337,7 +4398,7 @@ async def fetch_asset_credentials(
43374398
method_added_on="2025-05-15-preview",
43384399
params_added_on={"2025-05-15-preview": ["api_version", "name", "version", "content_type", "accept"]},
43394400
)
4340-
async def fetch_asset_credentials(
4401+
async def get_credentials(
43414402
self, name: str, version: str, body: Union[_models.AssetCredentialRequest, JSON, IO[bytes]], **kwargs: Any
43424403
) -> _models.AssetCredentialResponse:
43434404
"""Enable downloading json.
@@ -4374,7 +4435,7 @@ async def fetch_asset_credentials(
43744435
else:
43754436
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
43764437

4377-
_request = build_evaluation_results_fetch_asset_credentials_request(
4438+
_request = build_evaluation_results_get_credentials_request(
43784439
name=name,
43794440
version=version,
43804441
content_type=content_type,

0 commit comments

Comments
 (0)