Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress bars to long-running operations #153

Merged
merged 7 commits into from Mar 22, 2024

Conversation

amisevsk
Copy link
Contributor

Add progress bars for kit push, pull, and unpack:

  • Unpack
    unpack

  • Pull (Push is the same)
    pull

Progress bars can be disabled via --progress=false and are disabled when the output is not a TTY. For push/pull, one progress bar is shown per blob downloaded; for unpack a progress bar is shown for the current step, below the regular output, which allows for regular logging (e.g. debug logs) without interfering with the bar.

Wrap oras.Target in a struct that shows progress bars for the Push
operation. The wrap function can be used on any target to show a
progress bar when we push data to it (note, the oras Copy operation uses
the Pusher interface internally)

This adds a new dependency to go.mod, for github.com/vbauerster/mpb/v8.
The mpb package automatically suppresses logging progress bars when
output is not a TTY.
Add progress bar for unpacking. For this case, as kit potentially prints
info lines while unpacking, logs are printed above a progress bar, and
the progress bar is removed on completion to avoid cluttering the
display.
Rework progress bar wrappers to return an output struct that should be
used instead of the default output functions. This allows printing
information above a progress bar without the bar overwriting output.
@gorkem
Copy link
Contributor

gorkem commented Mar 22, 2024

Probably needs a test update

@amisevsk
Copy link
Contributor Author

Yup, I missed a couple edge cases in porting the tests over to the output package. I dropped the padding on byte quantities since I think it's no longer necessary

Copy link
Contributor

@gorkem gorkem left a comment

Choose a reason for hiding this comment

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

LGTM...
Feels like ProgressLogger may need another iteration for easier usage but I could not really imagine how we would simplfy it yet.

@amisevsk
Copy link
Contributor Author

Yeah, agreed. I'm not thrilled with it.

@amisevsk amisevsk merged commit 17ec3d5 into jozu-ai:main Mar 22, 2024
1 check passed
@amisevsk amisevsk deleted the progress-bars branch March 22, 2024 17:01
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.

Status indicator for pack and unpack Add progress bars for upload/download actions
2 participants