Skip to content

Commit 9d493b4

Browse files
author
SDKAuto
committed
CodeGen from PR 32524 in Azure/azure-rest-api-specs
Merge e8a40199e62adbb2d233742d6205b76f5f2db854 into 85b13254060355ccbad6317d33f647487dd57ced
1 parent 27e54c9 commit 9d493b4

35 files changed

+6737
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## 1.0.0b1 (1970-01-01)
4+
5+
- Initial version
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include *.md
2+
include LICENSE
3+
include azure/ai/evaluations/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include azure/__init__.py
7+
include azure/ai/__init__.py
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
3+
# Azure Ai Evaluations client library for Python
4+
<!-- write necessary description of service -->
5+
6+
## Getting started
7+
8+
### Install the package
9+
10+
```bash
11+
python -m pip install azure-ai-evaluations
12+
```
13+
14+
#### Prequisites
15+
16+
- Python 3.8 or later is required to use this package.
17+
- You need an [Azure subscription][azure_sub] to use this package.
18+
- An existing Azure Ai Evaluations instance.
19+
#### Create with an Azure Active Directory Credential
20+
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
21+
provide an instance of the desired credential type obtained from the
22+
[azure-identity][azure_identity_credentials] library.
23+
24+
To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip]
25+
26+
After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
27+
As an example, [DefaultAzureCredential][default_azure_credential] can be used to authenticate the client:
28+
29+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
30+
`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`
31+
32+
Use the returned token credential to authenticate the client:
33+
34+
```python
35+
>>> from azure.ai.evaluations import AIEvaluationsClient
36+
>>> from azure.identity import DefaultAzureCredential
37+
>>> client = AIEvaluationsClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
38+
```
39+
40+
## Examples
41+
42+
```python
43+
>>> from azure.ai.evaluations import AIEvaluationsClient
44+
>>> from azure.identity import DefaultAzureCredential
45+
>>> from azure.core.exceptions import HttpResponseError
46+
47+
>>> client = AIEvaluationsClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
48+
>>> try:
49+
<!-- write test code here -->
50+
except HttpResponseError as e:
51+
print('service responds error: {}'.format(e.response.json()))
52+
53+
```
54+
55+
## Contributing
56+
57+
This project welcomes contributions and suggestions. Most contributions require
58+
you to agree to a Contributor License Agreement (CLA) declaring that you have
59+
the right to, and actually do, grant us the rights to use your contribution.
60+
For details, visit https://cla.microsoft.com.
61+
62+
When you submit a pull request, a CLA-bot will automatically determine whether
63+
you need to provide a CLA and decorate the PR appropriately (e.g., label,
64+
comment). Simply follow the instructions provided by the bot. You will only
65+
need to do this once across all repos using our CLA.
66+
67+
This project has adopted the
68+
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
69+
see the Code of Conduct FAQ or contact [email protected] with any
70+
additional questions or comments.
71+
72+
<!-- LINKS -->
73+
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
74+
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
75+
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
76+
[azure_identity_pip]: https://pypi.org/project/azure-identity/
77+
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
78+
[pip]: https://pypi.org/project/pip/
79+
[azure_sub]: https://azure.microsoft.com/free/
80+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "985d9a014e6eb451627aa82ae3071aaa5f8d6c93",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/ai/Azure.AI.Evaluations",
5+
"@azure-tools/typespec-python": "0.38.3"
6+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"CrossLanguagePackageId": "Azure.AI.Evaluations",
3+
"CrossLanguageDefinitionId": {
4+
"azure.ai.evaluations.models.InputData": "Azure.AI.Evaluations.InputData",
5+
"azure.ai.evaluations.models.ApplicationInsightsConfiguration": "Azure.AI.Evaluations.ApplicationInsightsConfiguration",
6+
"azure.ai.evaluations.models.Trigger": "Azure.AI.Evaluations.Trigger",
7+
"azure.ai.evaluations.models.CronTrigger": "Azure.AI.Evaluations.CronTrigger",
8+
"azure.ai.evaluations.models.Dataset": "Azure.AI.Evaluations.Dataset",
9+
"azure.ai.evaluations.models.Evaluation": "Azure.AI.Evaluations.Evaluation",
10+
"azure.ai.evaluations.models.EvaluationSchedule": "Azure.AI.Evaluations.EvaluationSchedule",
11+
"azure.ai.evaluations.models.EvaluatorConfiguration": "Azure.AI.Evaluations.EvaluatorConfiguration",
12+
"azure.ai.evaluations.models.RecurrenceSchedule": "Azure.AI.Evaluations.RecurrenceSchedule",
13+
"azure.ai.evaluations.models.RecurrenceTrigger": "Azure.AI.Evaluations.RecurrenceTrigger",
14+
"azure.ai.evaluations.models.SystemData": "Azure.AI.Evaluations.SystemData",
15+
"azure.ai.evaluations.models.Frequency": "Azure.AI.Evaluations.Frequency",
16+
"azure.ai.evaluations.models.WeekDays": "Azure.AI.Evaluations.WeekDays",
17+
"azure.ai.evaluations.AIEvaluationsClient.evaluations.get": "Azure.AI.Evaluations.Evaluations.get",
18+
"azure.ai.evaluations.AIEvaluationsClient.evaluations.create": "Azure.AI.Evaluations.Evaluations.create",
19+
"azure.ai.evaluations.AIEvaluationsClient.evaluations.list": "Azure.AI.Evaluations.Evaluations.list",
20+
"azure.ai.evaluations.AIEvaluationsClient.evaluations.update": "Azure.AI.Evaluations.Evaluations.update",
21+
"azure.ai.evaluations.AIEvaluationsClient.evaluations.get_schedule": "Azure.AI.Evaluations.Evaluations.getSchedule",
22+
"azure.ai.evaluations.AIEvaluationsClient.evaluations.create_or_replace_schedule": "Azure.AI.Evaluations.Evaluations.createOrReplaceSchedule",
23+
"azure.ai.evaluations.AIEvaluationsClient.evaluations.list_schedule": "Azure.AI.Evaluations.Evaluations.listSchedule",
24+
"azure.ai.evaluations.AIEvaluationsClient.evaluations.disable_schedule": "Azure.AI.Evaluations.Evaluations.disableSchedule"
25+
}
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
9+
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import AIEvaluationsClient # type: ignore
16+
from ._version import VERSION
17+
18+
__version__ = VERSION
19+
20+
try:
21+
from ._patch import __all__ as _patch_all
22+
from ._patch import *
23+
except ImportError:
24+
_patch_all = []
25+
from ._patch import patch_sdk as _patch_sdk
26+
27+
__all__ = [
28+
"AIEvaluationsClient",
29+
]
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
31+
32+
_patch_sdk()
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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+
# --------------------------------------------------------------------------
8+
9+
from copy import deepcopy
10+
from typing import Any, TYPE_CHECKING
11+
from typing_extensions import Self
12+
13+
from azure.core import PipelineClient
14+
from azure.core.pipeline import policies
15+
from azure.core.rest import HttpRequest, HttpResponse
16+
17+
from ._configuration import AIEvaluationsClientConfiguration
18+
from ._serialization import Deserializer, Serializer
19+
from .operations import EvaluationsOperations
20+
21+
if TYPE_CHECKING:
22+
from azure.core.credentials import TokenCredential
23+
24+
25+
class AIEvaluationsClient:
26+
"""AIEvaluationsClient.
27+
28+
:ivar evaluations: EvaluationsOperations operations
29+
:vartype evaluations: azure.ai.evaluations.operations.EvaluationsOperations
30+
:param endpoint: The Azure AI Foundry project endpoint, in the form
31+
``https://<azure-region>.api.azureml.ms`` or
32+
``https://<private-link-guid>.<azure-region>.api.azureml.ms``\\\\ , where
33+
:code:`<azure-region>` is the Azure region where the project is deployed (e.g. westus) and
34+
:code:`<private-link-guid>` is the GUID of the Enterprise private link. Required.
35+
:type endpoint: str
36+
:param subscription_id: The Azure subscription ID. Required.
37+
:type subscription_id: str
38+
:param resource_group_name: The name of the Azure Resource Group. Required.
39+
:type resource_group_name: str
40+
:param project_name: The Azure AI Foundry project name. Required.
41+
:type project_name: str
42+
:param credential: Credential used to authenticate requests to the service. Required.
43+
:type credential: ~azure.core.credentials.TokenCredential
44+
:keyword api_version: The API version to use for this operation. Default value is
45+
"2024-07-01-preview". Note that overriding this default value may result in unsupported
46+
behavior.
47+
:paramtype api_version: str
48+
"""
49+
50+
def __init__(
51+
self,
52+
endpoint: str,
53+
subscription_id: str,
54+
resource_group_name: str,
55+
project_name: str,
56+
credential: "TokenCredential",
57+
**kwargs: Any
58+
) -> None:
59+
_endpoint = "{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}" # pylint: disable=line-too-long
60+
self._config = AIEvaluationsClientConfiguration(
61+
endpoint=endpoint,
62+
subscription_id=subscription_id,
63+
resource_group_name=resource_group_name,
64+
project_name=project_name,
65+
credential=credential,
66+
**kwargs
67+
)
68+
_policies = kwargs.pop("policies", None)
69+
if _policies is None:
70+
_policies = [
71+
policies.RequestIdPolicy(**kwargs),
72+
self._config.headers_policy,
73+
self._config.user_agent_policy,
74+
self._config.proxy_policy,
75+
policies.ContentDecodePolicy(**kwargs),
76+
self._config.redirect_policy,
77+
self._config.retry_policy,
78+
self._config.authentication_policy,
79+
self._config.custom_hook_policy,
80+
self._config.logging_policy,
81+
policies.DistributedTracingPolicy(**kwargs),
82+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
83+
self._config.http_logging_policy,
84+
]
85+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
86+
87+
self._serialize = Serializer()
88+
self._deserialize = Deserializer()
89+
self._serialize.client_side_validation = False
90+
self.evaluations = EvaluationsOperations(self._client, self._config, self._serialize, self._deserialize)
91+
92+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
93+
"""Runs the network request through the client's chained policies.
94+
95+
>>> from azure.core.rest import HttpRequest
96+
>>> request = HttpRequest("GET", "https://www.example.org/")
97+
<HttpRequest [GET], url: 'https://www.example.org/'>
98+
>>> response = client.send_request(request)
99+
<HttpResponse: 200 OK>
100+
101+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
102+
103+
:param request: The network request you want to make. Required.
104+
:type request: ~azure.core.rest.HttpRequest
105+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
106+
:return: The response of your network call. Does not do error handling on your response.
107+
:rtype: ~azure.core.rest.HttpResponse
108+
"""
109+
110+
request_copy = deepcopy(request)
111+
path_format_arguments = {
112+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
113+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
114+
"resourceGroupName": self._serialize.url(
115+
"self._config.resource_group_name", self._config.resource_group_name, "str"
116+
),
117+
"projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"),
118+
}
119+
120+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
121+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
122+
123+
def close(self) -> None:
124+
self._client.close()
125+
126+
def __enter__(self) -> Self:
127+
self._client.__enter__()
128+
return self
129+
130+
def __exit__(self, *exc_details: Any) -> None:
131+
self._client.__exit__(*exc_details)

0 commit comments

Comments
 (0)