HEXFELLOW Runtime Utilities
Project description
HEXFELLOW RUNTIME UTILITIES
📖 Overview
What is hex_util_runtime
hex_util_runtime is a lightweight Python utility library providing essential runtime primitives with minimal dependencies. It is part of the HEXFELLOW ecosystem and serves as the foundational layer for time management, inter-process communication, environment configuration, and file system operations.
| Module | Primary Purpose | Key Components |
|---|---|---|
| time_utils | High-precision time, PTP clock, loop rate control | ns_now(), HexRate, HexTimeManager |
| buffer_utils | Thread-safe variable + lock-free SPSC shared-memory ring buffer | HexThreadingVar, HexShmRingBuffer, deque_helper |
| env_util | Type-safe environment variable readers | get_env_int(), get_env_bool(), get_env_ndarray() |
| file_utils | Safe recursive directory removal | hex_rmtree() |
What problem it solves
- Unified time interface: Abstract away the difference between system monotonic clocks and PTP hardware clocks behind a simple
ns_now()call. - Thread-safe variable exchange: Wrap any Python value with
HexThreadingVarto safely read/write across threads using a mutex lock. - High-frequency inter-process streaming: Provide a lock-free, single-producer-single-consumer shared-memory ring buffer (
HexShmRingBuffer) optimized for 2–5 kHz+ data rates, avoiding serialization and IPC overhead. - Safe environment configuration: Read environment variables with proper type conversion and fallback defaults, without repetitive
try/exceptboilerplate. - Portable file operations: Pure-
osimplementation of recursive directory deletion, removing theshutildependency.
Target users
- Robotics engineers who need low-latency, lock-free shared-memory communication between processes.
- Developers building real-time control loops with precise timing requirements.
- Anyone working in the HEXFELLOW ecosystem (
hex_driver_mujoco,hex_util_robot, etc.) who needs runtime primitives.
Project structure
hex_util_runtime/
├── hex_util_runtime/
│ ├── __init__.py # Public exports (__all__)
│ ├── time_utils.py # ns_now(), HexRate, HexTimeManager, hex timestamp converters
│ ├── buffer_utils.py # HexThreadingVar (thread-safe variable), HexShmRingBuffer (lock-free SPSC SHM ring buffer), deque_helper
│ ├── env_util.py # get_env_str/get_env_int/get_env_bool/get_env_float/get_env_ndarray
│ └── file_utils.py # hex_rmtree (safe recursive directory removal)
├── docs/
│ ├── api.md # Full API reference
│ └── example.md # Usage walkthroughs
└── pyproject.toml # Project metadata & build configuration
📦 Installation
Requirements
- Python ≥ 3.8
- OS: Linux (POSIX shared memory and PTP clock support are Linux-specific)
- Dependencies:
numpy ≥ 2.2.6
Install from PyPI
pip install hex_util_runtime
Install from Source
We use uv to manage the Python environment. Please install it first.
- Clone and install in editable mode:
git clone https://github.com/hexfellow/hex_util_runtime.git
cd hex_util_runtime
./venv.sh
- Activate before using:
source .venv/bin/activate
⚡ Quick Start
from hex_util_runtime import ns_now, HexRate, hex_ts_now
from hex_util_runtime import get_env_int, hex_rmtree
from hex_util_runtime import HexThreadingVar, HexShmRingBuffer, deque_helper
# Get current time in nanoseconds
print(ns_now())
# Rate-limited loop (100 Hz)
rate = HexRate(100)
for _ in range(10):
rate.sleep()
print(f"ts: {hex_ts_now()}")
# Read an integer from environment (default 0)
interval = get_env_int("MY_INTERVAL_MS", default=50)
📑 Documentation
- API Reference — Detailed documentation of all classes and functions.
- Examples — Usage walkthroughs for each module.
📄 License
Apache License 2.0. See LICENSE.
👥 Authors & Maintainers
| Role | Name | |
|---|---|---|
| Author | Dong Zhaorui | joray.dong@hexfellow.com |
| Maintainer | jecjune (Chen Zejun) | zejun.chen@hexfellow.com |
| Maintainer | Dong Zhaorui | joray.dong@hexfellow.com |
🌟 Star History
👥 Contributors
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 hex_util_runtime-0.0.1a15.tar.gz.
File metadata
- Download URL: hex_util_runtime-0.0.1a15.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a162f7e3edb81f62dd79ed5c73b1a21c8201e26e26c7cbc3f3a97907bfd7c3c
|
|
| MD5 |
e105722d94bf8b66c1acbf86d9a81386
|
|
| BLAKE2b-256 |
10e1d0f0201d3bf83cefd6f352dde00543ba4456800165d1ff2cf496a74c8b91
|
File details
Details for the file hex_util_runtime-0.0.1a15-py3-none-any.whl.
File metadata
- Download URL: hex_util_runtime-0.0.1a15-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdf39e369b818063e0da93dc12a573666ec2cc1297776127446f5f80990fb7cf
|
|
| MD5 |
c211340f9095b171a2aebd11c938141f
|
|
| BLAKE2b-256 |
6aaf72406021718825fdea40715bb9041755c7a2d9b21aa7875392b0055c18b2
|