Histogramming as a Service
Project description
Histogramming as a Service (HistServ)
Install from PyPI
pip install histserv
Install from conda-forge
conda install -c conda-forge histserv
Quickstart
Start the async gRPC server (or just ./example/start_server.sh):
histserv --port 50051
# 2026-03-26 11:58:00.643 INFO:histserv:server (listening at [::]:50051) started with port=50051, prune_after=24.00 h, prune_interval=5.00 min, stats_interval=5.00 s
Then run:
from hist import Hist
from histserv import Client
import numpy as np
# initialize hist locally
H_local = Hist.new.Reg(30, -3, 3, name="x", label="x-axis").Double()
with Client(address="[::]:50051") as client:
# initialize it on the server and receive a remote hist to interact with it
H_remote = client.init(H_local)
# fill the remote hist; the client pre-bins locally and sends dense storage
H_remote.fill(x=np.random.normal(size=1000))
# retrieve it back as a ChunkedHist, drop it from the server, and materialize it locally
H_snapshot = H_remote.snapshot(delete_from_server=True)
print(H_snapshot.to_hist())
# local hist hasn't been filled
assert np.all(H_local.view(True) == 0)
Output in ipython:
┌────────────────────────────────────────────────────────────────────────────┐
[-inf, -3) 1 │▋ │
[ -3, -2.8) 0 │ │
[-2.8, -2.6) 1 │▋ │
[-2.6, -2.4) 1 │▋ │
[-2.4, -2.2) 6 │████ │
[-2.2, -2) 11 │███████▍ │
[ -2, -1.8) 12 │████████ │
[-1.8, -1.6) 20 │█████████████▍ │
[-1.6, -1.4) 19 │████████████▊ │
[-1.4, -1.2) 33 │██████████████████████▏ │
[-1.2, -1) 50 │█████████████████████████████████▌ │
[ -1, -0.8) 70 │██████████████████████████████████████████████▉ │
[-0.8, -0.6) 49 │████████████████████████████████▉ │
[-0.6, -0.4) 88 │███████████████████████████████████████████████████████████ │
[-0.4, -0.2) 63 │██████████████████████████████████████████▎ │
[-0.2, 0) 65 │███████████████████████████████████████████▋ │
[ 0, 0.2) 85 │█████████████████████████████████████████████████████████ │
[ 0.2, 0.4) 77 │███████████████████████████████████████████████████▋ │
[ 0.4, 0.6) 65 │███████████████████████████████████████████▋ │
[ 0.6, 0.8) 61 │████████████████████████████████████████▉ │
[ 0.8, 1) 63 │██████████████████████████████████████████▎ │
[ 1, 1.2) 45 │██████████████████████████████▏ │
[ 1.2, 1.4) 36 │████████████████████████▏ │
[ 1.4, 1.6) 32 │█████████████████████▌ │
[ 1.6, 1.8) 15 │██████████ │
[ 1.8, 2) 11 │███████▍ │
[ 2, 2.2) 10 │██████▊ │
[ 2.2, 2.4) 3 │██ │
[ 2.4, 2.6) 5 │███▍ │
[ 2.6, 2.8) 2 │█▍ │
[ 2.8, 3) 1 │▋ │
[ 3, inf) 0 │ │
└────────────────────────────────────────────────────────────────────────────┘
Examples
See example/ for more examples.
Run example client:
python example/client.py
# Remote hist initialized: RemoteHist(hist_id='52c77c93da8146f2a72c53af269d1ab5', address='[::]:50051', token=None)
# Remote hist fill succeeded.
# Snapshotting current hist: ChunkedHist(...)
# Remote hist fill succeeded.
# Remote hist fill succeeded.
# Remote hist flushed successfully to hist.h5.
Or check out how to use remote histogram filling with an example coffea Processor in example/coffea_processor.py.
Useful client methods on RemoteHist:
fill(...)fill_many([...])snapshot(delete_from_server=False)reset()exists()get_connection_info()flush(destination="hist.h5")delete()
Current supported types
Axis support:
hist.axis.Regularwithout transformshist.axis.Booleanhist.axis.Variablehist.axis.Integerhist.axis.IntCategoryhist.axis.StrCategory
Storage support:
hist.storage.Doublehist.storage.Int64boost_histogram.storage.AtomicInt64hist.storage.Weightboost_histogram.storage.Unlimited
Unsupported today:
- transformed
hist.axis.Regular boost_histogram.storage.Meanboost_histogram.storage.WeightedMean
Notes:
- Categorical axes (
IntCategory,StrCategory) are treated as chunk keys and must be filled with scalar values. RemoteHist.snapshot()returns aChunkedHist; call.to_hist()to materialize a localhist.Hist.fill_many(...)is useful for bundling several fills into one gRPC request.- Dense ndarray transport is generic over NumPy dtypes, but object arrays are not supported on the wire.
Developer Info
Install
uv sync --dev
Protobuf Codegen
python -m grpc_tools.protoc -Isrc/histserv/protos --python_out=src/histserv/protos --pyi_out=src/histserv/protos --grpc_python_out=src/histserv/protos src/histserv/protos/hist.proto
After regeneration, ensure src/histserv/protos/hist_pb2_grpc.py keeps the
package-relative import:
from . import hist_pb2 as hist__pb2
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file histserv-0.1.7.tar.gz.
File metadata
- Download URL: histserv-0.1.7.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e742e25a6d05f0e70066e23cf7543e7c373726cc53b6b1e3f8c14dc8b6f18da
|
|
| MD5 |
56c2a04c5efc438c19b1d453d579b9ed
|
|
| BLAKE2b-256 |
183cc07cc3b7bc4c4c49bfc3b0d6b6c2974477f0a4e2f37d6066ec3a2e59dd9d
|
Provenance
The following attestation bundles were made for histserv-0.1.7.tar.gz:
Publisher:
cd.yml on pfackeldey/histserv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
histserv-0.1.7.tar.gz -
Subject digest:
2e742e25a6d05f0e70066e23cf7543e7c373726cc53b6b1e3f8c14dc8b6f18da - Sigstore transparency entry: 1198189765
- Sigstore integration time:
-
Permalink:
pfackeldey/histserv@523684de0a513b2e3147418753fcc5e228595a5a -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/pfackeldey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@523684de0a513b2e3147418753fcc5e228595a5a -
Trigger Event:
release
-
Statement type:
File details
Details for the file histserv-0.1.7-py3-none-any.whl.
File metadata
- Download URL: histserv-0.1.7-py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a16ddd5f63d6694fafcffc22c48681bb8ce478cae20535d324c251d71ed0b897
|
|
| MD5 |
994016e51fdc3015288af2f50b00ca53
|
|
| BLAKE2b-256 |
b0b597d2809ab227d9a741e2e1a802d70c7a92153726ca13524bccd862e1a65f
|
Provenance
The following attestation bundles were made for histserv-0.1.7-py3-none-any.whl:
Publisher:
cd.yml on pfackeldey/histserv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
histserv-0.1.7-py3-none-any.whl -
Subject digest:
a16ddd5f63d6694fafcffc22c48681bb8ce478cae20535d324c251d71ed0b897 - Sigstore transparency entry: 1198189822
- Sigstore integration time:
-
Permalink:
pfackeldey/histserv@523684de0a513b2e3147418753fcc5e228595a5a -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/pfackeldey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@523684de0a513b2e3147418753fcc5e228595a5a -
Trigger Event:
release
-
Statement type: