-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Bugfix/aoai row mismatch #42466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nagkumar91
wants to merge
76
commits into
Azure:main
Choose a base branch
from
nagkumar91:bugfix/aoai_row_mismatch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+183
−39
Open
Bugfix/aoai row mismatch #42466
Changes from 71 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
4318329
Prepare evals SDK Release
192b980
Fix bug
758adb4
Fix for ADV_CONV for FDP projects
de09fd1
Update release date
ef60fe6
Merge branch 'main' into main
nagkumar91 8ca51d0
Merge branch 'Azure:main' into main
nagkumar91 98bfc3a
Merge branch 'Azure:main' into main
nagkumar91 a5f32e8
Merge branch 'Azure:main' into main
nagkumar91 5fd88b6
Merge branch 'Azure:main' into main
nagkumar91 51f2b44
Merge branch 'Azure:main' into main
nagkumar91 a5be8b5
Merge branch 'Azure:main' into main
nagkumar91 75965b7
Merge branch 'Azure:main' into main
nagkumar91 d0c5e53
Merge branch 'Azure:main' into main
nagkumar91 b790276
Merge branch 'Azure:main' into main
nagkumar91 d5ca243
Merge branch 'Azure:main' into main
nagkumar91 8d62e36
re-add pyrit to matrix
59a70f2
Change grader ids
4d146d7
Merge branch 'Azure:main' into main
nagkumar91 f7a4c83
Update unit test
79e3a40
replace all old grader IDs in tests
588cbec
Merge branch 'main' into main
nagkumar91 7514472
Update platform-matrix.json
nagkumar91 28b2513
Update test to ensure everything is mocked
8603e0e
tox/black fixes
895f226
Skip that test with issues
b4b2daf
Merge branch 'Azure:main' into main
nagkumar91 023f07f
update grader ID according to API View feedback
45b5f5d
Update test
1ccb4db
remove string check for grader ID
6fd9aa5
Merge branch 'Azure:main' into main
nagkumar91 f871855
Update changelog and officialy start freeze
59ac230
update the enum according to suggestions
794a2c4
update the changelog
b33363c
Finalize logic
464e2dd
Merge branch 'Azure:main' into main
nagkumar91 4585b14
Merge branch 'Azure:main' into main
nagkumar91 89c2988
Initial plan
Copilot 6805018
Fix client request ID headers in azure-ai-evaluation
Copilot aad48df
Fix client request ID header format in rai_service.py
Copilot db75552
Merge pull request #5 from nagkumar91/copilot/fix-4
nagkumar91 b8eebf3
Merge branch 'Azure:main' into main
nagkumar91 2899ad4
Merge branch 'Azure:main' into main
nagkumar91 c431563
Merge branch 'Azure:main' into main
nagkumar91 79ed63c
Merge branch 'Azure:main' into main
nagkumar91 a3be3fc
Merge branch 'Azure:main' into main
nagkumar91 056ac4d
Passing threshold in AzureOpenAIScoreModelGrader
1779059
Add changelog
43fecff
Adding the self.pass_threshold instead of pass_threshold
b0c102b
Merge branch 'Azure:main' into main
nagkumar91 7bf5f1f
Add the python grader
3248ad0
Remove redundant test
d76f59b
Add class to exception list and format code
4d60e43
Merge branch 'main' into feature/python_grader
nagkumar91 98d1626
Merge branch 'Azure:main' into main
nagkumar91 9248c38
Add properties to evaluation upload run for FDP
74b760f
Remove debug
23dbc85
Merge branch 'feature/python_grader'
467ccb6
Remove the redundant property
c2beee8
Merge branch 'Azure:main' into main
nagkumar91 be9a19a
Fix changelog
de3a1e1
Fix the multiple features added section
f9faa61
removed the properties in update
69e783a
Merge branch 'Azure:main' into main
nagkumar91 8ebea2a
Merge branch 'Azure:main' into main
nagkumar91 3f9c818
Merge branch 'Azure:main' into main
nagkumar91 3b3159c
Merge branch 'Azure:main' into main
nagkumar91 d78b834
Merge branch 'Azure:main' into main
nagkumar91 ae3fc52
Merge branch 'Azure:main' into main
nagkumar91 706c042
Merge branch 'Azure:main' into main
nagkumar91 4fa1981
fix(evaluation): pad AOAI grader results to expected_rows to prevent …
953bc77
Update the test and changelog
fa77849
Update sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evalua…
nagkumar91 4def576
Update sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evalua…
nagkumar91 6b71370
Fix the indent
b3af918
Lint fixes
54f7bc1
update cspell
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
sdk/evaluation/azure-ai-evaluation/tests/unittests/test_aoai_alignment_missing_rows.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
|
||
import logging | ||
from typing import List | ||
from unittest.mock import Mock, patch | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from azure.ai.evaluation._evaluate._evaluate_aoai import ( | ||
OAIEvalRunCreationInfo, | ||
_get_single_run_results, | ||
) | ||
|
||
|
||
class MockOutputItem: | ||
def __init__(self, id: str, datasource_item_id: int, results: List[dict]): | ||
self.id = id | ||
self.datasource_item_id = datasource_item_id | ||
self.results = results | ||
|
||
|
||
class MockOutputItemsList: | ||
def __init__(self, data, has_more=False): | ||
self.data = data | ||
self.has_more = has_more | ||
|
||
|
||
@pytest.mark.unittest | ||
def test_aoai_results_preserve_order_with_unordered_output_items(caplog): | ||
"""AOAI output_items can arrive unordered; results should align to row ids (0..N-1).""" | ||
mock_client = Mock() | ||
expected_rows = 5 | ||
run_info = OAIEvalRunCreationInfo( | ||
client=mock_client, | ||
eval_group_id="grp", | ||
eval_run_id="run", | ||
grader_name_map={"grader-1": "rel"}, | ||
expected_rows=expected_rows, | ||
) | ||
|
||
# Completed run; pass_rate comes from per_testing_criteria_results | ||
mock_run_results = Mock() | ||
mock_run_results.status = "completed" | ||
mock_run_results.per_testing_criteria_results = [Mock(testing_criteria="grader-1", passed=4, failed=1)] | ||
|
||
# Unordered items: ids [3,0,4,1,2]; score equals its id for easy checks | ||
unordered_items = [ | ||
MockOutputItem(id="i3", datasource_item_id=3, results=[{"name": "grader-1", "passed": True, "score": 3.0}]), | ||
MockOutputItem(id="i0", datasource_item_id=0, results=[{"name": "grader-1", "passed": True, "score": 0.0}]), | ||
MockOutputItem(id="i4", datasource_item_id=4, results=[{"name": "grader-1", "passed": False, "score": 4.0}]), | ||
MockOutputItem(id="i1", datasource_item_id=1, results=[{"name": "grader-1", "passed": True, "score": 1.0}]), | ||
MockOutputItem(id="i2", datasource_item_id=2, results=[{"name": "grader-1", "passed": True, "score": 2.0}]), | ||
] | ||
mock_client.evals.runs.output_items.list.return_value = MockOutputItemsList(data=unordered_items, has_more=False) | ||
|
||
caplog.set_level(logging.WARNING, logger="azure.ai.evaluation._evaluate._evaluate_aoai") | ||
|
||
with patch( | ||
"azure.ai.evaluation._evaluate._evaluate_aoai._wait_for_run_conclusion", | ||
return_value=mock_run_results, | ||
): | ||
df, metrics = _get_single_run_results(run_info) | ||
|
||
# Shape and index | ||
assert len(df) == expected_rows | ||
assert list(df.index) == list(range(expected_rows)) | ||
|
||
score_col = "outputs.rel.score" | ||
assert score_col in df.columns | ||
|
||
# Each row i should have score == float(i), proving correct alignment after sort/reindex | ||
for i in range(expected_rows): | ||
assert df.loc[i, score_col] == float(i) | ||
|
||
# No missing-row padding in this test; the row_missing flag should not exist | ||
missing_flag_col = "outputs.rel.row_missing" | ||
assert missing_flag_col not in df.columns | ||
|
||
# Pass rate surfaced from per_testing_criteria_results | ||
assert metrics["rel.pass_rate"] == 4 / 5 | ||
|
||
# No warning about padding missing rows in this scenario | ||
assert not any( | ||
"missing row(s) padded with NaN for alignment" in rec.message | ||
for rec in caplog.records | ||
if rec.levelno >= logging.WARNING | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we know for which row we did not get result ?