Evaluations
Hold one EvaluationClient across several calls, and handle the errors evaluation calls raise.
The class methods on the other Evaluations pages, such as Evaluation.create
and evaluation.run(), each construct a client for a single call. Hold an
EvaluationClient when you make several calls, or when you want it to borrow
credentials from a ConnectClient or a ChalkPy client you already have:
import chalkcompute
client = chalkcompute.EvaluationClient(chalk_client=my_chalk_client)
suite = client.create_suite("Release")
evaluation = client.create("Nightly", dataset=dataset, task=answer, scorers=[exact_match])
run = client.run(evaluation.id, metadata={"git_sha": "abc123"})
for candidate in client.list(suite_id=suite.id, limit=50):
print(candidate.name)
for previous in client.list_runs(evaluation_id=evaluation.id, limit=10):
print(previous.id, previous.status)
The client carries create_suite and list_suites for suites, create, get,
and list for definitions, and run, get_run, list_runs, and rescore for
runs. client.rescore(run_id, evaluation_id=...) is the call behind
run.rescore(), and evaluation_id defaults to the run’s own evaluation.
list and list_runs are generators that page in batches of up to 100 and stop
at limit. Pass only one of chalk_client or connect_client to the
constructor.
Every object a client returns keeps a reference to that client, which is what
makes evaluation.run(), run.refresh(), and suite.evaluations() work. A
handle you construct yourself has no client and raises EvaluationError on those
methods, so fetch it through the client instead.
A failed request raises EvaluationError, which carries status_code, the HTTP
equivalent of the underlying code. A missing evaluation or run raises
EvaluationNotFoundError, a subclass of it:
import chalkcompute
try:
evaluation = chalkcompute.Evaluation.from_id("does-not-exist")
except chalkcompute.EvaluationNotFoundError as e:
print(e.status_code) # 404
A run that fails or is canceled raises EvaluationRunFailedError out of
wait(), with the terminal handle attached so you can read its status and error
message. In this example, evaluation is an evaluation created as on the
Creating and Running page:
try:
run = evaluation.run().wait()
except chalkcompute.EvaluationRunFailedError as e:
print(e.run.status, e.run.error_message)
wait() raises TimeoutError when it runs out of time, as does a Trace read
that never settles. Local validation raises ValueError or TypeError for an
empty name, an empty scorer list, metadata that is not JSON-serializable, a score
outside [0, 1], or a bare callable passed as a task or scorer. That validation
runs before any request goes out, so a malformed call fails locally.
Archive a throwaway evaluation or an individual run by ID:
import chalkcompute
client = chalkcompute.EvaluationClient()
archived = client.archive("<evaluation-id>")
client.archive_run("<evaluation-run-id>")
You can also call evaluation.archive() or run.archive() on an existing
handle. Evaluation archival returns an updated handle with archived_at and
archived_by; it leaves the original handle unchanged. Run archival returns
None and clears the run’s baseline flag.
Archived evaluations and their runs are omitted from lists. Archiving an individual run hides only that run. You can still fetch archived records by ID. Archival preserves datasets and running work, and repeated calls succeed. Archiving a parent preserves each run’s individual archive state and baseline flag, so restoring the parent through the API does not restore individually archived runs.
The CLI exposes the same operations:
chalk eval archive <evaluation-id>
chalk eval run archive <evaluation-run-id>
In the dashboard, open a suite’s Definitions tab, open an evaluation’s three-dot menu, and choose Archive. To archive one run, open its three-dot menu in the Runs tab and choose Archive. The menus appear on row hover or keyboard focus and stay pinned to the right while the table scrolls horizontally. You can also right-click a row to open its actions.
On an evaluation or run detail page, use Archive in the top right. Confirm the dialog to archive. Archiving an evaluation hides it and all its runs from lists; archiving one run hides that run and clears its baseline flag. Datasets are preserved.
Delete unwanted datasets separately; see Deleting a dataset.