Skip to content

Commit 13aef37

Browse files
author
Andrei Bratu
committed
added test
1 parent 58aa2a4 commit 13aef37

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/humanloop/evals/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122
T = TypeVar("T") # Add TypeVar T definition
123123

124124

125-
126125
def print_error(message: str) -> None:
127126
"""Print a formatted error message to stdout."""
128127
sys.stdout.write(f"{RED}{message}{RESET}")
@@ -459,7 +458,7 @@ def _resolve_file(client: "BaseHumanloop", file_config: FileEvalConfig) -> tuple
459458
except ApiError:
460459
if not version or not path or file_id:
461460
raise HumanloopRuntimeError(
462-
"File does not exist on Humanloop. Please provide a `file.path` and a version to create a new version.",
461+
"File does not exist on Humanloop. Please provide a `file.path` and a `file.version` to create a new version.",
463462
)
464463
return _upsert_file(file_config=file_config, client=client), callable or None
465464

tests/custom/integration/test_evals.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,53 @@ async def my_async_flow(question: str) -> str:
457457
evaluation_id = evaluations_response.items[0].id
458458
runs_response = humanloop_client.evaluations.list_runs_for_evaluation(id=evaluation_id)
459459
assert runs_response.runs[0].status == "completed"
460+
461+
462+
async def test_eval_simple_async_callable(
463+
get_humanloop_client: GetHumanloopClientFn,
464+
eval_dataset: ResourceIdentifiers,
465+
output_not_null_evaluator: ResourceIdentifiers,
466+
sdk_test_dir: str,
467+
):
468+
humanloop_client = get_humanloop_client()
469+
470+
flow_path = f"{sdk_test_dir}/Test Async Flow"
471+
472+
# GIVEN a simple async callable
473+
async def my_async_callable(question: str) -> str:
474+
return "It's complicated don't worry about it!"
475+
476+
# WHEN we run an evaluation with the async callable
477+
humanloop_client.evaluations.run( # type: ignore [attr-defined]
478+
name="test_async_eval_run",
479+
file={
480+
"path": flow_path,
481+
"type": "flow",
482+
"version": {
483+
"attributes": {
484+
"foo": "bar",
485+
},
486+
},
487+
"callable": my_async_callable,
488+
},
489+
dataset={
490+
"path": eval_dataset.file_path,
491+
},
492+
evaluators=[
493+
{
494+
"path": output_not_null_evaluator.file_path,
495+
}
496+
],
497+
)
498+
499+
# THEN the Flow is created
500+
flow = humanloop_client.files.retrieve_by_path(path=flow_path)
501+
assert flow is not None
502+
503+
# THEN the evaluation finishes successfully
504+
evaluations_response = humanloop_client.evaluations.list(file_id=flow.id)
505+
assert evaluations_response.items and len(evaluations_response.items) == 1
506+
# THEN the evaluation is completed
507+
evaluation_id = evaluations_response.items[0].id
508+
runs_response = humanloop_client.evaluations.list_runs_for_evaluation(id=evaluation_id)
509+
assert runs_response.runs[0].status == "completed"

0 commit comments

Comments
 (0)