Allow custom urlopen for astropy.utils.data.download_file
See original GitHub issueThe astropy.utils.data
module is excellent, but restricted to ‘simple’ downloads. so I’m wondering if there is scope for a change such that users could use functions other that urlopen
in download_file()
?
My specific use case is for accessing files from behind an authentication layer, where we have a wrapper around urlopen
that handles authentication redirects and all that.
Something like this would be great:
def download_file(remote_url, cache=False, show_progress=True,
opener=urllib.request.urlopen, **kwargs):
where kwargs
then get passed to the opener. If the powers-that-be are open to the idea, I’m happy to work up a prototype and post a PR.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Downloadable Data Management (astropy.utils.data)
In this case, you may pass the allow_insecure=True argument to download_file() to allow the download with a warning instead (not recommended unless you ......
Read more >How do I open a FITS file from a URL in astropy?
If the file name is a URL, download_file is used to open the file. This specifies whether or not to save the file...
Read more >Source code for astropy.utils.data
If args[1] is present, it is a filename indicating the path to a temporary file that was created to store a remote data...
Read more >astroquery Documentation
All astroquery modules are supposed to follow the same API. In its simplest form, the API involves queries based on.
Read more >astropy/data.py at main - GitHub
Returns the local path that the file was download to. Raises. ------. urllib.error ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I now wonder whether this might be possible just using
mock
:Since I seem to be the only requester of this functionality I think we can close this issue now, and I can post a PR with a proper implementation of my initial suggestion if required.
My position has generally been that
download_data
andget*file*
are considered “public” because of just the reason @duncanmmacleod gave - that it’s already there and useful so why not let people use it.That said, I am sensitive to the point that it’s “feature creep” to keep adding options to maintain. E.g., we’d rather the progress bar get replaced by
tqdm
instead of maintaining our own (been on the todo list for a while). But I think I’m receptive to the idea @duncanmmacleod is suggesting here of basically making it more able to use other functions, because that might actually encourage use of other tools. But as @pllim says, devil is in the details, so would need to see a PR or at least a bit more detail to be entirely sure how much maintenance burden is likely…