Histogramming as a Service
Project description
Histogramming as a Service (HistServ)
Install PyPI
pip install histserv
Install Conda-Forge
conda install -c conda-forge histserv
Quickstart
Start gRPC server (or just ./example/start_server.sh):
histserv --port 50051 --n-threads 4
# INFO:histserv:started - listening on [::]:50051 with 4 threads
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 on the server
H_remote.fill(x=np.random.normal(size=1000))
# retrieve it back, drop it from the server & print it
print(H_remote.snapshot(drop_from_server=True))
# 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<ID=52c77c93da8146f2a72c53af269d1ab5 @[::]:50051>
# Remote hist filled successfully? -> True
# Snapshotting current hist: Hist(
# Regular(10, -2, 2, name='x', label='X Axis'),
# Regular(10, -2, 2, name='y', label='Y Axis'),
# StrCategory(['data', 'drell-yan'], growth=True, name='dataset', label='Dataset'),
# storage=Weight()) # Sum: WeightedSum(value=911503, variance=911503) (WeightedSum(value=1e+06, variance=1e+06) with flow)
# Remote hist filled successfully? -> True
# Remote hist filled successfully? -> True
# Remote hist flushed succesfully? -> Histogram (52c77c93da8146f2a72c53af269d1ab5) flushed successfully to hist.h5.
And the server logs additionally (after running the client script):
# INFO:histserv:RPC<Init> (hist_id=52c77c93da8146f2a72c53af269d1ab5) - initialized histogram
# INFO:histserv:RPC<Fill> (hist_id=52c77c93da8146f2a72c53af269d1ab5) - filled with 24.00 MB
# INFO:histserv:RPC<SnapShot> (hist_id=52c77c93da8146f2a72c53af269d1ab5) - created snapshot
# INFO:histserv:RPC<Fill> (hist_id=52c77c93da8146f2a72c53af269d1ab5) - filled with 24.00 MB
# INFO:histserv:RPC<Fill> (hist_id=52c77c93da8146f2a72c53af269d1ab5) - filled with 24.00 MB
# INFO:histserv:RPC<Flush> (hist_id=52c77c93da8146f2a72c53af269d1ab5) - flushed histogram to hist.h5
Or check out how to use remote histogram filling with an example coffea Processor in example/coffea_processor.py.
Current supported types
Axis support:
hist.axis.Regularhist.axis.Booleanhist.axis.Variablehist.axis.Integerhist.axis.IntCategoryhist.axis.StrCategory
np.dtype support for hist.axis.{Regular,Variable,Integer}:
np.float64np.float32np.int64np.int32
Developer Info
Install
uv pip install -e . --group=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
Maybe adjust imports in src/histserv/protos/hist_pb2_grpc.py.
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.4.tar.gz.
File metadata
- Download URL: histserv-0.1.4.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8fcfdcaf6b5cea216ca2ca7eb49009809c324af534212be9c4a095d082e234a
|
|
| MD5 |
19ff9b07f4c20ec089a2945b61842ccc
|
|
| BLAKE2b-256 |
2c8a8f03d567600a9819a171073d24d56ed7ffeb82a26dac9cf1ca2b9b1c47c5
|
Provenance
The following attestation bundles were made for histserv-0.1.4.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.4.tar.gz -
Subject digest:
f8fcfdcaf6b5cea216ca2ca7eb49009809c324af534212be9c4a095d082e234a - Sigstore transparency entry: 1145620338
- Sigstore integration time:
-
Permalink:
pfackeldey/histserv@205d53450daaa3dcd3400add9ffd3fded6759965 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/pfackeldey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@205d53450daaa3dcd3400add9ffd3fded6759965 -
Trigger Event:
release
-
Statement type:
File details
Details for the file histserv-0.1.4-py3-none-any.whl.
File metadata
- Download URL: histserv-0.1.4-py3-none-any.whl
- Upload date:
- Size: 16.9 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 |
3aad642bef76b18d03b05ebb24105da768eca728da24f917227ec8167f241db2
|
|
| MD5 |
ec888468f45d6a6d0a149a3fca24f230
|
|
| BLAKE2b-256 |
896277ed0fb282520982a0638211b99215c1a7eee92d6c100fa4c6e3070a5d00
|
Provenance
The following attestation bundles were made for histserv-0.1.4-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.4-py3-none-any.whl -
Subject digest:
3aad642bef76b18d03b05ebb24105da768eca728da24f917227ec8167f241db2 - Sigstore transparency entry: 1145620450
- Sigstore integration time:
-
Permalink:
pfackeldey/histserv@205d53450daaa3dcd3400add9ffd3fded6759965 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/pfackeldey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@205d53450daaa3dcd3400add9ffd3fded6759965 -
Trigger Event:
release
-
Statement type: