Skip to main content

File-like object from url of remote file, optimized for use with h5py.

Project description

remfile

latest-release tests codecov

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 = remfile.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, and parallelization, 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. For very large data arrays, the system will use multiple threads to read the data in parallel.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

remfile-0.1.4.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

remfile-0.1.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file remfile-0.1.4.tar.gz.

File metadata

  • Download URL: remfile-0.1.4.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for remfile-0.1.4.tar.gz
Algorithm Hash digest
SHA256 40abfa68f94b5ec4c7fb62a0928bcd7cd078dda9ec01f2e2ab3822a04208410c
MD5 5f11520de37f1acd4b98f0ba272c4742
BLAKE2b-256 1e9ffadf93a2a22ba3ad9b63a942a1d150e5481ab3e0df114273995a3f788969

See more details on using hashes here.

File details

Details for the file remfile-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: remfile-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for remfile-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b401e62c22a8ea24b29f20e3f7d9d97f009fe25b2cf8039ed2c08fe6f8211f28
MD5 cb9a350d211f658631d519e105ead525
BLAKE2b-256 9958ca5cf305a327fe75a9e998ac06970c424f912dae32befc03b6060dcca28b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page