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

[pf-evals] Fix the user agent not populated #3309

Merged
merged 1 commit into from
May 17, 2024
Merged
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
14 changes: 9 additions & 5 deletions src/promptflow-evals/promptflow/evals/evaluate/_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,14 @@ def evaluate(
_validate_columns(input_data_df, evaluators, target=None, evaluator_config=evaluator_config)

# Batch Run
evaluator_info = {}
evaluators_info = {}
use_thread_pool = kwargs.get("_use_thread_pool", True)
batch_run_client = CodeClient() if use_thread_pool else pf_client

with BatchRunContext(batch_run_client):
for evaluator_name, evaluator in evaluators.items():
evaluator_info[evaluator_name] = {}
evaluator_info[evaluator_name]["run"] = batch_run_client.run(
evaluators_info[evaluator_name] = {}
evaluators_info[evaluator_name]["run"] = batch_run_client.run(
flow=evaluator,
run=target_run,
evaluator_name=evaluator_name,
Expand All @@ -388,10 +388,14 @@ def evaluate(
stream=True,
)

# get_details needs to be called within BatchRunContext scope in order to have user agent populated
for evaluator_name, evaluator_info in evaluators_info.items():
evaluator_info["result"] = batch_run_client.get_details(evaluator_info["run"], all_results=True)

# Concatenate all results
evaluators_result_df = None
for evaluator_name, evaluator_info in evaluator_info.items():
evaluator_result_df = batch_run_client.get_details(evaluator_info["run"], all_results=True)
for evaluator_name, evaluator_info in evaluators_info.items():
evaluator_result_df = evaluator_info["result"]

# drop input columns
evaluator_result_df = evaluator_result_df.drop(
Expand Down
Loading