Skip to content
Open
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
41 changes: 21 additions & 20 deletions evalbench/evaluator/agentevaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(

runner_config = self.config.get("runners", {})
self.agent_runners = runner_config.get("agent_runners", 10)
self.agentrunner = mprunner.MPRunner(self.agent_runners)

def evaluate(
self,
Expand All @@ -73,35 +72,37 @@ def _evaluate_agent_cli(
generator_name = type(self.generator).__name__
logging.info(f"Running {generator_name} evaluation")

self.agentrunner.futures.clear()

# Extract generic metadata
metadata = {
"dialects": self.config.get("dialects", []),
"database": self.config.get("database", "unknown"),
"scorers": self.config.get("scorers", {}),
}

for item in dataset:
simulated_user = SimulatedUser(self.config)
work = AgentGenWork(
processor=self.process_scenario,
eval_result=item,
job_id=job_id,
metadata=metadata,
simulated_user=simulated_user
)
self.agentrunner.execute_work(work)
self.agentrunner = mprunner.MPRunner(self.agent_runners)
try:
for item in dataset:
simulated_user = SimulatedUser(self.config)
work = AgentGenWork(
processor=self.process_scenario,
eval_result=item,
job_id=job_id,
metadata=metadata,
simulated_user=simulated_user
)
self.agentrunner.execute_work(work)

for future in concurrent.futures.as_completed(self.agentrunner.futures):
item = future.result()
for future in concurrent.futures.as_completed(self.agentrunner.futures):
item = future.result()

if hasattr(item, "agent_results"):
eval_outputs.extend(item.agent_results)
if hasattr(item, "scoring_results"):
scoring_results.extend(item.scoring_results)
if hasattr(item, "agent_results"):
eval_outputs.extend(item.agent_results)
if hasattr(item, "scoring_results"):
scoring_results.extend(item.scoring_results)

return eval_outputs, scoring_results
return eval_outputs, scoring_results
finally:
self.agentrunner.shutdown()

def process_scenario(
self,
Expand Down
57 changes: 29 additions & 28 deletions evalbench/evaluator/cortadoevaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,47 @@ def __init__(self, config):

runner_config = self.config.get("runners", {})
self.agent_runners = runner_config.get("agent_runners", 10)
self.agentrunner = mprunner.MPRunner(self.agent_runners)

def evaluate(self, dataset: List[EvalCortadoRequest], job_id: str, run_time: datetime.datetime):
eval_outputs: List[Any] = []
scoring_results: List[Any] = []
logging.info("Running Cortado gRPC evaluation")

self.agentrunner.futures.clear()

metadata = {
"dialects": self.config.get("dialects", []),
"database": self.config.get("database", "unknown"),
"scorers": self.config.get("scorers", {}),
}

# Spin up threads for concurrent conversation processing
for item in dataset:
simulated_user = SimulatedUser(self.config)
work = AgentGenWork(
processor=self.process_scenario,
eval_result=item,
job_id=job_id,
metadata=metadata,
simulated_user=simulated_user
)
self.agentrunner.execute_work(work)

for future in concurrent.futures.as_completed(self.agentrunner.futures):
try:
# This now contains the returned object from process_scenario
modified_item = future.result()
if hasattr(modified_item, "agent_results"):
eval_outputs.extend(modified_item.agent_results)
if hasattr(modified_item, "scoring_results"):
scoring_results.extend(modified_item.scoring_results)
except Exception as e:
logging.error(
f"Error getting result from future: {e}", exc_info=True)

return eval_outputs, scoring_results
self.agentrunner = mprunner.MPRunner(self.agent_runners)
try:
# Spin up threads for concurrent conversation processing
for item in dataset:
simulated_user = SimulatedUser(self.config)
work = AgentGenWork(
processor=self.process_scenario,
eval_result=item,
job_id=job_id,
metadata=metadata,
simulated_user=simulated_user
)
self.agentrunner.execute_work(work)

for future in concurrent.futures.as_completed(self.agentrunner.futures):
try:
# This now contains the returned object from process_scenario
modified_item = future.result()
if hasattr(modified_item, "agent_results"):
eval_outputs.extend(modified_item.agent_results)
if hasattr(modified_item, "scoring_results"):
scoring_results.extend(modified_item.scoring_results)
except Exception as e:
logging.error(
f"Error getting result from future: {e}", exc_info=True)

return eval_outputs, scoring_results
finally:
self.agentrunner.shutdown()

def process_scenario(
self, scenario: Dict[str, Any], eval_result: Any, job_id: str,
Expand Down
10 changes: 8 additions & 2 deletions evalbench/evaluator/dataengineeringagentevaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __init__(self, config: dict[str, Any]) -> None:

runner_config = self.config.get("runners", {})
self.agent_runners = runner_config.get("agent_runners", 10)
self.agentrunner = mprunner.MPRunner(self.agent_runners)

def _get_session_dir(self, job_id: str) -> str:
"""Resolves the session directory path for a given job ID."""
Expand Down Expand Up @@ -119,7 +118,7 @@ def evaluate(
"'dataform_workspace', 'gcp_project_id', and 'gcp_region' in your run config."
)

self.agentrunner.futures.clear()
self.agentrunner = mprunner.MPRunner(self.agent_runners)

metadata = {
"dialects": self.config.get("dialects", []),
Expand Down Expand Up @@ -150,6 +149,13 @@ def evaluate(
except Exception as e:
logger.exception(f"Error getting result from future: {e}")
finally:
# Shut down before archiving. On the normal path as_completed has
# already drained every scenario, so this cancels nothing. On the
# error path it stops scenarios that are still queued from mutating
# the Dataform workspace while _archive_workspace_to_gcs zips it. A
# scenario already running is not interrupted, so the archive can
# still catch one mid-write.
self.agentrunner.shutdown()
self._archive_workspace_to_gcs(workspace_uri, job_id, dataset)

return eval_outputs, scoring_results
Expand Down
Loading
Loading