Skip to main content

Zero-copy shared memory IPC library for building complex streaming data pipelines capable of processing large datasets

Project description

MomentumX


MomentumX is a zero-copy shared memory IPC library for building complex streaming data pipelines capable of processing large datasets using Python.


Key Features:

  • High-Throughput, Low Latency
  • Supports streaming and synchronous modes for use within a wide variety of use cases.
  • Bring your own encoding, or use raw binary data.
  • Small footprint with zero dependencies.
  • Sane data protections to ensure reliability of data in a cooperative computing environment.
  • Pairs with other high-performance libraries, such as numpy and scipy, to support parallel processing of memory-intensive scientific data.
  • Works on most modern versions of Linux using shared memory (via /dev/shm).
  • Seamlessly integrates into a Docker environment with minimal configuration, and readily enables lightweight container-to-container data sharing.

Examples:

Below are some simplified use cases for common MomentumX workflows. Consult the examples in the examples/ directory for additional details and implementation guidance.

Streaming Mode (e.g. lossy)

# Producer Process
import momentumx as mx

# Create a stream with a total capacity of 10MB
stream = mx.Producer('my_stream', buffer_size=int(1e6), buffer_count=10, sync=False)

# Write the series 0-9 repeatedly to a buffer 1000 times
for i in range(0, 1000):
    buffer = stream.next_to_send()
    buffer.write(f'{i % 10}'.encode('utf8')) # Note: writing to buffer via [<index>] and [<start_index>:<stop_index>] is also possible
    buffer.send() # Note: call with .send(<num bytes>) if you want to explicitly control the data_size parameter, otherwise internal cursor will be used
# Consumer Process(es)
import momentumx as mx

stream = mx.Consumer('my_stream')

while stream.is_alive:
    # Receive from the stream as long as the stream is available 
    buffer = stream.receive()
    print(buffer[:buffer.data_size])

Syncronous Mode (e.g. lossless)

# Producer Process
import momentumx as mx
import threading
import signal

cancel_event = threading.Event()
signal.signal(signal.SIGINT, (lambda _sig, _frm: cancel_event.set()))

# Create a stream with a total capacity of 10MB
stream = mx.Producer('my_stream', buffer_size=int(1e6), buffer_count=10, sync=True) # NOTE: sync set to True

min_subscribers = 1

while stream.subscriber_count < min_subscribers:
    print("waiting for subscriber(s)")
    if cancel_event.wait(0.5):
        break

print("All expected subscribers are ready")

# Write the series 0-999 to a consumer 
for n in range(0, 1000):
    if stream.subscriber_count == 0:
        cancel_event.wait(0.5)

    # Note: sending strings directly is possible via the send_string call
    elif stream.send_string(str(n)):
        print(f"Sent: {n}")
# Consumer Process(es)
import momentumx as mx

stream = mx.Consumer('my_stream')

while stream.is_alive:
    # Note: receiving strings is possible as well via the receive_string call
    print(f"Received: {stream.receive_string()}")

Numpy Integration

import momentumx as mx
import numpy as np

# Create a stream
stream = mx.Consumer('numpy_stream')

# Receive the next buffer (or if a producer, obtain the next_to_send buffer)
buffer = stream.receive()

# Create a numpy array directly from the memory without any copying
np_buff = np.frombuffer(buffer, dtype=uint8)

License

Captivation Software, LLC offers MomentumX under an Unlimited Use License to the United States Government, with all other parties subject to the GPL-3.0 License.

Inquiries / Requests

All inquiries and requests may be sent to opensource@captivation.us.

Copyright © 2022-2023 - Captivation Software, LLC.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

MomentumX-2.2.0.tar.gz (170.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

MomentumX-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

MomentumX-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

MomentumX-2.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

MomentumX-2.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

MomentumX-2.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.8 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

MomentumX-2.2.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.8 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

Details for the file MomentumX-2.2.0.tar.gz.

File metadata

  • Download URL: MomentumX-2.2.0.tar.gz
  • Upload date:
  • Size: 170.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for MomentumX-2.2.0.tar.gz
Algorithm Hash digest
SHA256 747a797f47218c6c03af63a4053cd915b9d2f0745948a1adab2552b414c0a47e
MD5 2fe2b1dce1a8ed628e9127ac98480459
BLAKE2b-256 a7dc12ed3b372e867909773c1e32fb4c29910756b627fd28949b84066ca484e9

See more details on using hashes here.

File details

Details for the file MomentumX-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for MomentumX-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dfd9fb310b5fb9019c79b5d1d70bda252bcebe3aa6cb322f9b067959a3a6fd56
MD5 190725956ed9133106e6cd6d1d831321
BLAKE2b-256 eb855edce14b7169c12ac1640edb6a00ff24a2db415de790af6c04f35b07a58a

See more details on using hashes here.

File details

Details for the file MomentumX-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for MomentumX-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2f5669707c1e4f046b0c867fb52debdda8c36530b442a5abf89ea5e16a0c6c70
MD5 323b46e4430a73540ae28972ff87d841
BLAKE2b-256 d5ced92c119dc612e00b84812f053649a540ccd5045276a7c0a99a99c192209c

See more details on using hashes here.

File details

Details for the file MomentumX-2.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for MomentumX-2.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c2e032fe66faa119497580e12e4496b2e464d0568abdbb4a98915979f7088e8
MD5 5f964f878d7212583feb7f9078c19e24
BLAKE2b-256 e6700e5cc54e8b800965b37585927e85ab511167395c9f1c388223b49038545d

See more details on using hashes here.

File details

Details for the file MomentumX-2.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for MomentumX-2.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8db25f65510fea980891593ebc5592af27e30f8f47e695eb9d01258f97481739
MD5 f48463269d6268edea40fe4eaab91f8c
BLAKE2b-256 87b2956b23e86840deb750ff3a4033ac66b2b98468de3684c144700a971f2679

See more details on using hashes here.

File details

Details for the file MomentumX-2.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for MomentumX-2.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 96a69082d6f2e73266d24c181214e0a3365646e9612bf0f7b0c8b0066a31be44
MD5 dc429ef702d43302def996c7a00845d7
BLAKE2b-256 015af68cdba742d00c0aea9d809b78e2c2125b2124e888cb08b4067e3cf9e4cc

See more details on using hashes here.

File details

Details for the file MomentumX-2.2.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for MomentumX-2.2.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4213b00c691c3213b435ce84f099eb6c270f637f5e551e114c99f377f5b2b17a
MD5 7dec1bf9cc69b716d69347b829185eda
BLAKE2b-256 ad558462e251be217c0c73eea1ad473bac95507ae0a45b78ebc949d7a75cba29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page