Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Remove the need for the requests library entirely #145

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

addyess
Copy link
Contributor

@addyess addyess commented Oct 30, 2023

the inclusion of the requests library drew in urllib3 whose latests versions caused issues in charms which didn't have hatching.

Update this library to not depend on requests at all

@addyess addyess force-pushed the akd/remove-requests-lib branch from 9539ffd to 2f741b0 Compare October 30, 2023 17:32
Comment on lines 456 to 431
r = requests.get(repository_url)
r.raise_for_status()
with open(cuda_repository_package, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
f.write(chunk)
r.close()
with contextlib.closing(urlopen(repository_url)) as r:
with open(cuda_repository_package, "wb") as f:
f.write(r.read())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For those looking -- this is the only change to remove the requests package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

urlopen(...) will raise when there are protocol errors -- just like r.raise_for_status() did

Choose a reason for hiding this comment

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

Just a quick suggestion here: I don't know exactly what the size of the package is; however, caution should be taken with r.read() for large files, as this can consume a significant amount of host memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm... true it is pulling the whole deb package. Lemme fix that

Copy link

@mateoflorido mateoflorido left a comment

Choose a reason for hiding this comment

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

LGTM

@addyess addyess merged commit 4c7f4c0 into master Oct 30, 2023
7 checks passed
@addyess addyess deleted the akd/remove-requests-lib branch October 30, 2023 18:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants