File-like object from url of remote file, optimized for use with h5py.
Project description
remfile
Provides a file-like object for reading a remote file over HTTP, optimized for use with h5py.
Example usage:
# See examples/example1.py
import h5py
import remfile
url = 'https://dandiarchive.s3.amazonaws.com/blobs/d86/055/d8605573-4639-4b99-a6d9-e0ac13f9a7df'
file = remfil.File(url)
with h5py.File(file, 'r') as f:
print(f['/'].keys())
See examples/example1.py for a more complete example.
Installation
pip install remfile
Why?
The conventional way of reading a remote hdf5 file is to use the fsspec library as in examples/example1_compare_fsspec.py. However, this approach is empirically much slower than using remfile. I am not familiar with the inner workings of fsspec, but it does not seem to be optimized for reading hdf5 files. Efficient access of remote hdf5 files requires reading small chunks of data to obtain meta information, and then large chunks of data to obtain the larger data arrays.
See a timing comparison betweeen remfile and fsspec in the examples directory.
How?
A file-like object is created that reads the remote file in chunks using the requests library. A relatively small default chunk size is used, but when the system detects that a large data array is being accessed, it switches to a larger chunk size.
Caveats
This library is not intended to be a general purpose library for reading remote files. It is optimized for reading hdf5 files.
License
Apache 2.0
Author
Jeremy Magland, Center for Computational Mathematics, Flatiron Institute
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file remfile-0.1.0.tar.gz
.
File metadata
- Download URL: remfile-0.1.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b1f4be98c8aab2e61246427a8d56f94fca0dd0980c70915537d4673d1d858c6 |
|
MD5 | fed5b0a63bd0a1c0f1374040072e99a4 |
|
BLAKE2b-256 | 2edd8498bfd3700d1d8b8b53c6257d3ae1690ca6527630ad0baff5f8f3edb907 |
File details
Details for the file remfile-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: remfile-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43f069138620bf389a279e77b609ee650129ef83f9c2b4fcd1af19218d709ae8 |
|
MD5 | e972c8eb0249e42f66c87b7eeb8b0bb8 |
|
BLAKE2b-256 | 844d8c75cabd6873f4c3ddbf09d0332edab5ea3ad0fbd6bf2cbad25ddc4f6057 |