Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test to ensure failures don't tank the workflow run #241

Merged
merged 1 commit into from
Feb 23, 2024
Merged
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
26 changes: 26 additions & 0 deletions tests/langkit/callbacks/test_webhook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from langkit.callbacks.library import lib as callback_lib
from langkit.core.validation import ValidationFailure
from langkit.core.workflow import EvaluationWorkflow
from langkit.metrics.library import lib as metric_lib
from langkit.validators.library import lib as validator_lib


def test_webhook_failures_dont_ruin_run():
wf = EvaluationWorkflow(
metrics=[metric_lib.text_stat.char_count.prompt],
validators=[validator_lib.constraint("prompt.char_count", upper_threshold=5)],
callbacks=[callback_lib.webhook.basic_validation_failure("https://foo.bar")], # will fail, url doesn't exist
)

result = wf.run({"prompt": "1234567890"})

assert result.validation_results.report == [
ValidationFailure(
id="0",
metric="prompt.char_count",
details="Value 10 is above threshold 5",
value=10,
upper_threshold=5,
)
]
assert result.metrics["prompt.char_count"][0] == 10
Loading