Call raise_for_status after retrieving a URL with requests #176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Sometimes, image files may fail to download due to HTTP errors such as "429 Too Many Requests". As a result of the image file on disk being empty, errors may occur later on in the notebook, which can look somewhat misleading:
cv2.error: OpenCV(4.7.0) /io/opencv/modules/imgcodecs/src/loadsave.cpp:798:
error: (-215:Assertion failed) !buf.empty() in function 'imdecode_'
Add a call to
raise_for_status()
on the returnedresponse
object from therequests
library, which at the very least notifies the user that something has gone wrong.(Alternately, perhaps consider relocating the images from imgur to some other CDN, or even commit them directly to this repository.)
Also, fix some indentation, spacing, and variable naming inconsistencies.
Type of change
Bug fix (non-breaking change which fixes an issue)
How has this change been tested, please provide a testcase or example of how you tested the change?
Manually tested running the notebooks, ensuring the 429 error is displayed to the user.
Any specific deployment considerations
None.
Docs
No documentation was updated.