From 24cc0a1422e03ca08ba4c66e6178f99fe8aa24ed Mon Sep 17 00:00:00 2001 From: Darren Cohen <39422044+dargilco@users.noreply.github.com> Date: Thu, 29 Jan 2026 16:20:38 -0800 Subject: [PATCH 1/2] First --- .../evaluations/sample_redteam_evaluations.py | 17 ++++------------- .../tests/samples/test_samples_evaluations.py | 18 +++++++++--------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py index dee0bfd3b88e..4773ae76102c 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py @@ -19,12 +19,11 @@ Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your Microsoft Foundry project. It has the form: https://.services.ai.azure.com/api/projects/. - 2) DATA_FOLDER - Optional. The folder path where the data files for upload are located. - 3) AZURE_AI_AGENT_NAME - Required. The name of the Agent to perform red teaming evaluation on. + 2) AZURE_AI_AGENT_NAME - Required. The name of the Agent to perform red teaming evaluation on. """ import os - +import tempfile from dotenv import load_dotenv from pprint import pprint from azure.ai.projects.models._models import PromptAgentDefinition @@ -49,10 +48,6 @@ def main() -> None: endpoint = os.environ.get("AZURE_AI_PROJECT_ENDPOINT", "") agent_name = os.environ.get("AZURE_AI_AGENT_NAME", "") - # Construct the paths to the data folder and data file used in this sample - script_dir = os.path.dirname(os.path.abspath(__file__)) - data_folder = os.environ.get("DATA_FOLDER", os.path.join(script_dir, "data_folder")) - with ( DefaultAzureCredential() as credential, AIProjectClient(endpoint=endpoint, credential=credential) as project_client, @@ -99,9 +94,7 @@ def main() -> None: ) taxonomy = project_client.evaluation_taxonomies.create(name=agent_name, body=eval_taxonomy_input) - taxonomy_path = os.path.join(data_folder, f"taxonomy_{agent_name}.json") - # Create the data folder if it doesn't exist - os.makedirs(data_folder, exist_ok=True) + taxonomy_path = os.path.join(tempfile.gettempdir(), f"taxonomy_{agent_name}.json") with open(taxonomy_path, "w") as f: f.write(json.dumps(_to_json_primitive(taxonomy), indent=2)) print(f"Red teaming Taxonomy created for agent: {agent_name}. Taxonomy written to {taxonomy_path}") @@ -134,9 +127,7 @@ def main() -> None: run = client.evals.runs.retrieve(run_id=eval_run_response.id, eval_id=eval_object.id) if run.status == "completed" or run.status == "failed": output_items = list(client.evals.runs.output_items.list(run_id=run.id, eval_id=eval_object.id)) - output_items_path = os.path.join(data_folder, f"redteam_eval_output_items_{agent_name}.json") - # Create the data folder if it doesn't exist - os.makedirs(data_folder, exist_ok=True) + output_items_path = os.path.join(tempfile.gettempdir(), f"redteam_eval_output_items_{agent_name}.json") with open(output_items_path, "w") as f: f.write(json.dumps(_to_json_primitive(output_items), indent=2)) print( diff --git a/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py b/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py index acb3c5c2fd04..f1261d6c8ba6 100644 --- a/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py +++ b/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py @@ -110,15 +110,15 @@ class TestSamplesEvaluations(AzureRecordedTestCase): get_sample_paths( "evaluations", samples_to_test=[ - "sample_agent_evaluation.py", - "sample_model_evaluation.py", - "sample_agent_response_evaluation.py", - "sample_evaluations_builtin_with_inline_data.py", - "sample_eval_catalog.py", - "sample_eval_catalog_code_based_evaluators.py", - "sample_eval_catalog_prompt_based_evaluators.py", - "sample_evaluation_compare_insight.py", - "sample_agent_response_evaluation_with_function_tool.py", + # "sample_agent_evaluation.py", + # "sample_model_evaluation.py", + # "sample_agent_response_evaluation.py", + # "sample_evaluations_builtin_with_inline_data.py", + # "sample_eval_catalog.py", + # "sample_eval_catalog_code_based_evaluators.py", + # "sample_eval_catalog_prompt_based_evaluators.py", + # "sample_evaluation_compare_insight.py", + # "sample_agent_response_evaluation_with_function_tool.py", "sample_redteam_evaluations.py", ], ), From 2d27cc9e3ad1dd3ca1ad5ab71dce59da40538c4b Mon Sep 17 00:00:00 2001 From: Darren Cohen <39422044+dargilco@users.noreply.github.com> Date: Thu, 29 Jan 2026 16:26:50 -0800 Subject: [PATCH 2/2] Revert change --- .../tests/samples/test_samples_evaluations.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py b/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py index f1261d6c8ba6..acb3c5c2fd04 100644 --- a/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py +++ b/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py @@ -110,15 +110,15 @@ class TestSamplesEvaluations(AzureRecordedTestCase): get_sample_paths( "evaluations", samples_to_test=[ - # "sample_agent_evaluation.py", - # "sample_model_evaluation.py", - # "sample_agent_response_evaluation.py", - # "sample_evaluations_builtin_with_inline_data.py", - # "sample_eval_catalog.py", - # "sample_eval_catalog_code_based_evaluators.py", - # "sample_eval_catalog_prompt_based_evaluators.py", - # "sample_evaluation_compare_insight.py", - # "sample_agent_response_evaluation_with_function_tool.py", + "sample_agent_evaluation.py", + "sample_model_evaluation.py", + "sample_agent_response_evaluation.py", + "sample_evaluations_builtin_with_inline_data.py", + "sample_eval_catalog.py", + "sample_eval_catalog_code_based_evaluators.py", + "sample_eval_catalog_prompt_based_evaluators.py", + "sample_evaluation_compare_insight.py", + "sample_agent_response_evaluation_with_function_tool.py", "sample_redteam_evaluations.py", ], ),