Skip to content

Make download_url() follow redirects (#3235) #3236

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

Merged
merged 11 commits into from
Jan 15, 2021

Conversation

slipnitskaya
Copy link
Contributor

Fix bug related to the incorrect processing of redirects (#3235).
Follow the redirect chain until the destination is reached or
the number of redirects exceeds the max allowed value (by default 10).

Fix bug related to the incorrect processing of redirects.
Follow the redirect chain until the destination is reached or
the number of redirects exceeds the max allowed value (by default 10).
@facebook-github-bot
Copy link

Hi @slipnitskaya!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Hey @slipnitskaya and thanks for the PR. I have one minor comment below. Otherwise LGTM!

@pmeier pmeier requested a review from fmassa January 11, 2021 08:13
Make max number of hops a function argument and assign its default value to 10
Add the maximum number of redirect hops parameter to download_url()
Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot! @slipnitskaya we need to add tests for this. Do you want to add some or shall I take this after this PR is merged?

@slipnitskaya
Copy link
Contributor Author

@pmeier Would be great if you can add the tests later.

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I added a few comments, please let me know what you think. The two comments marked with "Nit:" are non-blocking nice to haves that we can do on a future PR. I noticed that the tests are stalling and eventually fail, could you please have a look?

@pmeier
Copy link
Collaborator

pmeier commented Jan 14, 2021

@datumbox I'll look into the failing tests. @slipnitskaya is it ok if I push changes directly to the PR?

@datumbox
Copy link
Contributor

@pmeier cool, ping me when you are ready. :)

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR! :)

@pmeier
Copy link
Collaborator

pmeier commented Jan 15, 2021

@slipnitskaya I went ahead and made a few changes:

  • CI was failing, because the redirect check happened before we checked for local files. Some of our tests relied on download_url simply accepting these local files and thus the tests timed out since they tried to actually download the files. I've changed the ordering and now everything is working as expected
  • I've removed the printing as well as recursion as was suggested by @datumbox
  • I've added tests

@datumbox datumbox merged commit 0985533 into pytorch:master Jan 15, 2021
@slipnitskaya
Copy link
Contributor Author

@pmeier @datumbox, all sounds good. Thank you!

facebook-github-bot pushed a commit that referenced this pull request Jan 21, 2021
Summary:
* Make download_url() follow redirects

Fix bug related to the incorrect processing of redirects.
Follow the redirect chain until the destination is reached or
the number of redirects exceeds the max allowed value (by default 10).

* Parametrize value of max allowed redirect number

Make max number of hops a function argument and assign its default value to 10

* Propagate the max number of hops to download_url()

Add the maximum number of redirect hops parameter to download_url()

* check file existence before redirect

* remove print

* remove recursion

* add tests

* Reducing max_redirect_hops

Reviewed By: datumbox

Differential Revision: D25954556

fbshipit-source-id: 3b2c64592d5882b98e87acdb5efd95e9283d2862

Co-authored-by: Vasilis Vryniotis <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Vasilis Vryniotis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants