Fix FileDetector output/result misalignment (yield None for skipped outputs)#1883
Open
AUTHENSOR wants to merge 1 commit into
Open
Fix FileDetector output/result misalignment (yield None for skipped outputs)#1883AUTHENSOR wants to merge 1 commit into
AUTHENSOR wants to merge 1 commit into
Conversation
…utputs) FileDetector.detect() used `continue` to skip missing/empty/non-file outputs, which made detector_results SHORTER than attempt.outputs. The evaluator then indexed attempt.outputs by position (evaluators.base.Evaluator.evaluate: `messages.append(attempt.outputs[idx])`), misattributing later detector scores to the WRONG outputs and silently dropping some from scoring entirely. The hitlog recorded incorrect output<->score pairings. Concrete: with outputs [valid.pkl, /missing, valid.txt], FileDetector yielded [1.0, 0.0] (dropping the missing file). The evaluator then attributed the 0.0 (valid.txt) to outputs[1] (/missing), and outputs[2] was never scored. Fix: yield None for skipped outputs instead of `continue`, preserving length alignment with attempt.outputs. The evaluator already counts None scores as `nones` (excluded from pass/fail), so this is the correct signal. The existing test_filedetector_nonexist asserted `len(results) == 0` for skipped outputs -- this encoded the buggy behavior; updated to assert length alignment + None for skipped. Signed-off-by: John Kearney <johndanielkearney@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
FileDetectoroutput/result misalignment (yieldNonefor skipped outputs)Summary
FileDetector.detect()usedcontinueto skip missing/empty/non-file outputs,which made
detector_resultsshorter thanattempt.outputs. The evaluatorthen indexes
attempt.outputsby position, so this misattributed laterdetector scores to the wrong outputs and silently dropped some from scoring.
The hitlog recorded incorrect output↔score pairings.
The fix yields
Nonefor skipped outputs, preserving length alignment. Theevaluator already counts
Nonescores asnones(excluded from pass/fail), sothis is the correct downstream signal.
The bug
The evaluator consumes these results positionally:
When
FileDetectorskips an output, the results list shifts — sooutputs[idx]no longer corresponds to the output that produced
results[idx]. The code evendocuments the assumption: "expects that detector_results aligns with
attempt.outputs".
Reproduction
The fix
Yielding
Nonefor skipped outputs keepsdetector_resultslength-alignedwith
attempt.outputs. The evaluator already handlesNone:Tests
Updated
test_filedetector_nonexist(it previously assertedlen(results) == 0for skipped files — encoding the buggy behavior) and added 3 alignment tests to
tests/detectors/test_detectors_base.py:None, so the valid files' scores stay aligned ([1.0, None, 0.0]).Nonerather than being dropped.Impact
FileDetectorsubclasses —FileIsPickled,FileIsExecutable,PossiblePickleNameindetectors/fileformats.py— andany third-party subclass.
or non-file (e.g. a broken model-repo download, a non-file path).
detector hits to the wrong prompts produces unreliable reports. Verified
against the three built-in fileformat detectors.
Scope
Single-purpose: one fix in
FileDetector.detect+ tests. Diff: +94/−3 across2 files. No changes to any probe, evaluator, or other detector class.
Notes
FileIsPickled,FileIsExecutable,PossiblePickleName) produce aligned results after thefix.
Nonehandling predates this change — it was already designedto accept
Nonescores (e.g.StringDetectoryieldsNoneforNoneoutputs). This fix makes
FileDetectorconsistent with that contract.