Skip to main content

DataMux

DataMux is a library to stream data into real-time analytics pipelines. It provides the modes listed below.

  • Proxy Mode: to interface and proxy live data from sensors
  • Replay Mode: to replay stored data from datasets
  • Simulate Mode: to stream guided/unguided mock data for testing

Installation

First, install datamux as a pip package.

pip install streaminghub-datamux

Initialization

Next, configure where datamux should look for data and metadata. We use $HOME/streaminghub by default. This configuration will be stored at $HOME/.streaminghubrc.

python -m streaminghub_datamux init --data_dir="$HOME/streaminghub" --meta_dir="$HOME/streaminghub"

Usage

Import and Setup

In your Python script, first import datamux as follows.

# import datamux
import streaminghub_datamux as dm

Next, instantiate the Datamux API. Here, you have two options:

# Option A - Local API (runs locally)
api = dm.API()

# Option B - Remote API (runs over a remote datamux server)
api = dm.RemoteAPI(rpc_name="<rpc>", codec_name="<codec>")
await api.connect(server_host="<host>", server_port=<port>)

Replay Recordings from Collections

# list all collections (each collection provides one or more streams)
collections = await api.list_collections()
# list all recordings (i.e., streams) in a collection, by id
streams = await api.list_collection_streams(collection_id="<id>")
# sample attributes of a stream (found in stream.attrs)
attrs = dict({"subject": "A", "session": "1", "task": "1"})
# queue to append received data
sink = asyncio.Queue()
# start gathering data into queue
ack = await api.replay_collection_stream(collection_id="<id>", stream_id="<id>", attrs, sink)
# each request is assigned a unique ID for later reference
assert ack.randseq is not None
# simply await the queue to read data
while True:
    item = await sink.get()
    # checking for end-of-stream
    if item == util.END_OF_STREAM:
        break
# once done, stop the task to avoid wasting resources
await api.stop_task(ack.randseq)

Proxy Live Streams from Devices

# list all nodes (each node provides one or more streams)
nodes = await api.list_live_nodes()
# list all devices (i.e., streams) in a node, by id
streams = await api.list_live_streams(node_id="<id>")
# sample attributes of a stream (found in stream.attrs)
attrs = dict({"subject": "A", "session": "1", "task": "1"})
# queue to append received data
sink = asyncio.Queue()
# start gathering data into queue
ack = await api.proxy_live_stream(node_id="<id>", stream_id="<id>", attrs, sink)
# each request is assigned a unique ID for later reference
assert ack.randseq is not None
# simply await the queue to read data
while True:
    item = await sink.get()
    # checking for end-of-stream
    if item == util.END_OF_STREAM:
        break
# once done, stop the task to avoid wasting resources
await api.stop_task(ack.randseq)

Start a Remote API

You can start a remote API using the command below.

python -m streaminghub_datamux serve -H "<host_name>" -p <port> -r <rpc_name> -c <codec_name>

For Developers

# clone streaminghub from git
git clone https://github.com/nirdslab/streaminghub.git

# cd into streaminghub/ directory
cd streaminghub/

# install the streaminghub_datamux/ folder as a pip package
python -m pip install -e streaminghub_datamux/

Metadata

Release files for streaminghub-datamux 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streaminghub-datamux 0.1.8
File Size Uploaded Provenance Actions
streaminghub_datamux-0.1.8.tar.gz 21.8 kB Without provenance Details for streaminghub_datamux-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for streaminghub-datamux 0.1.8
File Interpreter ABI Platform Actions
streaminghub_datamux-0.1.8-py3-none-any.whl Python 3 none any Details for streaminghub_datamux-0.1.8-py3-none-any.whl

Total release size: 47.9 kB

Release files / streaminghub_datamux-0.1.8.tar.gz

Download URL streaminghub_datamux-0.1.8.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3740a30810828277ad5d7951f81eb709c4724bb6d6e199d077ac83b482f2344d
BLAKE2b-256 checksum
How to use checksums
990b40ae8fb450062cd38d00da38a298ecc5aa5311c463bc2cdbf46e781c8f05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.14

Release files / streaminghub_datamux-0.1.8-py3-none-any.whl

Download URL streaminghub_datamux-0.1.8-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d4dd2cd0d8d4643b29bc9a66dbd59eb12e5960c15d72f830e1a1983ddecf26d
BLAKE2b-256 checksum
How to use checksums
e01b868275743353e438d09b8d8fd5396b08af4cefad5a6d27083adff55eeb45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.14

Security for streaminghub-datamux 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page