Skip to content

Commit a9a04a3

Browse files
authored
Fixing evaluation upload (#40867)
1 parent a6a249d commit a9a04a3

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_azure/_token_manager.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
import logging
66
import time
77
import inspect
8-
from typing import cast, Optional, Union
8+
from typing import cast, Optional, Union, Any
99

1010
from azure.core.credentials import TokenCredential, AccessToken
1111
from azure.identity import AzureCliCredential, DefaultAzureCredential, ManagedIdentityCredential
1212
from azure.ai.evaluation._exceptions import ErrorBlame, ErrorCategory, ErrorTarget, EvaluationException
13+
1314
from ..simulator._model_tools._identity_manager import APITokenManager, AZURE_TOKEN_REFRESH_INTERVAL
1415

1516

@@ -71,15 +72,19 @@ def get_aad_credential(self) -> Union[DefaultAzureCredential, ManagedIdentityCre
7172
# Fall back to using the parent implementation
7273
return super().get_aad_credential()
7374

74-
def get_token(self) -> AccessToken:
75+
def get_token(
76+
self, scopes = None, claims: Union[str, None] = None, tenant_id: Union[str, None] = None, enable_cae: bool = False, **kwargs: Any) -> AccessToken:
7577
"""Get the API token. If the token is not available or has expired, refresh the token.
7678
7779
:return: API token
7880
:rtype: str
7981
"""
8082
if self._token_needs_update():
8183
credential = cast(TokenCredential, self.credential)
82-
access_token = credential.get_token(self.token_scope)
84+
token_scope = self.token_scope
85+
if scopes:
86+
token_scope = scopes
87+
access_token = credential.get_token(token_scope)
8388
self._update_token(access_token)
8489

8590
return cast(AccessToken, self.token) # check for none is hidden in the _token_needs_update method

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCr
4747
self.endpoint = endpoint
4848
self.credential = credential
4949
self.api_version = api_version
50-
self.credential_scopes = kwargs.pop("credential_scopes", ["https://cognitiveservices.azure.com/.default"])
50+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"])
5151
kwargs.setdefault("sdk_moniker", "ai-projects-onedp/{}".format(VERSION))
5252
self.polling_interval = kwargs.get("polling_interval", 30)
5353
self._configure(**kwargs)

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/simulator/_model_tools/_identity_manager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
import time
1010
from abc import ABC, abstractmethod
11-
from typing import Optional, Union
11+
from typing import Optional, Union, Any
1212

1313
from azure.ai.evaluation._constants import TokenScope
1414
from azure.core.credentials import AccessToken, TokenCredential
@@ -77,7 +77,8 @@ def get_aad_credential(self) -> Union[DefaultAzureCredential, ManagedIdentityCre
7777
return DefaultAzureCredential()
7878

7979
@abstractmethod
80-
def get_token(self) -> str:
80+
def get_token(
81+
self, scopes: Union[str, None] = None, claims: Union[str, None] = None, tenant_id: Union[str, None] = None, enable_cae: bool = False, **kwargs: Any) -> AccessToken:
8182
"""Async method to get the API token. Subclasses should implement this method.
8283
8384
:return: API token

0 commit comments

Comments
 (0)