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.2.tar.gz (172.1 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.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (191.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

MomentumX-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (191.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

MomentumX-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (191.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

MomentumX-2.2.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (191.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

MomentumX-2.2.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (191.0 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

MomentumX-2.2.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (191.0 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: MomentumX-2.2.2.tar.gz
  • Upload date:
  • Size: 172.1 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.2.tar.gz
Algorithm Hash digest
SHA256 00804fa113e5de58fdec6a7340cfe592df794ede2ddca708c28390c5e6c239d2
MD5 dda725839753771814d260d8c4c78f14
BLAKE2b-256 5e65cf25a90ae6b49c7cf960dfc015f918dd27fa49ab82337565e59ad167852c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d5e52b43065f1e86d934b528ab2291b54a317769a4941d8a155141f67bc8c0b3
MD5 de002573597ee980f26cf7c877250636
BLAKE2b-256 dbc1fcfe0afc6f458d42c7a815e626fffbc1bb6e72a0b8a4657f3816ae5da42a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b249a38537fb01c39fe8f5737a3e9bf307c5f3985b2ffa71fc025cd7c182eefa
MD5 4d7fae301fa97866cce355f8704e2641
BLAKE2b-256 4fe852e0979b0b87a60bf34e01bef813337bcad1e010e2fae113b8c21aa559de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f8914947014d1696e5d42d442dd728e06bbe99a677656e3ed1eebc37cf024356
MD5 2ed7907becf44a07603d3306f1957d7d
BLAKE2b-256 dd22f84acf8a3e534451e1870c2bdcd894dd5a3985715e085d2881396f7bd802

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.2.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 40f99c5b3ac2695f97804c291ac90afc4f0a733349e69ee10e2e026a8a19c390
MD5 16a676ecc48afc61792d6944fb331827
BLAKE2b-256 ed4a72ff9bb463e20dfa08182dfd9a91db1518cc94c4a6be3a5ebed5b56e06e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.2.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1004b46657fe3050d9e8d12c967d24d38cfd1c05a32d1cc816997f3ac2c657ab
MD5 ba5e5527876dfe52b7be013d8468789c
BLAKE2b-256 a4f161c0faf69dd8b419c1a2895a949f2403bbbde1c110475d88df1c258a7802

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.2.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2843088e792c3029f3cdea977a72ea0b745b2a9bbfc25316f66b58700b1e5cdd
MD5 c5c0daa39a9b24fafcb025b206252ef0
BLAKE2b-256 f63f1706034afbd98a287a0801764d00d0912d8ae525ec8da2caa224d8bf3079

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