Skip to content

Export EvaluationModuleError and wrap _compute failures (fixes #758)#768

Open
Robby955 wants to merge 1 commit into
huggingface:mainfrom
Robby955:fix/export-evaluation-module-error
Open

Export EvaluationModuleError and wrap _compute failures (fixes #758)#768
Robby955 wants to merge 1 commit into
huggingface:mainfrom
Robby955:fix/export-evaluation-module-error

Conversation

@Robby955

Copy link
Copy Markdown

Raw exceptions from a metric's _compute (for example sklearn ValueError or KeyError) currently propagate to callers of compute() unchanged, and there is no public evaluate error type to catch, so users fall back on a broad except Exception.

This adds an EvaluationModuleError class, exports it from the package, and wraps failures coming out of _compute in it. The original exception is kept on cause so tracebacks and debugging are unaffected.

Note: the linked issue assumed EvaluationModuleError already existed internally; it did not, so this PR also defines the class.

Added tests in tests/test_metric.py covering that the error is importable from the public API and that a failing _compute raises EvaluationModuleError rather than a bare ValueError.

Fixes #758

Raw exceptions from a metric's _compute (for example sklearn ValueError or
KeyError) previously propagated to callers of compute() unchanged, and there
was no public error type to catch. Add EvaluationModuleError, export it from
the package, and wrap failures from _compute in it while preserving the
original exception as __cause__.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EvaluationModuleError not exported from public API — sklearn errors leak to users

1 participant