Skip to content

Keep the weights download progress output short in logs - #6

Merged
smishra3 merged 1 commit into
mainfrom
fix/download-progress-logs
Nov 11, 2026
Merged

smishra3 merged 1 commit into
mainfrom
fix/download-progress-logs

Conversation

@smishra3

Copy link
Copy Markdown
Collaborator

What changed

The progress hook for the first-time weights download (src/subcellseg/weights.py) is now a small _Progress class that writes only when the shown value changes:

  • in a terminal: the line is redrawn in place once per whole percent (101 redraws);
  • when stderr is not a terminal (CI, nohup, SLURM logs, notebooks): one line per 10% (11 lines);
  • unknown size: a terminal redraws once per MB; a non-terminal writes nothing until the download ends.

Download, SHA-256 check and caching are unchanged.

Fixes #5.

Why

urlretrieve calls the hook for every 8 KB block, about 8,000 times for the 64 MB weights, and each call rewrote the line. Any captured log got ~150 KB of 0 / 64 MB (0%) text.

How it was tested

  • pytest: 13 passed on Linux (CPU), including 2 new cases checking the output for both the terminal and non-terminal paths.
  • Real download from the public release with an empty SUBCELLSEG_CACHE_DIR:
Output Before After
stderr to a file ~150 KB, ~8,000 redraws 407 bytes, 11 lines
under a terminal (script) ~8,000 redraws 101 redraws

The downloaded file's SHA-256 is unchanged (858689a3…). Segmentation code is untouched, so no bench_predict.sh run is needed.

Checklist

  • Tests pass locally (pytest)
  • Docs updated if behaviour or commands changed (no command changes)
  • CHANGELOG.md has an entry under Unreleased (if a user would notice)
  • No weights, outputs or notebook outputs committed
  • AI-assisted code is reviewed line by line and the commit carries an Assisted-by: trailer (written with Claude Code; for the maintainer to review)

Assisted-by: claude-code (claude-opus-5-5)

🤖 Generated with Claude Code

urlretrieve calls the progress hook for every 8 KB block, about 8,000 times
for the weights, and each call rewrote the progress line. In a terminal it now
redraws only when the whole percentage changes; when stderr is not a terminal
it writes one line per 10%.

Fixes #5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: claude-code (claude-opus-5-5)
@smishra3
smishra3 merged commit 40d402b into main Nov 11, 2026
7 checks passed
@smishra3
smishra3 deleted the fix/download-progress-logs branch November 11, 2026 05:17
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.

Weights download progress line floods non-terminal logs

1 participant