Skip to content
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

Adding properties to evaluation for UI rendering #37718

Merged
merged 4 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class DefaultOpenEncoding:
"""SDK Default Encoding when writing a file"""


class EvaluationRunProperties:
"""Defines properties used to identify an evaluation run by UI"""

RUN_TYPE = "runType"
EVALUATION_RUN = "_azureml.evaluation_run"


DEFAULT_EVALUATION_RESULTS_FILE_NAME = "evaluation_results.json"

CONTENT_SAFETY_DEFECT_RATE_THRESHOLD_DEFAULT = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .._constants import (
CONTENT_SAFETY_DEFECT_RATE_THRESHOLD_DEFAULT,
EvaluationMetrics,
EvaluationRunProperties,
Prefixes,
_InternalEvaluationMetrics,
)
Expand Down Expand Up @@ -346,7 +347,7 @@ def _apply_target_to_data(
flow=target,
display_name=evaluation_name,
data=data,
properties={"runType": "eval_run", "isEvaluatorRun": "true"},
properties={EvaluationRunProperties.RUN_TYPE: "eval_run", "isEvaluatorRun": "true"},
stream=True,
name=_run_name,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@

import pandas as pd

from azure.ai.evaluation._constants import DEFAULT_EVALUATION_RESULTS_FILE_NAME, DefaultOpenEncoding, Prefixes
from azure.ai.evaluation._constants import (
DEFAULT_EVALUATION_RESULTS_FILE_NAME,
DefaultOpenEncoding,
Prefixes,
EvaluationRunProperties,
)
from azure.ai.evaluation._evaluate._eval_run import EvalRun
from azure.ai.evaluation._exceptions import ErrorBlame, ErrorCategory, ErrorTarget, EvaluationException

Expand Down Expand Up @@ -112,7 +117,8 @@ def _log_metrics_and_instance_results(
if run is None:
ev_run.write_properties_to_run_history(
properties={
"_azureml.evaluation_run": "azure-ai-generative-parent",
EvaluationRunProperties.RUN_TYPE: "eval_run",
EvaluationRunProperties.EVALUATION_RUN: "azure-ai-generative-parent",
"_azureml.evaluate_artifacts": json.dumps([{"path": artifact_name, "type": "table"}]),
"isEvaluatorRun": "true",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
F1ScoreEvaluator,
FluencyEvaluator,
GroundednessEvaluator,
evaluate,
)


Expand Down Expand Up @@ -399,6 +400,7 @@ def test_evaluate_track_in_cloud(
# module named test_evaluate and it will be a different module in unit test
# folder. By keeping function in separate file we guarantee, it will be loaded
# from there.
# os.environ["AZURE_TEST_RUN_LIVE"] = "True"
from .target_fn import target_fn

f1_score_eval = F1ScoreEvaluator()
Expand All @@ -413,7 +415,6 @@ def test_evaluate_track_in_cloud(
)
row_result_df = pd.DataFrame(result["rows"])

assert "outputs.answer" in row_result_df.columns
assert "outputs.answer.length" in row_result_df.columns
assert list(row_result_df["outputs.answer.length"]) == [28, 76, 22]
assert "outputs.f1.f1_score" in row_result_df.columns
Expand All @@ -427,6 +428,7 @@ def test_evaluate_track_in_cloud(
assert remote_run is not None
assert remote_run["runMetadata"]["properties"]["azureml.promptflow.local_to_cloud"] == "true"
assert remote_run["runMetadata"]["properties"]["runType"] == "eval_run"
assert remote_run["runMetadata"]["properties"]["_azureml.evaluation_run"] == "promptflow.BatchRun"
assert remote_run["runMetadata"]["displayName"] == evaluation_name

@pytest.mark.skipif(in_ci(), reason="This test fails in CI and needs to be investigate. Bug: 3458432")
Expand Down Expand Up @@ -470,6 +472,7 @@ def test_evaluate_track_in_cloud_no_target(
remote_run = _get_run_from_run_history(run_id, azure_ml_client, project_scope)

assert remote_run is not None
assert remote_run["runMetadata"]["properties"]["runType"] == "eval_run"
assert remote_run["runMetadata"]["properties"]["_azureml.evaluation_run"] == "azure-ai-generative-parent"
assert remote_run["runMetadata"]["displayName"] == evaluation_name

Expand Down
Loading