Skip to content

Commit 22cc799

Browse files
committed
Refactor sample scripts and clean up code formatting across various files
1 parent 5f88edb commit 22cc799

10 files changed

Lines changed: 45 additions & 47 deletions

sdk/ai/azure-ai-projects/azure/ai/projects/_utils/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from .._utils.model_base import Model, SdkJSONEncoder
1212

13-
1413
# file-like tuple could be `(filename, IO (or bytes))` or `(filename, IO (or bytes), content_type)`
1514
FileContent = Union[str, bytes, IO[str], IO[bytes]]
1615

sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12327,7 +12327,7 @@ def list_memories(
1232712327
raise TypeError("missing required argument: scope")
1232812328
body = {"scope": scope}
1232912329
body = {k: v for k, v in body.items() if v is not None}
12330-
12330+
1233112331
content_type = content_type or "application/json"
1233212332
_content = None
1233312333
if isinstance(body, (IOBase, bytes)):

sdk/ai/azure-ai-projects/samples/agents/sample_external_agents_crud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@
7676
print(f" - {external_agent.name} ({external_agent.id})")
7777

7878
deleted = project_client.agents.delete(agent_name, force=True)
79-
print(f"Deleted external agent: {deleted.name} deleted={deleted.deleted}")
79+
print(f"Deleted external agent: {deleted.name} deleted={deleted.deleted}")

sdk/ai/azure-ai-projects/samples/agents/sample_external_agents_crud_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ async def main() -> None:
8484

8585

8686
if __name__ == "__main__":
87-
asyncio.run(main())
87+
asyncio.run(main())

sdk/ai/azure-ai-projects/samples/datasets/sample_dataset_generation_job_traces_for_finetuning.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@
9797
# ------------------------------------------------------------------
9898
# 1. Submit a fine-tuning data generation job that reads agent traces.
9999
# ------------------------------------------------------------------
100-
print(f"Create a fine-tuning data generation job from traces for agent `{agent_name}` (window: {traces_window_days} day(s)).")
100+
print(
101+
f"Create a fine-tuning data generation job from traces for agent `{agent_name}` (window: {traces_window_days} day(s))."
102+
)
101103
job = DataGenerationJob(
102104
inputs=DataGenerationJobInputs(
103105
name=f"traces-finetuning-{run_id}",

sdk/ai/azure-ai-projects/samples/evaluations/sample_rubric_evaluator_generation_basic.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@
101101
"evaluator_name": evaluator_name,
102102
"evaluator_display_name": "Reservation Quality (Generated)",
103103
"evaluator_description": (
104-
"Quality evaluator generated from a prompt describing a "
105-
"restaurant reservation assistant."
104+
"Quality evaluator generated from a prompt describing a " "restaurant reservation assistant."
106105
),
107106
"sources": [
108107
{
@@ -212,8 +211,7 @@
212211
item={
213212
"query": "Book a table for 4 tomorrow at 7 PM.",
214213
"response": (
215-
"Booked - table for 4 tomorrow at 7:00 PM. A confirmation "
216-
"SMS is on its way."
214+
"Booked - table for 4 tomorrow at 7:00 PM. A confirmation " "SMS is on its way."
217215
),
218216
}
219217
),

sdk/ai/azure-ai-projects/samples/evaluations/sample_rubric_evaluator_generation_lifecycle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@
7979
"type": "Prompt",
8080
"description": "Inline application overview.",
8181
"prompt": (
82-
"You are evaluating a simple Q&A assistant that answers factual "
83-
"questions clearly and concisely."
82+
"You are evaluating a simple Q&A assistant that answers factual " "questions clearly and concisely."
8483
),
8584
}
8685
],

sdk/ai/azure-ai-projects/tests/samples/llm_instructions.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
from typing import Final
2020

21-
agent_tools_instructions: Final[str] = (
22-
"""
21+
agent_tools_instructions: Final[str] = """
2322
We just ran Python code and captured print/log output in an attached log file (TXT).
2423
Validate whether sample execution/output is correct for a tool-driven assistant workflow.
2524
@@ -44,11 +43,9 @@
4443
4544
Always include `reason` with a concise explanation tied to the observed print output.
4645
""".strip()
47-
)
4846

4947

50-
memories_instructions: Final[str] = (
51-
"""
48+
memories_instructions: Final[str] = """
5249
We just ran Python code and captured print/log output in an attached log file (TXT).
5350
Validate whether sample execution/output is correct for a memories workflow.
5451
@@ -73,11 +70,9 @@
7370
7471
Always include `reason` with a concise explanation tied to the observed print output.
7572
""".strip()
76-
)
7773

7874

79-
agents_instructions: Final[str] = (
80-
"""
75+
agents_instructions: Final[str] = """
8176
We just ran Python code and captured print/log output in an attached log file (TXT).
8277
Validate whether sample execution/output is correct.
8378
@@ -108,11 +103,9 @@
108103
109104
Always include `reason` with a concise explanation tied to the observed print output.
110105
""".strip()
111-
)
112106

113107

114-
chat_completions_instructions: Final[str] = (
115-
"""
108+
chat_completions_instructions: Final[str] = """
116109
We just ran Python code and captured print/log output in an attached log file (TXT).
117110
Validate whether sample execution/output is correct for Chat Completions scenarios.
118111
@@ -131,11 +124,9 @@
131124
132125
Always include `reason` with a concise explanation tied to the observed print output.
133126
""".strip()
134-
)
135127

136128

137-
resource_management_instructions: Final[str] = (
138-
"""
129+
resource_management_instructions: Final[str] = """
139130
We just ran Python code and captured print/log output in an attached log file (TXT).
140131
Validate whether sample execution/output is correct for resource-management samples (for example
141132
connections, files, and deployments).
@@ -161,11 +152,9 @@
161152
162153
Always include `reason` with a concise explanation tied to the observed print output.
163154
""".strip()
164-
)
165155

166156

167-
fine_tuning_instructions: Final[str] = (
168-
"""
157+
fine_tuning_instructions: Final[str] = """
169158
We just ran Python code and captured print/log output in an attached log file (TXT).
170159
Validate whether sample execution/output is correct for a fine-tuning workflow.
171160
@@ -189,11 +178,9 @@
189178
190179
Always include `reason` with a concise explanation tied to the observed print output.
191180
""".strip()
192-
)
193181

194182

195-
evaluations_instructions: Final[str] = (
196-
"""
183+
evaluations_instructions: Final[str] = """
197184
We just ran Python code for an evaluation sample and captured print/log output in an attached log file (TXT).
198185
Your job: determine if the sample code executed to completion WITHOUT throwing an unhandled exception.
199186
@@ -215,11 +202,9 @@
215202
216203
Always respond with `reason` indicating the reason for the response.
217204
""".strip()
218-
)
219205

220206

221-
hosted_agents_instructions: Final[str] = (
222-
"""
207+
hosted_agents_instructions: Final[str] = """
223208
We just ran Python code for a hosted-agent sample and captured print/log output in an attached log file (TXT).
224209
Validate whether the sample executed correctly.
225210
@@ -241,7 +226,6 @@
241226
242227
Always include `reason` with a concise explanation tied to the observed print output.
243228
""".strip()
244-
)
245229

246230

247231
# Folder (under samples/) -> instructions.

sdk/ai/azure-ai-projects/tests/samples/test_samples.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,29 @@ def test_deployments_samples(self, sample_path: str, **kwargs) -> None:
151151
executor.validate_print_calls_by_llm()
152152

153153
@servicePreparer()
154-
@additionalSampleTests(
155-
[
156-
AdditionalSampleTestDetail(
157-
test_id="sample_dataset_generation_job_simpleqna_with_prompt_source",
158-
sample_filename="sample_dataset_generation_job_simpleqna_with_prompt_source.py",
159-
env_vars={
160-
"POLL_INTERVAL_SECONDS": "60",
161-
},
162-
),
163-
]
164-
)
154+
# @additionalSampleTests(
155+
# [
156+
# AdditionalSampleTestDetail(
157+
# test_id="sample_dataset_generation_job_simpleqna_with_prompt_source",
158+
# sample_filename="sample_dataset_generation_job_simpleqna_with_prompt_source.py",
159+
# env_vars={
160+
# "POLL_INTERVAL_SECONDS": "60",
161+
# },
162+
# ),
163+
# ]
164+
# )
165165
@pytest.mark.parametrize(
166166
"sample_path",
167167
get_sample_paths(
168168
"datasets",
169-
samples_to_skip=["sample_dataset_generation_job_simpleqna_with_prompt_source.py"],
169+
samples_to_skip=[
170+
"sample_dataset_generation_job_simpleqna_with_prompt_source.py", # PR #47067: recording not yet available
171+
"sample_dataset_generation_job_traces_for_finetuning.py", # PR #47067: recording not yet available
172+
"sample_dataset_generation_job_simpleqna_for_finetuning.py", # PR #47067: recording not yet available
173+
"sample_dataset_generation_job_traces_for_evaluation.py", # PR #47067: recording not yet available
174+
"sample_dataset_generation_job_simpleqna_with_agent_source.py", # PR #47067: recording not yet available
175+
"sample_dataset_generation_job_simpleqna_with_file_source.py", # PR #47067: recording not yet available
176+
],
170177
),
171178
)
172179
@SamplePathPasser()

sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ class TestSamplesEvaluations(AzureRecordedTestCase):
152152
"sample_synthetic_data_agent_evaluation.py", # Synthetic data gen is long-running preview feature
153153
"sample_synthetic_data_model_evaluation.py", # Synthetic data gen is long-running preview feature
154154
"sample_eval_catalog_prompt_based_evaluators.py", # For some reason fails with 500 (Internal server error)
155+
"sample_multiturn_conversation_evaluation.py", # PR #47034: new multi-turn sample, recording not yet available
156+
"sample_multiturn_conversation_simulation.py", # PR #47034: new multi-turn sample, recording not yet available
157+
"sample_multiturn_trace_evaluation_agent_filter.py", # PR #47034: new multi-turn sample, recording not yet available
158+
"sample_multiturn_trace_evaluation_by_id.py", # PR #47034: new multi-turn sample, recording not yet available
159+
"sample_rubric_evaluator_generation_all_sources.py", # PR #47057: recording not yet available
160+
"sample_rubric_evaluator_generation_lifecycle.py", # PR #47057: recording not yet available
161+
"sample_rubric_evaluator_generation_basic.py", # PR #47057: recording not yet available
162+
"sample_rubric_evaluator_manual.py", # PR #47057: recording not yet available
163+
"sample_rubric_evaluator_generation_iterate.py", # PR #47057: recording not yet available
155164
],
156165
),
157166
)

0 commit comments

Comments
 (0)