Skip to content

Give the progress bar a proper width also when the output is piped - #310

Open
hannahbast wants to merge 1 commit into
mainfrom
fix-progress-bar-width
Open

Give the progress bar a proper width also when the output is piped#310
hannahbast wants to merge 1 commit into
mainfrom
fix-progress-bar-width

Conversation

@hannahbast

Copy link
Copy Markdown
Collaborator

When the output of qlever update-wikidata is piped (for example, through tee -a update-log.txt to keep a log file, which became attractive now that #307 keeps the colors), tqdm cannot detect the terminal width and falls back to a bar of only 10 characters. With this change, the width is taken from the COLUMNS environment variable (or 80 if it is not set) in that case; on a terminal, the width remains dynamic as before.

NOTE: bash does not export COLUMNS by default, so for a bar that really spans the whole terminal in the piped case, add export COLUMNS to the shell profile; without it, the bar is 80 characters wide.

When the output of `qlever update-wikidata` is piped (for example,
through `tee` to keep a log file), `tqdm` cannot detect the terminal
width and falls back to a bar of only 10 characters. Use the width from
the `COLUMNS` environment variable (or 80) in that case; on a terminal,
the width remains dynamic as before.
Copilot AI review requested due to automatic review settings July 29, 2026 06:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the user experience of qlever update-wikidata by ensuring the tqdm progress bar has a sensible width even when output is piped (e.g., through tee), where terminal-width auto-detection can fail.

Changes:

  • Determine a tqdm ncols value dynamically when running on a TTY, and fall back to COLUMNS/default width when not on a TTY.
  • Pass the computed ncols into the tqdm_logging_redirect progress bar used for batch processing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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