Skip to content

test: external_predict and config coverage — final pre-synthesis gates - #21

Merged
cschanhniem merged 2 commits into
mainfrom
feat/external-predict-config-tests
Jun 28, 2026
Merged

cschanhniem merged 2 commits into
mainfrom
feat/external-predict-config-tests

Conversation

@cschanhniem

Copy link
Copy Markdown
Collaborator

Summary

  • 31 new tests in tests/test_external_predict.py for the mandatory pre-synthesis external validation gate (write_pilot_fasta, write_external_predict_checklist, write_confident_panel)
  • 11 new tests in tests/test_config.py for load_config including the real pipeline.yaml

These were the two CRITICAL zero-coverage gaps before synthesis spend.

What's tested

write_pilot_fasta — FASTA file format: one >id|rank=N|seed=S header per candidate, sequence on next line, file ends with newline, missing optional fields don't crash, empty panel produces empty-like file, parent directories created

write_external_predict_checklist — markdown output: all three tools (CAMPR4, AMPScanner v2, dbAMP 2.0) present, panel size in text, result table rows contain each candidate ID, ≥2/3 agreement rule stated, synthesis stop gate present, disclaimer text present, generated_at conditional inclusion, fasta path referenced

write_confident_panel — filtering: keeps only specified IDs, re-ranks kept candidates starting at 1, empty keep_ids returns empty, unknown IDs silently ignored, writes .csv and .md outputs

load_config — valid YAML, real configs/pipeline.yaml integrity (filters, weights sum to 1.0, selection keys), string path accepted, missing file raises FileNotFoundError, empty YAML, list/numeric/bool values preserved

Test plan

  • 42 new tests pass in isolation
  • Full suite: 705 passed (was 663)
  • Pre-push hook passes

…gates

- tests/test_external_predict.py (31 tests):
  write_pilot_fasta: file creation, FASTA header format (id/rank/seed), sequence
  body, empty panel, missing optional fields, newline termination
  write_external_predict_checklist: all 3 tools named, panel size, result table
  rows, 2/3-agreement gate, disclaimer, generated_at conditional, fasta path ref
  write_confident_panel: keeps only specified IDs, re-ranks 1..n, handles empty
  and nonexistent IDs, writes .csv and .md outputs

- tests/test_config.py (11 tests):
  load_config: valid YAML, real pipeline config (filters/weights/selection),
  weights sum to 1.0, string path, missing file raises, empty YAML, list/numeric/bool
  values preserved

705 tests total (was 663).
…ormed YAML test

test_external_predict.py:
- fix E741: rename l → line in list comprehension
- add test_empty_sequence_in_candidate_writes_blank_body_line: documents that
  callers must validate sequences before write_pilot_fasta (blank FASTA body line
  risks silent misparse by external prediction tools)
- add test_output_order_follows_panel_not_keep_ids: documents that keep_ids order
  is not honoured — output order is always panel order
- fix test_two_thirds_agreement_rule_stated: use '≥2' or '2/3' instead of '2'

config.py:
- load_config now raises ValueError('Config file is empty') when yaml.safe_load
  returns None; protects all downstream callers expecting a dict

test_config.py:
- test_empty_yaml_raises: replaces test_empty_yaml_returns_none_or_dict (was
  accepting None which would crash any caller doing result['key'])
- test_malformed_yaml_raises: new test verifying yaml.YAMLError propagates
- test_default_config_weights_are_positive: replaces fragile sum-to-1.0 check
  (ensemble scorer normalises by total weight so sum doesn't have to be 1.0)
- test_default_config_selection_present: add max_safety_risk assertion
@cschanhniem
cschanhniem merged commit 26bb21f into main Jun 28, 2026
1 of 2 checks passed
@cschanhniem
cschanhniem deleted the feat/external-predict-config-tests branch June 28, 2026 01:18
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.

1 participant