Skip to content

Commit 9d93301

Browse files
author
Xiting Zhang
committed
Merge remote-tracking branch 'upstream/main'
2 parents 5baf8c5 + 6dc8416 commit 9d93301

File tree

11 files changed

+1163
-90
lines changed

11 files changed

+1163
-90
lines changed

eng/emitter-package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/emitter-package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dist/src/index.js",
33
"dependencies": {
4-
"@azure-tools/typespec-python": "0.51.2"
4+
"@azure-tools/typespec-python": "0.52.0"
55
},
66
"devDependencies": {
77
"@typespec/compiler": "^1.4.0",
@@ -17,7 +17,7 @@
1717
"@azure-tools/typespec-azure-resource-manager": "~0.60.0",
1818
"@azure-tools/typespec-autorest": "~0.60.0",
1919
"@azure-tools/typespec-azure-rulesets": "~0.60.0",
20-
"@azure-tools/typespec-client-generator-core": "0.60.2",
20+
"@azure-tools/typespec-client-generator-core": "~0.60.2",
2121
"@azure-tools/typespec-liftr-base": "0.10.0"
2222
}
2323
}

sdk/ai/azure-ai-voicelive/pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,3 @@ pytyped = ["py.typed"]
7676
[tool.pytest.ini_options]
7777
asyncio_default_fixture_loop_scope = "function"
7878
asyncio_mode = "auto"
79-
80-
[tool.azure-sdk-build]
81-
whl_no_aio = false

sdk/core/azure-core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
### Bugs Fixed
1010

11+
- Fixed repeated import attempts of cchardet and chardet when charset_normalizer is used #43092
12+
1113
### Other Changes
1214

1315
- Updated `BearerTokenCredentialPolicy` and `AsyncBearerTokenCredentialPolicy` to set the `enable_cae` parameter to `True` by default. This change enables Continuous Access Evaluation (CAE) for all token requests made through these policies. #42941

sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424
#
2525
# --------------------------------------------------------------------------
2626
from __future__ import annotations
27+
from functools import cache
2728
import sys
2829
from typing import (
2930
Any,
31+
Callable,
32+
NoReturn,
3033
Optional,
3134
AsyncIterator as AsyncIteratorType,
3235
TYPE_CHECKING,
@@ -35,6 +38,7 @@
3538
Union,
3639
Type,
3740
MutableMapping,
41+
Mapping,
3842
)
3943
from types import TracebackType
4044
from collections.abc import AsyncIterator
@@ -88,6 +92,31 @@
8892
class ConnectionTimeoutError(Exception): ... # type: ignore[no-redef]
8993

9094

95+
@cache
96+
def _get_detect() -> Callable[[bytes], Mapping[str, Any]]:
97+
try:
98+
from cchardet import detect
99+
100+
return detect
101+
except ImportError: # pragma: no cover
102+
try:
103+
from chardet import detect
104+
105+
return detect
106+
except ImportError: # pragma: no cover
107+
try:
108+
from charset_normalizer import detect
109+
110+
return detect
111+
except ImportError as e: # pragma: no cover
112+
charset_import_err = e
113+
114+
def error_detect(_: bytes) -> NoReturn:
115+
raise charset_import_err
116+
117+
return error_detect
118+
119+
91120
class AioHttpTransport(AsyncHttpTransport):
92121
"""AioHttp HTTP sender implementation.
93122
@@ -525,16 +554,7 @@ def text(self, encoding: Optional[str] = None) -> str:
525554
elif body is None:
526555
raise RuntimeError("Cannot guess the encoding of a not yet read body")
527556
else:
528-
try:
529-
import cchardet as chardet
530-
except ImportError: # pragma: no cover
531-
try:
532-
import chardet # type: ignore
533-
except ImportError: # pragma: no cover
534-
import charset_normalizer as chardet # type: ignore[no-redef]
535-
# While "detect" can return a dict of float, in this context this won't happen
536-
# The cast is for pyright to be happy
537-
encoding = cast(Optional[str], chardet.detect(body)["encoding"])
557+
encoding = _get_detect()(body)["encoding"]
538558
if encoding == "utf-8" or encoding is None:
539559
encoding = "utf-8-sig"
540560

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluate/_evaluate.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from azure.ai.evaluation._common.math import list_mean_nan_safe, apply_transform_nan_safe
2020
from azure.ai.evaluation._common.utils import validate_azure_ai_project, is_onedp_project
21+
from azure.ai.evaluation._evaluators._common._base_eval import EvaluatorBase
2122
from azure.ai.evaluation._exceptions import ErrorBlame, ErrorCategory, ErrorTarget, EvaluationException
2223

2324
from azure.ai.evaluation._aoai.aoai_grader import AzureOpenAIGrader
@@ -317,6 +318,9 @@ def _aggregate_metrics(df: pd.DataFrame, evaluators: Dict[str, Callable]) -> Dic
317318
# For rest of metrics, we will calculate mean
318319
df.drop(columns=handled_columns, inplace=True)
319320

321+
# Convert "not applicable" strings to None to allow proper numeric aggregation
322+
df = df.replace(EvaluatorBase._NOT_APPLICABLE_RESULT, None)
323+
320324
# NOTE: nan/None values don't count as as booleans, so boolean columns with
321325
# nan/None values won't have a mean produced from them.
322326
# This is different from label-based known evaluators, which have special handling.

0 commit comments

Comments
 (0)