Skip to content

Route console messages through tqdm.write() to avoid corrupted progress bars#1606

Open
dxqb wants to merge 1 commit into
Nerogar:masterfrom
dxqb:tqdm-print-fix
Open

Route console messages through tqdm.write() to avoid corrupted progress bars#1606
dxqb wants to merge 1 commit into
Nerogar:masterfrom
dxqb:tqdm-print-fix

Conversation

@dxqb

@dxqb dxqb commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Test plan

  • pre-commit run --all-files passes
  • Launched the affected UI or script and exercised the change
  • Tested with at least one real preset / config when relevant (note which: ____)

AI assistance

  • AI-assisted — I have read every line in this diff and can defend each change

…ess bars

print() writes to stdout while tqdm's bar redraws go to stderr; the two
streams are independently buffered and their writes can interleave at
the byte level, corrupting both. Route the messages that can fire while
a training-loop, caching, or sampling bar is active through tqdm.write()
instead, which synchronizes via tqdm's own lock.

Also drop __backup()/__save()'s print_cb parameter: it only ever received
either print or step_tqdm.write (itself just a classmethod indistinguishable
from the bare tqdm.write, since it doesn't depend on the instance), so both
methods can just call tqdm.write() directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dxqb dxqb added the preview merged in the preview branch label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview merged in the preview branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant