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)

Isolated Contexts

MomentumX allows for the usage of streams outside of /dev/shm (the default location). Pass the context kwarg pointing
to a directory on the filesystem for both the Producer and all Consumer instances to create isolated contexts.

This option is useful if access to /dev/shm is unsuitable.

import momentumx as mx

# Create a producer attached to the context path /my/path
stream = mx.Producer('my_stream', ..., context='/my/path/')
...

# Create Consumer elsewhere attached to the same context of /my/path
stream = mx.Consumer('my_stream', context='/my/path/')

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.3.1.tar.gz (45.6 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.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (198.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

MomentumX-2.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (198.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

MomentumX-2.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

MomentumX-2.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (198.7 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

MomentumX-2.3.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (200.2 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

MomentumX-2.3.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (200.1 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

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

File metadata

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

File hashes

Hashes for MomentumX-2.3.1.tar.gz
Algorithm Hash digest
SHA256 eab2f901b380752e36e87bcc049d0379473e4004f6151df4d5117403140dd0bc
MD5 17ada818ce4d5052b630f1a10b439bb6
BLAKE2b-256 0a7d13979e4e89e6f821638acd2bb6b8cd111ffe00e3af47b0b43cddf285c3dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7a99e84d743edf2dcd9844479f07ecada5cea9a6729cd9cda7ed72d87b518426
MD5 77ad101d94316910c788a2dce40628f5
BLAKE2b-256 2da1f3feef47682b3cf71e12fb544e094c69ff2ac86fe115db6e558df1a36033

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 76c379cbb7ab929dc5808ba3f1e5ce945f5eaa3ac283ada43158426a9a73ddcf
MD5 fbd7fa2e36bc238e95b8faf4ce088486
BLAKE2b-256 a2d9b3ac94ce5908d13bdd0300019c775b8a0a14459d4ffe189ece6e845d089e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2249d0d4f5be5f2b587b6dc6e27f1155eae0cdab00520cfeb294cfaac40cb45f
MD5 6f41ca563b2cf8a0d5590677d9fba67b
BLAKE2b-256 7768593c019060d5a52d990d8c0494bf6009e3168dac80c75f7ef1ae564bf0ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 81edcf102b07485948838a501594002cfaba504109bffc1fed71cc71d3710af2
MD5 afa8bc44b51e119654f35c0c5d6665ad
BLAKE2b-256 4176f207ddb95bc68556bf3b2284cc2db2d5ee832e4c9d9b0543de2636a3956f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.3.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9ffc1d16559c111ecc3c0e374f9bdbd02970b602b838c6d910e77243f8c9622c
MD5 1309547055c1d1e26355584172947c7e
BLAKE2b-256 60cbb8edac6106e90f11cc95bfdf6e24816f6cdbe0fbc6c245b8388f93433985

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for MomentumX-2.3.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc8887d3a3e4981f6695bfa89511ffcf4e5614f68fdd88bd25ee9a4488115bd1
MD5 605b25ac0010aa5b62cb2f23cb455d85
BLAKE2b-256 4b343bc39f7e545e13f6a90ddd4655d12e3fa1319dbe2ff5757c8f9abf313655

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