Skip to content

Commit dc4e341

Browse files
Expose log_test_result function as public API
This allows a user to skip most of the vm-library machinery and just send results to ValidMind. Amp-Thread-ID: https://ampcode.com/threads/T-0d15caf4-4ac4-4ff4-b7e1-9be6ed2590f7 Co-authored-by: Amp <amp@ampcode.com>
1 parent 7dcf19f commit dc4e341

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

validmind/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
from . import scorer
5252
from .__version__ import __version__ # noqa: E402
53-
from .api_client import init, log_metric, log_text, reload
53+
from .api_client import init, log_metric, log_test_result, log_text, reload
5454
from .client import ( # noqa: E402
5555
get_test_suite,
5656
init_dataset,
@@ -143,6 +143,7 @@ def check_version():
143143
"unit_metrics",
144144
"test_suites",
145145
"log_text",
146+
"log_test_result",
146147
# experimental features
147148
"experimental_agent",
148149
]

validmind/api_client.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,35 @@ async def alog_test_result(
365365
raise e
366366

367367

368+
def log_test_result(
369+
result: Dict[str, Any],
370+
section_id: str = None,
371+
position: int = None,
372+
unsafe: bool = False,
373+
config: Dict[str, bool] = None,
374+
) -> Dict[str, Any]:
375+
"""Logs test results information.
376+
377+
Args:
378+
result (dict): A dictionary representing the test result.
379+
section_id (str, optional): The section ID add a test driven block to the documentation.
380+
position (int): The position in the section to add the test driven block.
381+
unsafe (bool): If True, log the result even if it contains sensitive data.
382+
config (Dict[str, bool]): Configuration options for displaying the test result.
383+
384+
Returns:
385+
dict: The response from the API.
386+
"""
387+
return run_async(
388+
alog_test_result,
389+
result=result,
390+
section_id=section_id,
391+
position=position,
392+
unsafe=unsafe,
393+
config=config,
394+
)
395+
396+
368397
async def alog_input(
369398
input_id: str, type: str, metadata: Dict[str, Any]
370399
) -> Dict[str, Any]:

0 commit comments

Comments
 (0)