Skip to content

Commit 383b5cd

Browse files
authored
(engsys) ci,fix: Fix Run Black falsely reporting success (Azure#38095)
* ci,fix(run_black): Resolve package directory when service dir is "auto" * style: Run black
1 parent 876a6c0 commit 383b5cd

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

scripts/devops_tasks/validate_formatting.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ def run_black(glob_string, service_dir):
2323
results = []
2424
logging.info("Running black for {}".format(service_dir))
2525

26-
discovered_packages = discover_targeted_packages(
27-
glob_string, os.path.join(root_dir, "sdk", service_dir)
28-
)
26+
if service_dir and service_dir != "auto":
27+
target_dir = os.path.join(root_dir, "sdk", service_dir)
28+
else:
29+
target_dir = root_dir
30+
31+
discovered_packages = discover_targeted_packages(glob_string, target_dir)
2932

3033
for package in discovered_packages:
3134
package_name = os.path.basename(package)
@@ -43,7 +46,7 @@ def run_black(glob_string, service_dir):
4346
"-e",
4447
"black",
4548
"--",
46-
os.path.join("sdk", service_dir, package_name),
49+
package,
4750
],
4851
stdout=subprocess.PIPE,
4952
stderr=subprocess.STDOUT,

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/simulator/_indirect_attack_simulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ async def __call__(
191191
template_parameters = completed_task.get("template_parameters", {}) # type: ignore
192192
xpia_attack_type = template_parameters.get("xpia_attack_type", "") # type: ignore
193193
action = template_parameters.get("action", "") # type: ignore
194-
document_type = template_parameters.get("document_type", "") # type: ignore
194+
document_type = template_parameters.get("document_type", "") # type: ignore
195195
sim_results.append(
196196
{
197197
"messages": completed_task["messages"], # type: ignore

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/simulator/_simulator.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,19 @@ async def run_simulation(simulation: List[Union[str, Dict[str, Any]]]) -> JsonLi
236236
user_turn = Turn(
237237
role=ConversationRole.USER,
238238
content=str(simulated_turn.get("content")),
239-
context=str(simulated_turn.get("context"))
239+
context=str(simulated_turn.get("context")),
240240
)
241241
else:
242-
raise ValueError("Each simulated turn must be a string or a dict with 'content' and 'context' keys")
242+
raise ValueError(
243+
"Each simulated turn must be a string or a dict with 'content' and 'context' keys"
244+
)
243245
current_simulation.add_to_history(user_turn)
244246
assistant_response, assistant_context = await self._get_target_response(
245247
target=target, api_call_delay_sec=api_call_delay_sec, conversation_history=current_simulation
246248
)
247-
assistant_turn = Turn(role=ConversationRole.ASSISTANT, content=assistant_response, context=assistant_context)
249+
assistant_turn = Turn(
250+
role=ConversationRole.ASSISTANT, content=assistant_response, context=assistant_context
251+
)
248252
current_simulation.add_to_history(assistant_turn)
249253
async with progress_bar_lock:
250254
progress_bar.update(1)
@@ -286,7 +290,7 @@ async def _extend_conversation_with_simulator(
286290
prompty_model_config: Dict[str, Any],
287291
target: Callable,
288292
progress_bar: tqdm,
289-
progress_bar_lock: asyncio.Lock
293+
progress_bar_lock: asyncio.Lock,
290294
):
291295
"""
292296
Extends an ongoing conversation using a user simulator until the maximum number of turns is reached.
@@ -329,7 +333,9 @@ async def _extend_conversation_with_simulator(
329333
assistant_response, assistant_context = await self._get_target_response(
330334
target=target, api_call_delay_sec=api_call_delay_sec, conversation_history=current_simulation
331335
)
332-
assistant_turn = Turn(role=ConversationRole.ASSISTANT, content=assistant_response, context=assistant_context)
336+
assistant_turn = Turn(
337+
role=ConversationRole.ASSISTANT, content=assistant_response, context=assistant_context
338+
)
333339
current_simulation.add_to_history(assistant_turn)
334340
async with progress_bar_lock:
335341
progress_bar.update(1)
@@ -667,7 +673,9 @@ async def _complete_conversation(
667673
assistant_response, assistant_context = await self._get_target_response(
668674
target=target, api_call_delay_sec=api_call_delay_sec, conversation_history=conversation_history
669675
)
670-
assistant_turn = Turn(role=ConversationRole.ASSISTANT, content=assistant_response, context=assistant_context)
676+
assistant_turn = Turn(
677+
role=ConversationRole.ASSISTANT, content=assistant_response, context=assistant_context
678+
)
671679
conversation_history.add_to_history(assistant_turn)
672680
progress_bar.update(1)
673681

sdk/evaluation/azure-ai-evaluation/tests/unittests/test_built_in_evaluator.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ def test_retrieval_evaluator_keys(self, mock_model_config):
5959
conversation = {
6060
"messages": [
6161
{"role": "user", "content": "What is the value of 2 + 2?"},
62-
{"role": "assistant", "content": "2 + 2 = 4", "context": {
63-
"citations": [
62+
{
63+
"role": "assistant",
64+
"content": "2 + 2 = 4",
65+
"context": {
66+
"citations": [
6467
{"id": "math_doc.md", "content": "Information about additions: 1 + 2 = 3, 2 + 2 = 4"}
6568
]
66-
}
67-
}
69+
},
70+
},
6871
]
6972
}
7073

7174
result = retrieval_eval(conversation=conversation)
72-
assert result["retrieval"] == result["gpt_retrieval"] == 1
75+
assert result["retrieval"] == result["gpt_retrieval"] == 1

0 commit comments

Comments
 (0)