tensorflow / tensorflow/datasets
Custom download method
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 1.6k
- Avg merge
- 3h 54m
- Merged PRs (30d)
- 1
Description
Is your feature request related to a problem? Please describe.
I have a dataset that requires a bit more complicated download method than usual (for example, add some headers)
Describe the solution you'd like
I would like to have a method: dl_manager.download_custom that is given:
- a URL or list of URLs
- a custom download method that receives:
a. a single URL
b. local file destination path
So I could implement custom downloads.
Full code I want to write:
def my_custom_download(url: str, local_path: str):
opener = urllib.request.build_opener()
opener.addheaders = {...my headers...}
urllib.request.install_opener(opener)
urllib.request.urlretrieve(url, local_path)
URLs = ['url1', 'url2', 'url3']
dl_manager.download_custom(URLs, my_custom_download)
Describe alternatives you've considered
Doing my download without the download manager, but then I'll just hack around where to save the files. the dl_manager seems like the correct place to do this.
Additional context
This method exists in huggingface/datasets, and I think is well motivated.
This is not just for headers, but also for other download methods (for example, download over scp)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the download manager entry point referenced as dl_manager and inspect its existing download APIs and tests. Define the requested download_custom behavior for one URL or a list, passing each URL and local destination to the supplied callback. Done means custom methods can save downloads through the manager, including nonstandard methods such as headers or SCP.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100