Skip to content

Spinners for setup steps with --progress --batch#1943

Merged
rolandwalker merged 1 commit into
mainfrom
RW/more-batch-steps-before-progress-bar
Jun 20, 2026
Merged

Spinners for setup steps with --progress --batch#1943
rolandwalker merged 1 commit into
mainfrom
RW/more-batch-steps-before-progress-bar

Conversation

@rolandwalker

Copy link
Copy Markdown
Contributor

Description

For large --batch scripts (the very kind of SQL scripts for which the progress bar is useful) the initial steps of pre-parsing the batch and optionally replaying the checkpoint log can take substantial time. Therefore, add text and spinners showing the stage and progress of the setup steps.

A lightweight new dependency is added due to limitations in the spinners from prompt-toolkit: the prompt-toolkit spinners must have a known upper bound to which to iterate, and they leave behind random "mid-spin" characters on completion like

pre-parsing batch \

which creates visual confusion about whether the step completed successfully.

yaspin spinners can integrate with prompt-toolkit more deeply than is done here, and could also for instance be used during long interactive queries (though that particular usecase may have little value).

Another option would be spinners from the rich library, which we may try in the future, if adopting rich for tabular output.

Motivation: the pause before showing the progress bar was recently opaque to me when running a large --batch script of ~70M statements. It took several seconds to parse the script.

Examples:

last image Screenshot 2026-06-19 at 3 06 53 PM

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Jun 19, 2026
Comment thread mycli/main_modes/batch.py Outdated
raise CheckpointReplayError(f'Error reading --batch file: {batch_path}: {e}') from None
if progress:
spinner = yaspin(text='replaying checkpoint', side='right', stream=sys.stderr)
spinner.start()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This instance of spinner doesn't use with like the other, so if the outer try/except errors out after the spinner starts it won't be stopped

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good catch!

@rolandwalker rolandwalker force-pushed the RW/more-batch-steps-before-progress-bar branch from 42efaf9 to 5f25b7a Compare June 20, 2026 10:27
For large --batch scripts (the very kind of SQL scripts for which the
progress bar is useful) the initial steps of pre-parsing the batch and
optionally replaying the checkpoint log can take substantial time.
Therefore, add text and spinners showing the stage and progress of the
setup steps.

A lightweight new dependency is added due to limitations in the
spinners from prompt-toolkit: the prompt-toolkit spinners must have a
known upper bound to which to iterate, and they leave behind random
"mid-spin" characters on completion like

    pre-parsing batch \

which creates visual confusion about whether the step completed
successfully.

yaspin spinners can integrate with prompt-toolkit more deeply than is
done here, and could also for instance be used during long interactive
queries (though that particular usecase may have little value).

Another option would be spinners from the "rich" library, which we may
try in the future, if adopting "rich" for tabular output.
@rolandwalker rolandwalker force-pushed the RW/more-batch-steps-before-progress-bar branch from 5f25b7a to 7336214 Compare June 20, 2026 10:32
@rolandwalker rolandwalker merged commit 1525c7f into main Jun 20, 2026
11 checks passed
@rolandwalker rolandwalker deleted the RW/more-batch-steps-before-progress-bar branch June 20, 2026 10:40
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