Repository navigation
fix+feat: CSV column validation and scorer disagreement gate - #25
Merged
Merged
Conversation
) CSV loader (loaders.py): Missing 'sequence' column now raises ValueError with the actual column names found, instead of a bare KeyError — prevents cryptic crashes from mis-formatted input files before synthesis. Disagreement gate (pipeline.py + configs): Add max_disagreement to eligibility filter: eligible = [...and scores.get("disagreement", 0.0) <= max_disagreement] pipeline.yaml: max_disagreement=0.40 (lenient) phase3.yaml: max_disagreement=0.30 (strict — final synthesis batch needs consensus between physchem-activity and Boman index scorer) Default is 1.0 (off) so existing callers without the key are unaffected. Science rationale: a candidate with activity=0.9 but boman_activity=0.2 has high uncertainty; blocking it prevents wasting synthesis budget on contradictory predictions. Tests (4 new): test_missing_sequence_column_raises_value_error test_missing_sequence_column_error_names_found_columns test_disagreement_gate_blocks_high_uncertainty_candidate test_disagreement_gate_config_values_documented
…ositive control
pipeline.py: scores.get('disagreement', 0.0) → scores['disagreement']
Consistent with bracket access used for novelty/safety; if the key ever
goes missing the pipeline fails loudly instead of silently passing all
candidates through the disagreement gate.
loaders.py: validate CSV header before iterating rows
Check reader.fieldnames before the row loop so header-only files (zero
data rows) also raise ValueError. Per-row check was redundant once the
header is validated — removed. Error message now says 'CSV header is
missing' not 'CSV row 1 is missing' to avoid confusion.
test_data_loaders.py:
- import pytest at module level (was inside function — ruff PLC0415)
- add test_missing_sequence_column_fires_on_header_only_csv for zero-row case
- remove inline imports
test_pipeline_filters.py:
- add positive control to test_disagreement_gate_blocks_high_uncertainty_candidate:
same candidate is selected when max_disagreement=1.0 (relaxed gate), proving
the disagreement gate is the cause of blocking, not some other filter
- fix ruff E741: rename l → ln in list comprehensions
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.
Summary
1. Helpful CSV column validation (
loaders.py)Previously, a CSV with
seqinstead ofsequencewould crash with a bareKeyErrordeep in the pipeline — no file name, no row number, no hint of what was expected. Now it raisesValueErrorwith the actual columns found:2. Scorer disagreement hard gate (
pipeline.py+ configs)The pipeline already computed
disagreement = |activity - boman_activity|per candidate, but never used it as a filter. A candidate withactivity=0.9andboman_activity=0.2could still be nominated — contradictory signals with no resolution.New eligibility condition:
Config values added:
pipeline.yaml:max_disagreement: 0.40(lenient — allows some model spread)phase3.yaml:max_disagreement: 0.30(strict — final synthesis batch needs consensus)Default (when key absent):
1.0= gate is off, existing callers unaffected.Science rationale: two independent scoring approaches (physico-chemical features vs Boman interaction potentials) both predicting activity is better evidence than one score alone. High disagreement means we can't tell which model is right — don't spend synthesis money on it.
Test plan
test_missing_sequence_column_raises_value_error— correct error type and messagetest_missing_sequence_column_error_names_found_columns— error lists actual columns foundtest_disagreement_gate_blocks_high_uncertainty_candidate—max_disagreement=0.0rejects every real sequence (all have disagreement > 0)test_disagreement_gate_config_values_documented— pinspipeline.yaml=0.40,phase3.yaml=0.30, confirms phase3 is stricterruff check src tests— clean🤖 Generated with Claude Code