Skip to content

Commit

Permalink
Handle the error case
Browse files Browse the repository at this point in the history
  • Loading branch information
ninghu committed Jun 10, 2024
1 parent c82a84e commit a34447b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# ---------------------------------------------------------
import logging

import numpy as np

from promptflow.client import PFClient
from promptflow.tracing import ThreadPoolExecutorWithContext as ThreadPoolExecutor

Expand All @@ -20,9 +22,13 @@ def __init__(self, pf_client: PFClient):
self._thread_pool = ThreadPoolExecutor(thread_name_prefix="evaluators_thread")

def run(self, flow, data, column_mapping=None, **kwargs):
eval_future = self._thread_pool.submit(self._pf_client.run, flow, data=data, column_mapping=column_mapping)
eval_future = self._thread_pool.submit(
self._pf_client.run, flow, data=data, column_mapping=column_mapping, **kwargs
)
return ProxyRun(run=eval_future)

def get_details(self, proxy_run, all_results=False):
run = proxy_run.run.result(timeout=60 * 60)
return self._pf_client.get_details(run, all_results=all_results)
result_df = self._pf_client.get_details(run, all_results=all_results)
result_df.replace("(Failed)", np.nan, inplace=True)
return result_df
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def test_evaluate_output_path(self, evaluate_test_data_jsonl_file, tmpdir, use_t
def test_evaluate_with_errors(self):
"""Test evaluate_handle_errors"""
data = _get_file("yeti_questions.jsonl")
result = evaluate(data=data, evaluators={"yeti": _yeti_evaluator}, _use_thread_pool=True)
result = evaluate(data=data, evaluators={"yeti": _yeti_evaluator})
result_df = pd.DataFrame(result["rows"])
expected = pd.read_json(data, lines=True)
expected.rename(columns={"question": "inputs.question", "answer": "inputs.answer"}, inplace=True)
Expand Down

0 comments on commit a34447b

Please sign in to comment.