Skip to content

Replace requests by urllib #4941

@pmeier

Description

@pmeier

🚀 The feature

See title.

Motivation, pitch

The requests library is currently an optional dependency. It is used only for downloading from GDrive:

def download_file_from_google_drive(file_id: str, root: str, filename: Optional[str] = None, md5: Optional[str] = None):
"""Download a Google Drive file from and place it in root.
Args:
file_id (str): id of file to be downloaded
root (str): Directory to place downloaded file in
filename (str, optional): Name to save the file under. If None, use the id of the file.
md5 (str, optional): MD5 checksum of the download. If None, do not check
"""
# Based on https://stackoverflow.com/questions/38511444/python-download-files-from-google-drive-using-url
import requests

It would be nice to refactor this to use urllib and drop a "hidden" dependency. From skimming the the linked StackOverflow issue, it seems our implementation is almost a 1-to-1 copy. Thus, I'd wager a guess that requests was simply chosen, because the solution was already there and not because the functionality is not available in urllib.

Alternatives

No response

Additional context

See #4917.

cc @pmeier

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions