Skip to content

Commit ffe542d

Browse files
authored
Fix MyPy, PyRight, and Black issues in Evaluations Samples (#43981)
* Fix mypy issues * Fix pyright issues: wrong argument name * Run Black * Add missing required in coherence and fluency * Remove ignore type for DataSourceConfigCustom * Fix DataSourceConfigCustom type ignores * black
1 parent fead515 commit ffe542d

34 files changed

+600
-501
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,3 @@ pytyped = ["py.typed"]
6363

6464
[tool.azure-sdk-build]
6565
verifytypes = false
66-
67-
[tool.mypy]
68-
exclude = [
69-
"samples/evaluations/.*"
70-
]
71-

sdk/ai/azure-ai-projects/pyrightconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"reportMissingImports": false,
44
"pythonVersion": "3.11",
55
"exclude": [
6-
"**/samples/evaluations/**"
76
],
87
"extraPaths": [
98
"./../../core/azure-core",

sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_coherence.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
SourceFileContent,
3737
SourceFileContentContent,
3838
)
39+
from openai.types.eval_create_params import DataSourceConfigCustom
3940

4041

4142
load_dotenv()
@@ -53,15 +54,17 @@ def main() -> None:
5354

5455
client = project_client.get_openai_client()
5556

56-
data_source_config = {
57-
"type": "custom",
58-
"item_schema": {
59-
"type": "object",
60-
"properties": {"query": {"type": "string"}, "response": {"type": "string"}},
61-
"required": [],
62-
},
63-
"include_sample_schema": True,
64-
}
57+
data_source_config = DataSourceConfigCustom(
58+
{
59+
"type": "custom",
60+
"item_schema": {
61+
"type": "object",
62+
"properties": {"query": {"type": "string"}, "response": {"type": "string"}},
63+
"required": ["query", "response"],
64+
},
65+
"include_sample_schema": True,
66+
}
67+
)
6568

6669
testing_criteria = [
6770
{
@@ -76,8 +79,8 @@ def main() -> None:
7679
print("Creating Eval Group")
7780
eval_object = client.evals.create(
7881
name="Test Coherence Evaluator with inline data",
79-
data_source_config=data_source_config, # type: ignore
80-
testing_criteria=testing_criteria, # type: ignore
82+
data_source_config=data_source_config,
83+
testing_criteria=testing_criteria, # type: ignore
8184
)
8285
print(f"Eval Group created")
8386

sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_fluency.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
SourceFileContent,
3737
SourceFileContentContent,
3838
)
39+
from openai.types.eval_create_params import DataSourceConfigCustom
3940

4041

4142
load_dotenv()
@@ -53,15 +54,17 @@ def main() -> None:
5354

5455
client = project_client.get_openai_client()
5556

56-
data_source_config = {
57-
"type": "custom",
58-
"item_schema": {
59-
"type": "object",
60-
"properties": {"query": {"type": "string"}, "response": {"type": "string"}},
61-
"required": [],
62-
},
63-
"include_sample_schema": True,
64-
}
57+
data_source_config = DataSourceConfigCustom(
58+
{
59+
"type": "custom",
60+
"item_schema": {
61+
"type": "object",
62+
"properties": {"query": {"type": "string"}, "response": {"type": "string"}},
63+
"required": ["response"],
64+
},
65+
"include_sample_schema": True,
66+
}
67+
)
6568

6669
testing_criteria = [
6770
{
@@ -76,8 +79,8 @@ def main() -> None:
7679
print("Creating Eval Group")
7780
eval_object = client.evals.create(
7881
name="Test Fluency Evaluator with inline data",
79-
data_source_config=data_source_config, # type: ignore
80-
testing_criteria=testing_criteria, # type: ignore
82+
data_source_config=data_source_config,
83+
testing_criteria=testing_criteria, # type: ignore
8184
)
8285
print(f"Eval Group created")
8386

sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/agent_utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
# ------------------------------------
66

77
from dotenv import load_dotenv
8-
import json
98
import os
109
import time
1110
from pprint import pprint
12-
from samples.evaluation.sample_agentic_evaluators.sample_generic_agentic_evaluator.agent_utils import pprint
1311

1412
from azure.identity import DefaultAzureCredential
1513
from azure.ai.projects import AIProjectClient
@@ -18,6 +16,7 @@
1816
SourceFileContent,
1917
SourceFileContentContent,
2018
)
19+
from openai.types.eval_create_params import DataSourceConfigCustom
2120

2221

2322
load_dotenv()
@@ -26,7 +25,7 @@
2625
def run_evaluator(
2726
evaluator_name: str,
2827
evaluation_contents: list[SourceFileContentContent],
29-
data_source_config: dict,
28+
data_source_config: DataSourceConfigCustom,
3029
initialization_parameters: dict[str, str],
3130
data_mapping: dict[str, str],
3231
) -> None:
@@ -53,8 +52,8 @@ def run_evaluator(
5352
print("Creating Eval Group")
5453
eval_object = client.evals.create(
5554
name=f"Test {evaluator_name} Evaluator with inline data",
56-
data_source_config=data_source_config, # type: ignore
57-
testing_criteria=testing_criteria, # type: ignore
55+
data_source_config=data_source_config,
56+
testing_criteria=testing_criteria, # type: ignore
5857
)
5958
print(f"Eval Group created")
6059

sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/sample_generic_agentic_evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from dotenv import load_dotenv
2727
import os
28-
from samples.evaluation.sample_agentic_evaluators.sample_generic_agentic_evaluator.agent_utils import run_evaluator
28+
from agent_utils import run_evaluator
2929
from schema_mappings import evaluator_to_data_source_config, evaluator_to_data_mapping
3030
from openai.types.evals.create_eval_jsonl_run_data_source_param import SourceFileContentContent
3131

0 commit comments

Comments
 (0)