Skip to content

fix(py): type evaluator callbacks as BaseEvalDataPoint - #5995

Closed
a2105z wants to merge 1 commit into
genkit-ai:mainfrom
a2105z:fix/py-evaluator-base-eval-datapoint
Closed

a2105z wants to merge 1 commit into
genkit-ai:mainfrom
a2105z:fix/py-evaluator-base-eval-datapoint

Conversation

@a2105z

@a2105z a2105z commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Change Python EvaluatorFn to take BaseEvalDataPoint (test_case_id: str) instead of BaseDataPoint (test_case_id optional), matching the JS evaluator API.
  • Construct a BaseEvalDataPoint in the stepper (UUID fill-in) before calling the callback, without mutating the dataset BaseDataPoint.
  • Update first-party evaluators (genkit-evaluators, google-genai Vertex evaluators) and the evaluators sample to use the required id directly.
  • Add regression tests for id fill-in / non-mutation and callback typing.

Fixes genkit-ai/genkit-python#230

cc @jeffdh5

Test plan

  • pytest evaluator helper + veneer eval + genkit-evaluators tests (10 passed)
  • Confirm a custom evaluator can use datapoint.test_case_id without or '' under the typechecker

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the evaluator typing system to ensure that evaluator callbacks receive a BaseEvalDataPoint with a guaranteed test_case_id instead of a BaseDataPoint where the ID is optional. A helper function _as_eval_datapoint has been introduced to automatically generate a UUID for missing test case IDs without mutating the original dataset. Corresponding updates have been made across various plugins, tests, and samples. There are no review comments, so I have no feedback to provide.

@a2105z

a2105z commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@jeffdh5 ready for review when you have a moment.

This mirrors the JS EvaluatorFn / BaseEvalDataPoint split, and I reconfirmed the evaluator tests pass locally (helper + veneer eval + genkit-evaluators). Happy to adjust anything.

The evaluator stepper always assigns a test_case_id before invoking the
callback, so type EvaluatorFn with BaseEvalDataPoint (required id) like
JS does, and drop the `or ''` fallbacks in built-in evaluators. The
dataset stays BaseDataPoint and is no longer mutated. Export
BaseEvalDataPoint from genkit.evaluator.

Fixes #5991

Co-authored-by: Cursor <cursoragent@cursor.com>
@a2105z
a2105z force-pushed the fix/py-evaluator-base-eval-datapoint branch from 0e0ca82 to 9688047 Compare October 5, 2026 16:19
@a2105z

a2105z commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@jeffdh5 @huangjeff5, could one of you take a look when you have a moment?

I rebased this onto current main. The evaluator stepper changed a lot since I opened it (span handling and per-row failure recording), so I re-applied the change on top of the new code instead of merging mechanically:

  • EvaluatorFn now receives BaseEvalDataPoint (required test_case_id), matching JS. The or '' fallbacks are gone from the built-in evaluators, the Vertex evaluators, and the sample.
  • The dataset stays BaseDataPoint and is no longer mutated. The id is filled in on a copy that is passed to the callback.
  • BaseEvalDataPoint is exported from genkit.evaluator, since the public-surface cleanup in feat(py)!: clean up exported symbols on the core API surface #6390 no longer exposes it there.

The genkit, genkit-evaluators, and genkit-google-genai tests pass locally (2062 passed), and pyright is clean on the changed files. Fixes genkit-ai/genkit-python#230. Thanks!

@MichaelDoyle

Copy link
Copy Markdown
Contributor

Closing as obsolete: Python SDK development has moved to https://github.com/genkit-ai/genkit-python, and evaluators were removed from Python 1.0 in genkit-ai/genkit-python#37.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

py: type evaluator callbacks as BaseEvalDataPoint

2 participants