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

Progress bar when uploading LFS files #1266

Merged
merged 3 commits into from
Dec 14, 2022
Merged

Progress bar when uploading LFS files #1266

merged 3 commits into from
Dec 14, 2022

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Dec 14, 2022

Resolve #1244 (cc @sijunhe).

Add 2 progress bars when creating a commit. A "main" one showing how much LFS files must be uploaded + 1 progress for each individual LFS file. Progress bars can be disabled by setting HF_HUB_DISABLE_PROGRESS_BARS=1 as environment variable. Example:

8b.arrow: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.00/2.00 [00:03<00:00, 1.54s/B]
8kb.arrow: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.05k/2.05k [00:03<00:00, 655B/s]
8mb.arrow: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.10M/2.10M [00:22<00:00, 94.8kB/s]
Upload 3 LFS files: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:22<00:00,  7.38s/it]

I based the implementation on @julien-c 's implementation from transformers back in 2019 (huggingface/transformers#2078).
I kept it as minimal as possible. Especially, only files that are passed as a filepath have a progress bar. Should cover 95% of the cases. I'm not against making it more flexible but it could bring more problems/corner cases to debug.

Also refactored the code to upload files in parallel (now using thread_map).

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 14, 2022

The documentation is not available anymore as the PR was closed or merged.

@julien-c
Copy link
Member

I based the implementation on @julien-c 's implementation from transformers back in 2019.

❤️❤️❤️ :)

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Looks good to me!

"""
A context manager that yields a file-like object allowing to read the underlying
data behind `path_or_fileobj`.

Args:
with_tqdm (bool, *optional*):
Copy link
Member

Choose a reason for hiding this comment

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

I think the convention is to have defaults to False, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😫

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still don't know about that. I'm seing a lot of private (bool, *optional*, defaults to False): so I'll put that.
I remember a conversation about that on Slack, wasn't so clear what the output is though 😕

@Wauplin
Copy link
Contributor Author

Wauplin commented Dec 14, 2022

Thanks for the review @LysandreJik :) I've adapted the docstring and will merge.

@Wauplin Wauplin merged commit 6a68ae7 into main Dec 14, 2022
@Wauplin Wauplin deleted the 1244-progress-on-upload branch December 14, 2022 15:42
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@sijunhe
Copy link

sijunhe commented Dec 15, 2022

Thanks for the quick turnaround!

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.

http-based upload function should have a progress bar and show upload speed
5 participants