feat(evaluation) 2/15: test-set parsing and file_id normalisation - #813
feat(evaluation) 2/15: test-set parsing and file_id normalisation#813Ahmath-Gadji wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds public evaluation exports, filename sanitization, strict UTF-8 CSV test-set parsing, validation errors, optional file identifiers, row limits, and comprehensive unit tests. ChangesEvaluation test-set support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Upload
participant parse_testset
participant EvalTestCase
Upload->>parse_testset: CSV bytes or text
parse_testset->>parse_testset: validate headers and rows
parse_testset->>EvalTestCase: build ordered cases
parse_testset-->>Upload: cases or ValidationError
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openrag/core/evaluation/testset.py`:
- Around line 44-45: Update _split_file_ids in
openrag/core/evaluation/testset.py at lines 44-45 to apply sanitize_file_id() to
each non-empty trimmed ID before returning the tuple. Add a unit test in
tests/unit/core/evaluation/test_testset.py at lines 20-27 asserting that “A
B.pdf” parses to “A_B.pdf”.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2336df91-037c-4fd7-918a-7fc3df9ca5ee
📒 Files selected for processing (4)
openrag/core/evaluation/__init__.pyopenrag/core/evaluation/identity.pyopenrag/core/evaluation/testset.pytests/unit/core/evaluation/test_testset.py
7a9a880 to
9407f34
Compare
40c5277 to
18bd516
Compare
18bd516 to
cfa53f9
Compare
a9f7fd5 to
7b7f3fe
Compare
cfa53f9 to
fe67a25
Compare
`parse_testset` reads the admin-uploaded CSV (`question,expected_answer,expected_file_ids`) into `EvalTestCase` rows and rejects a malformed file at upload time rather than after a run has already spent minutes indexing a corpus. `sanitize_file_id` maps a corpus filename onto an id the indexing API will accept — it allows only `[A-Za-z0-9._:-]`, so a file cannot be uploaded under a raw human filename. It lives on its own because both sides of the ground-truth comparison have to apply it: the uploader (part 9) and the metrics (part 4). A test set naming `A B.pdf` still matches the stored `A_B.pdf`.
fe67a25 to
8e008f2
Compare
hedhoud
left a comment
There was a problem hiding this comment.
The parser is going in the right direction, but I found two cases that can make the evaluation results unreliable.
Different filenames can currently produce the same file ID. For example, A B.pdf and A_B.pdf both become A_B.pdf. If both are in the corpus, one upload will fail and the metrics may match the wrong file. The generated ID should stay unique, or the upload should reject that collision with a clear error.
Malformed CSV rows can also be silently dropped. A row with only expected_file_ids, or a row with more values than its header, can be accepted without telling the user that some data was ignored. Please reject any non-empty malformed row and add tests for these cases. It would also be useful to report the CSV reader’s real line number when blank lines are present.
Once these cases are covered, this should be safe to move forward.
Part 2 of 15 of the split of #811. Targets
eval/01-config-and-models(#812) — merge that first.What
The first two pieces of
core/evaluation/, both pure functions with no I/O.parse_testset— reads the admin-uploaded CSV (question,expected_answer,expected_file_ids) intoEvalTestCaserows, under a row cap.expected_file_idsis optional and;-separated.sanitize_file_id— maps a corpus filename onto an id the indexing API accepts.Notable
identity.pyis its own module. The indexing API allows only[A-Za-z0-9._:-]in afile_id, so a corpus file cannot be uploaded under a raw human filename. Both sides of the ground-truth comparison must therefore normalise: the uploader (part 9) and the metrics (part 4). A test set namingA B.pdfmatches the storedA_B.pdfonly because one function owns that mapping.create_datasetfor that reason.Testing
12 new unit tests over the parser: header validation, the optional third column, blank and malformed rows, the row cap, and encoding.
ruff, format check and the layer-import guard pass.Summary by CodeRabbit