Skip to content
Draft
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 @@ -366,6 +366,8 @@ async def log_redteam_results_to_mlflow(
self.logger.debug(f"Logged metric: {risk_category}_{key} = {value}")

if self._one_dp_project:
run_id = getattr(eval_run, "id", "unknown")
run_display_name = getattr(eval_run, "display_name", None) or "unknown"
# Step 1: Upload evaluation results (blob upload + version create)
evaluation_result_id = None
try:
Expand All @@ -379,7 +381,10 @@ async def log_redteam_results_to_mlflow(
)
evaluation_result_id = create_evaluation_result_response.id
except Exception as e:
self.logger.error(f"Failed to create evaluation result: {str(e)}")
self.logger.error(
f"Failed to create evaluation result for run {run_id} ({run_display_name}): {str(e)}",
exc_info=True,
)

# Step 2: Always update the run status, even if result upload failed
outputs = None
Expand All @@ -399,7 +404,7 @@ async def log_redteam_results_to_mlflow(
)
self.logger.debug(f"Updated UploadRun: {update_run_response.id}")
except Exception as e:
self.logger.error(f"Failed to update red team run status: {str(e)}")
self.logger.error(f"Failed to update red team run status for run {run_id}: {str(e)}", exc_info=True)
else:
# Log the entire directory to MLFlow
try:
Expand Down Expand Up @@ -431,19 +436,23 @@ def update_run_status(self, eval_run, status: str) -> None:
"""
if not self._one_dp_project:
return
run_id = getattr(eval_run, "id", "unknown")
run_display_name = getattr(eval_run, "display_name", None)
try:
self.generated_rai_client._evaluation_onedp_client.update_red_team_run(
name=eval_run.id,
red_team=RedTeamUpload(
id=eval_run.id,
display_name=getattr(eval_run, "display_name", None)
or f"redteam-agent-{datetime.now().strftime('%Y%m%d-%H%M%S')}",
display_name=run_display_name or f"redteam-agent-{datetime.now().strftime('%Y%m%d-%H%M%S')}",
status=status,
),
)
self.logger.info(f"Updated red team run status to '{status}'")
self.logger.info(f"Updated red team run {run_id} status to '{status}'")
except Exception as e:
self.logger.error(f"Failed to update red team run status to '{status}': {str(e)}")
self.logger.error(
f"Failed to update red team run {run_id} status to '{status}': {str(e)}",
exc_info=True,
)

def _build_instance_results_payload(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,11 @@ async def scan(

# Process and return results
return await self._finalize_results(skip_upload, skip_evals, eval_run, output_path, scan_name)
except Exception:
except Exception as e:
self.logger.error(
f"Red team scan execution failed for run {getattr(eval_run, 'id', 'unknown')}: {str(e)}",
exc_info=True,
)
# Ensure the run status is updated to Failed if an upload was started
if not skip_upload and self.mlflow_integration is not None:
self.mlflow_integration.update_run_status(eval_run, "Failed")
Expand Down