Skip to content

feat: new command chipstream-compress - #30

Merged
paulmueller merged 3 commits into
DC-analysis:mainfrom
paulmueller-agent:chipstream-compress
Nov 30, 2026
Merged

paulmueller merged 3 commits into
DC-analysis:mainfrom
paulmueller-agent:chipstream-compress

Conversation

@paulmueller-agent

Copy link
Copy Markdown

New command chipstream-compress for lossless compression of .rtdc files, based on dcnum.write.compress (dcnum 0.32.0, DC-analysis/dcnum#125, #126, #128-#130).

Usage

chipstream-compress [OPTIONS] PATH_IN [PATH_OUT]
  • PATH_OUT is optional: by default, the output is written to <name>_compressed.rtdc next to the input file. A missing ".rtdc" suffix is added. Existing output files are not overwritten (error).
  • All features of the input file, including the features of its file basins (e.g. the image data of the raw file of a "_dcn.rtdc" file), are written to the output file.
  • --crop-event-images: store only the image data around the events (same format and data as dclab-compress --crop-event-images); --crop-method dilation|box (default "dilation"). Requires processed data ("mask", "image_bg", "size_x", "size_y", "frame"); raw data give a clear error.
  • -b/--basin PATH (optional, multiple): location of a moved basin file (e.g. the raw data file). Without image data (neither in the input file nor in its basins), the command fails with a message that lists the unavailable basins.
  • -c/--compression (default "zstd-5", validated: 'none' or 'zstd-1' to 'zstd-9'). Features that are already compressed with the same or a higher level are copied.
  • -r/--recursive: like chipstream-cli -r, with an optional target directory; files ending with "_compressed.rtdc" are ignored, files with an existing output file are skipped (not counted as failures), failures are listed at the end (exit code 1).
  • --num-cpus: number of worker processes.
  • Progress is shown as "Compression: NN%".

Entry point chipstream-compress = "chipstream.cli:main_compress" (cli extra), README and docs/install.rst mention the new command.

Benchmark (dcnum, Windows lab PC, 8 cores)

Pipeline output with 2,191,988 events (images from the 38 GB raw file), wall time including writing:

dcnum (8 processes) dclab-compress
with cropping 301-308 s, 2.615 GB 2581 s, 2.618 GB (identical data)
without cropping 632 s, 24.0 GB 3966 s, 24.0 GB

Peak memory (summed USS): dcnum 2.0 GB with cropping, 1.0 GB without; dclab ≥ 0.95 GB with cropping, 0.29 GB without.

Tests

  • tests/test_cli_compress.py: compression of a chipstream-cli output with and without cropping (the output does not need the raw file), moved raw file (-b, crop method "box", -c, --num-cpus), errors (invalid compression, cropping raw data, directory without -r, file with -r, output path is a directory, existing output file, suffix), recursive mode (target directory, skipped and failed files, compressed files are not compressed again), unexpected errors.
  • Coverage of chipstream/cli/cli_compress.py: 100 %.
  • Full test suite (local, Linux, dcnum 0.32.0 from PyPI): 109 passed.
  • ruff: 0, flake8: 0, pyright 1.1.408: 0 errors (as on main).

🤖 Generated with Claude Code

Paul Müller and others added 2 commits November 27, 2026 11:21
Lossless compression of .rtdc files with `dcnum.write.compress`,
optionally with cropped event images (`--crop-event-images`, same
format as `dclab-compress --crop-event-images`). Features in file
basins (e.g. the image data of the raw file of a "_dcn.rtdc" file)
are written to the output file; moved basin files can be specified
with `-b`. Supports `-r`, `-c`, and `--num-cpus` like `chipstream-cli`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dcnum 0.32.0 copies features that are already compressed with the
same or a higher Zstandard level, so the `-c` test now requests a
higher level than the input data. Mention the copying in the `-c`
help text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.72165% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.56%. Comparing base (829d462) to head (b7f53a3).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
chipstream/cli/_main.py 10.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
+ Coverage   80.99%   81.56%   +0.56%     
==========================================
  Files          23       24       +1     
  Lines        1721     1817      +96     
==========================================
+ Hits         1394     1482      +88     
- Misses        327      335       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paulmueller
paulmueller merged commit 6cb9470 into DC-analysis:main Nov 30, 2026
6 of 8 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.

2 participants