Create store out_dir before writing excluded_reads.parquet
extract_store wrote the excluded-reads parquet before the shard writer created the output directory, so any fresh --out path failed with 'No such file or directory'. Add the mkdir (the docstring already promised 'created as needed') plus a regression test.
This commit is contained in:
@@ -180,6 +180,39 @@ def test_filter_excluded() -> None:
|
||||
assert counts4["n_rows_out"] == 5 and "reason" in dropped4.columns
|
||||
|
||||
|
||||
def test_extract_store_creates_missing_out_dir(tmp_path: Path) -> None:
|
||||
"""Regression: extract_store must create out_dir before writing artifacts.
|
||||
|
||||
The excluded-reads parquet is written before the shard writer gets to
|
||||
mkdir; a fresh nested --out used to die with "No such file or directory".
|
||||
"""
|
||||
import polars as pl
|
||||
|
||||
from custom_models.store import EXCLUDED_NAME, ExtractConfig, extract_store
|
||||
|
||||
labels = pl.DataFrame(
|
||||
{
|
||||
"read_id": ["r1"],
|
||||
"ref_name": ["DCS_Lambda"],
|
||||
"genus": ["escherichia"],
|
||||
"species": ["escherichia_coli"],
|
||||
"identity": [0.99],
|
||||
"aligned_len": [1000],
|
||||
"query_len": [1000],
|
||||
"source_run": ["run1"],
|
||||
}
|
||||
)
|
||||
cfg = ExtractConfig(
|
||||
pod5_paths=(tmp_path / "never-read.pod5",), exclude_refs=("dcs",)
|
||||
)
|
||||
# the only labelled read is excluded -> zero usable reads; the ValueError
|
||||
# fires after the (previously failing) excluded_reads.parquet write
|
||||
with pytest.raises(ValueError, match="non-null genus"):
|
||||
extract_store(cfg, labels, tmp_path / "nested" / "store")
|
||||
assert (tmp_path / "nested" / "store").is_dir()
|
||||
assert (tmp_path / "nested" / "store" / EXCLUDED_NAME).is_file()
|
||||
|
||||
|
||||
def test_config_roundtrip(tmp_path: Path) -> None:
|
||||
cfg = RunConfig(
|
||||
run_id="cnn_1.0M_s4_g11",
|
||||
|
||||
Reference in New Issue
Block a user