Skip to content

Add stdin support to the tskit CLI#3469

Merged
jeromekelleher merged 3 commits into
tskit-dev:mainfrom
chris-a-talbot:feature/cli-stdin
Jun 25, 2026
Merged

Add stdin support to the tskit CLI#3469
jeromekelleher merged 3 commits into
tskit-dev:mainfrom
chris-a-talbot:feature/cli-stdin

Conversation

@chris-a-talbot

Copy link
Copy Markdown
Contributor

Closes #3468.

CLI commands that load a tree sequence now accept - as the input path to read from stdin. This allows workflows such as

python -m tszip -d my_file.tsz -c | python -m tskit vcf - > my_file.vcf

to convert a .tsz file to VCF.

@hyanwong hyanwong requested a review from benjeffery June 20, 2026 08:38
@hyanwong

Copy link
Copy Markdown
Member

Nice, thanks. LGTM, but maybe someone else could check it over too?

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.67%. Comparing base (df2a253) to head (780edc0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3469   +/-   ##
=======================================
  Coverage   91.67%   91.67%           
=======================================
  Files          38       38           
  Lines       32186    32188    +2     
  Branches     5150     5151    +1     
=======================================
+ Hits        29505    29509    +4     
+ Misses       2348     2346    -2     
  Partials      333      333           
Flag Coverage Δ
C 82.23% <ø> (ø)
c-python 77.54% <ø> (ø)
python-tests 96.43% <100.00%> (+0.02%) ⬆️
python-tests-no-jit 33.19% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Python API 98.72% <100.00%> (+0.02%) ⬆️
Python C interface 91.23% <ø> (ø)
C library 91.24% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeromekelleher

Copy link
Copy Markdown
Member

Thanks @chris-a-talbot - I'll have a good look at this in the next few days

chris-a-talbot and others added 2 commits June 23, 2026 16:31
Update changelog to reflect stdin CLI feature
Update the CLI tests to cover reading a tree sequence from stdin when the
positional path argument is omitted, replacing the stale tests written for
the earlier '-' convention. Adds in-process equivalence tests across all
loading subcommands, stdin error-path tests, and end-to-end subprocess tests
that exercise a real non-seekable pipe. Also removes a dead comment in cli.py
and updates the changelog to describe the omit-argument behaviour.

@jeromekelleher jeromekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this to use the convention we usually use of "no file means read from stdin" instead of having "-" mean stdin. I also added more thorough tests and simplified the implementation.

Thanks again for picking this up @chris-a-talbot

@jeromekelleher jeromekelleher enabled auto-merge June 23, 2026 15:37
The info command prints unicode box-drawing characters, which crash the
child process with a UnicodeEncodeError when stdout is a pipe on platforms
defaulting to a non-UTF-8 codec (e.g. Windows). Set PYTHONIOENCODING=utf-8
in the subprocess environment.
@jeromekelleher jeromekelleher added this pull request to the merge queue Jun 25, 2026
Merged via the queue into tskit-dev:main with commit 3cdd0a5 Jun 25, 2026
17 checks passed
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.

Allow CLI, e.g. tskit vcf to take stdin

3 participants