H5Grove

4.0.0 · active · verified Fri Apr 17

h5grove is a Python library providing core utilities to serve HDF5 file contents over a REST API. It allows users to browse and extract data from HDF5 files via HTTP requests, with support for various web frameworks like FastAPI, Flask, and Tornado. The library is actively maintained, with a current version of 4.0.0, and releases new versions regularly, often including breaking changes to improve the API or underlying structure.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates setting up a basic h5grove server using FastAPI and Uvicorn. It mounts the h5grove API at the `/h5grove` path. Ensure you have the `h5grove[fastapi]` and `uvicorn` packages installed, and specify an `H5GROVE_HDF5_DIR` environment variable or directly set `H5GroveConfig.hdf5_dir` to point to a directory containing your HDF5 files. This allows the server to discover and serve them.

import os
from fastapi import FastAPI
from h5grove.app import create_app
from h5grove.config import H5GroveConfig

# Configure the base directory for HDF5 files.
# Replace with a path where your .h5 files are located.
# For a runnable example, ensure a '.h5' file exists here.
H5GroveConfig.hdf5_dir = os.environ.get('H5GROVE_HDF5_DIR', '.')

app = FastAPI()
app.mount("/h5grove", create_app())

# To run this app (requires uvicorn):
# 1. pip install h5grove[fastapi] uvicorn
# 2. Save this code as 'main.py'
# 3. Run from terminal: uvicorn main:app --reload --port 8000
# 4. Access API: http://127.0.0.1:8000/h5grove/

view raw JSON →