Skip to content

Add url_getsize() function#9247

Merged
glenn-jocher merged 3 commits intomasterfrom
glenn-jocher-patch-2
Sep 1, 2022
Merged

Add url_getsize() function#9247
glenn-jocher merged 3 commits intomasterfrom
glenn-jocher-patch-2

Conversation

@glenn-jocher
Copy link
Copy Markdown
Member

@glenn-jocher glenn-jocher commented Sep 1, 2022

Signed-off-by: Glenn Jocher glenn.jocher@ultralytics.com

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

New function to determine the size of online files before downloading.

📊 Key Changes

  • Added a new function url_getsize in utils/downloads.py.
  • The url_getsize function uses the requests.head method to access file information.
  • Retrieves the 'content-length' from the response headers for the file size.

🎯 Purpose & Impact

  • Enables users to check file size before committing to a download: Prevents downloading large files unexpectedly, saving bandwidth and time.
  • Improves data handling within the code: By understanding the size of the data being processed, code can manage resources more efficiently.
  • Potential Impact: Might increase convenience and efficiency for users who deal with frequent downloads and want to automate size checks.

glenn-jocher and others added 3 commits September 1, 2022 11:52
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@glenn-jocher glenn-jocher self-assigned this Sep 1, 2022
@glenn-jocher glenn-jocher merged commit 223c59d into master Sep 1, 2022
@glenn-jocher glenn-jocher deleted the glenn-jocher-patch-2 branch September 1, 2022 10:13
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* Add `url_getsize()` function

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update downloads.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

1 participant