Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

debug(benchmark): Add log statement to validator on `TestResult`

Reinier van der Leer09c307d6796b
diff --git a/benchmark/agbenchmark/reports/processing/report_types.py b/benchmark/agbenchmark/reports/processing/report_types.py
index 2ed4acf3bf..0475455a71 100644
--- a/benchmark/agbenchmark/reports/processing/report_types.py
+++ b/benchmark/agbenchmark/reports/processing/report_types.py
@@ -2,11 +2,13 @@
Model definitions used internally and for reports generated during command-line runs.
"""
+import logging
from typing import Any, Dict, List
from pydantic import BaseModel, Field, constr, validator
datetime_format = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+00:00$"
+logger = logging.getLogger(__name__)
class TestResult(BaseModel):
@@ -27,6 +29,12 @@ class TestResult(BaseModel):
@validator("fail_reason")
def success_xor_fail_reason(cls, v: str | None, values: dict[str, Any]):
+ if bool(v) == bool(values["success"]):
+ logger.error(
+ "Error validating `success ^ fail_reason` on TestResult: "
+ f"success = {repr(values['success'])}; "
+ f"fail_reason = {repr(v)}"
+ )
if v:
success = values["success"]
assert not success, "fail_reason must only be specified if success=False"