Skip to content

Surface mount-time startup errors without stack traces#12

Merged
jeromekelleher merged 2 commits intosgkit-dev:mainfrom
jeromekelleher:UI-improvements
May 7, 2026
Merged

Surface mount-time startup errors without stack traces#12
jeromekelleher merged 2 commits intosgkit-dev:mainfrom
jeromekelleher:UI-improvements

Conversation

@jeromekelleher
Copy link
Copy Markdown
Member

Running mount-plink against an unsupported VCZ (e.g. multi-allelic) used to dump two tracebacks: one from the plink-server subprocess crashing on the unhandled ValueError out of generate_bim, and one from Click on the parent's uncaught OSError after the connect deadline expired.

Running mount-plink against an unsupported VCZ (e.g. multi-allelic) used
to dump two tracebacks: one from the plink-server subprocess crashing on
the unhandled ValueError out of generate_bim, and one from Click on the
parent's uncaught OSError after the connect deadline expired.

_server_main now wraps its body so startup failures log a single ERROR
line (visible by default) plus a DEBUG traceback (only at -v), then
return cleanly. PlinkClient detects an exited subprocess in both the
pre-connect retry loop and the post-handshake failure path, surfacing a
single OSError(EIO, "plink-server exited during startup; see log above
for details"). The CLI's handle_exception decorator catches OSError too,
so the user sees one Error: line instead of a Python traceback.
vcztools' BedEncoder refuses any reader with set_variant_filter()
configured, so the bcftools-style filters mount-plink advertises
(--max-alleles, --types, --include, ...) all failed at first connection
with NotImplementedError. The error message biofuse prints on
multi-allelic input even points users at --max-alleles 2 as the
workaround, but it didn't work.

_server_main now calls reader.materialise_variant_filter() between
make_reader_from_options and _ServerSession. The call is a no-op when
no filter is configured; otherwise it walks the chunk plan, evaluates
the filter, and replaces (variant_filter, plan) with a fixed plan over
the surviving variants — exactly what BedEncoder expects.

_ServerSession.bed_size also switches from reader.num_variants (raw
store count) to variant_counts_per_chunk().sum() (planned count) so
.bed and .bim agree once a filter has been baked in.

Tests cover --max-alleles 2 end-to-end via the CLI and through
PlinkClient.start(reader_options=...) on the multi-allelic fixture;
both assert .bim line count drops to fx_multiallelic_vcz.num_biallelic_sites
(1309 vs 1382). VczFixture grows a num_biallelic_sites field computed
at fixture-build time from variant_allele via zarr, mirroring vcztools'
own _check_biallelic acceptance rule.
@jeromekelleher jeromekelleher merged commit c535b23 into sgkit-dev:main May 7, 2026
5 checks passed
@jeromekelleher jeromekelleher deleted the UI-improvements branch May 7, 2026 11:39
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