streaminghub-datamux


Namestreaminghub-datamux JSON
Version 0.1.7 PyPI version JSON
download
home_page
SummaryA library to stream data into real-time analytics pipelines
upload_time2024-01-29 19:37:05
maintainer
docs_urlNone
author
requires_python>=3.10
licenseCopyright (c) 2023 Old Dominion University Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: This work shall be cited in the bibliography as: Yasith Jayawardana, Vikas G. Ashok, and Sampath Jayarathna. 2022. StreamingHub: interactive stream analysis workflows. In Proceedings of the 22nd ACM/IEEE Joint Conference on Digital Libraries (JCDL '22). Association for Computing Machinery, New York, NY, USA, Article 15, 1-10. https://doi.org/10.1145/3529372.3530936 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords dfds metadata parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DataMux

<img src="https://i.imgur.com/xSieE3V.png" height="100px">

**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.

```bash

pip install streaminghub-datamux==0.1.7

```

## Initialization

Next, configure where datamux should look for data and metadata.
The configuration is stored at ``~/.streaminghubrc``.

```bash

python -m datamux init --data_dir="<path/to/dataset/dir>" --meta_dir="<path/to/metadata/dir>"

```

## Usage

### Imports

```python

# Required functions / flags
import datamux.util as util
# Direct API (for running on the same system)
from datamux.api import DataMuxAPI
# Remote API (for running on a remote server)
from datamux.remote.api import DataMuxRemoteAPI

```

### Remote API

To start the remote API, run the following at server-side.

```bash
python -m datamux serve -H "<host_name>" -p <port> -r <rpc_name> -c <codec_name>
```

If you are running from source (from the datamux/ folder), use the following command instead.

```bash
PYTHONPATH=src python -m datamux serve -H "<host_name>" -p <port> -r <rpc_name> -c <codec_name>
```

At client side, you can connect to this server via the Python API.

```python
server_host = "<host_name>"
server_port = <port>
server_rpc = "<rpc_name>"
server_codec = "<codec_name>"
api = DataMuxRemoteAPI(server_rpc, server_codec)
await api.connect(server_host, server_port)

```

### Direct API

```python

api = DataMuxAPI()

```

### Listing Available Collections and their Streams

```python

collections = await api.list_collections()
collection_streams = await api.list_collection_streams("name_of_collection")

```

### Replaying a Collection-Stream

```python

# attributes to uniquely identify a recording
attrs = dict({"subject": "A", "session": "1", "task": "1"})
# queue to append replayed data
sink = asyncio.Queue()
# start replaying data into queue
ack = await api.replay_collection_stream("name_of_colelction", "name_of_stream", 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)

```

### Upgrade a Collection-Stream into LSL Stream

```python

status = await api.publish_collection_stream(collection_name, stream_name, attrs)

```

### List LSL Streams

```python

live_streams = await api.list_live_streams()

```

### Proxy a LSL Stream

```python

# attributes to uniquely identify a LSL stream
attrs = dict({"subject": "19681349", "session": "1", "task": "restEC"})
# queue to append proxied data
sink = asyncio.Queue()
# start proxying LSL data into queue
ack = await api.read_live_stream("stream_name", 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)

```

## Developer Guide

```bash

# create a virtual environment
python -m venv ~/.virtualenvs/datamux
# activate virtual environment
source ~/.virtualenvs/datamux/bin/activate
# install pip tools
python -m pip install --upgrade pip-tools
# generate requirements.txt
pip-compile --strip-extras -o requirements.txt pyproject.toml
pip-compile --strip-extras --extra dev -o requirements.dev.txt pyproject.toml
# install dependencies
pip-sync requirements.txt requirements.dev.txt
# update version (--patch or --minor or --major)
bumpver update --patch
# build package
python -m build
# check package
python -m twine check dist/*
# publish package (testpypi)
python -m twine upload -r testpypi dist/*
# publish package (pypi)
python -m twine upload dist/*

```

## Copyright

```
Copyright (c) 2023 Old Dominion University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

This work shall be cited in the bibliography as:

    Yasith Jayawardana, Vikas G. Ashok, and Sampath Jayarathna. 2022.
    StreamingHub: interactive stream analysis workflows. In Proceedings of
    the 22nd ACM/IEEE Joint Conference on Digital Libraries (JCDL '22).
    Association for Computing Machinery, New York, NY, USA, Article 15, 1-10.
    https://doi.org/10.1145/3529372.3530936

    Yasith Jayawardana and Sampath Jayarathna. 2020. Streaming Analytics and
    Workflow Automation for DFS. In Proceedings of the 20th ACM/IEEE Joint
    Conference on Digital Libraries (JCDL '20).
    Association for Computing Machinery, New York, NY, USA, 513-514.
    https://doi.org/10.1145/3383583.3398589

    Yasith Jayawardana and Sampath Jayarathna. 2019. DFS: A Dataset File
    System for Data Discovering Users. In Proceedings of the 19th ACM/IEEE
    Joint Conference on Digital Libraries in 2019 (JCDL '19).
    Association for Computing Machinery, New York, NY, USA, 355-356.
    https://doi.org/10.1109/JCDL.2019.00068

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "streaminghub-datamux",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "dfds,metadata,parser",
    "author": "",
    "author_email": "Yasith Jayawardana <yasith@cs.odu.edu>",
    "download_url": "https://files.pythonhosted.org/packages/4e/23/c3aa714e8963101d8d7e49ede4da81ef4f319fe56ead40c406a69ead5184/streaminghub-datamux-0.1.7.tar.gz",
    "platform": null,
    "description": "# DataMux\n\n<img src=\"https://i.imgur.com/xSieE3V.png\" height=\"100px\">\n\n**DataMux** is a library to stream data into real-time analytics pipelines.\nIt provides the modes listed below.\n\n* **Proxy Mode**: to interface and proxy live data from sensors\n* **Replay Mode**: to replay stored data from datasets\n* **Simulate Mode**: to stream guided/unguided mock data for testing\n\n## Installation\n\nFirst, install datamux as a pip package.\n\n```bash\n\npip install streaminghub-datamux==0.1.7\n\n```\n\n## Initialization\n\nNext, configure where datamux should look for data and metadata.\nThe configuration is stored at ``~/.streaminghubrc``.\n\n```bash\n\npython -m datamux init --data_dir=\"<path/to/dataset/dir>\" --meta_dir=\"<path/to/metadata/dir>\"\n\n```\n\n## Usage\n\n### Imports\n\n```python\n\n# Required functions / flags\nimport datamux.util as util\n# Direct API (for running on the same system)\nfrom datamux.api import DataMuxAPI\n# Remote API (for running on a remote server)\nfrom datamux.remote.api import DataMuxRemoteAPI\n\n```\n\n### Remote API\n\nTo start the remote API, run the following at server-side.\n\n```bash\npython -m datamux serve -H \"<host_name>\" -p <port> -r <rpc_name> -c <codec_name>\n```\n\nIf you are running from source (from the datamux/ folder), use the following command instead.\n\n```bash\nPYTHONPATH=src python -m datamux serve -H \"<host_name>\" -p <port> -r <rpc_name> -c <codec_name>\n```\n\nAt client side, you can connect to this server via the Python API.\n\n```python\nserver_host = \"<host_name>\"\nserver_port = <port>\nserver_rpc = \"<rpc_name>\"\nserver_codec = \"<codec_name>\"\napi = DataMuxRemoteAPI(server_rpc, server_codec)\nawait api.connect(server_host, server_port)\n\n```\n\n### Direct API\n\n```python\n\napi = DataMuxAPI()\n\n```\n\n### Listing Available Collections and their Streams\n\n```python\n\ncollections = await api.list_collections()\ncollection_streams = await api.list_collection_streams(\"name_of_collection\")\n\n```\n\n### Replaying a Collection-Stream\n\n```python\n\n# attributes to uniquely identify a recording\nattrs = dict({\"subject\": \"A\", \"session\": \"1\", \"task\": \"1\"})\n# queue to append replayed data\nsink = asyncio.Queue()\n# start replaying data into queue\nack = await api.replay_collection_stream(\"name_of_colelction\", \"name_of_stream\", attrs, sink)\n# each request is assigned a unique ID for later reference\nassert ack.randseq is not None\n# simply await the queue to read data\nwhile True:\n    item = await sink.get()\n    # checking for end-of-stream\n    if item == util.END_OF_STREAM:\n        break\n# once done, stop the task to avoid wasting resources\nawait api.stop_task(ack.randseq)\n\n```\n\n### Upgrade a Collection-Stream into LSL Stream\n\n```python\n\nstatus = await api.publish_collection_stream(collection_name, stream_name, attrs)\n\n```\n\n### List LSL Streams\n\n```python\n\nlive_streams = await api.list_live_streams()\n\n```\n\n### Proxy a LSL Stream\n\n```python\n\n# attributes to uniquely identify a LSL stream\nattrs = dict({\"subject\": \"19681349\", \"session\": \"1\", \"task\": \"restEC\"})\n# queue to append proxied data\nsink = asyncio.Queue()\n# start proxying LSL data into queue\nack = await api.read_live_stream(\"stream_name\", attrs, sink)\n# each request is assigned a unique ID for later reference\nassert ack.randseq is not None\n# simply await the queue to read data\nwhile True:\n    item = await sink.get()\n    # checking for end-of-stream\n    if item == util.END_OF_STREAM:\n        break\n# once done, stop the task to avoid wasting resources\nawait api.stop_task(ack.randseq)\n\n```\n\n## Developer Guide\n\n```bash\n\n# create a virtual environment\npython -m venv ~/.virtualenvs/datamux\n# activate virtual environment\nsource ~/.virtualenvs/datamux/bin/activate\n# install pip tools\npython -m pip install --upgrade pip-tools\n# generate requirements.txt\npip-compile --strip-extras -o requirements.txt pyproject.toml\npip-compile --strip-extras --extra dev -o requirements.dev.txt pyproject.toml\n# install dependencies\npip-sync requirements.txt requirements.dev.txt\n# update version (--patch or --minor or --major)\nbumpver update --patch\n# build package\npython -m build\n# check package\npython -m twine check dist/*\n# publish package (testpypi)\npython -m twine upload -r testpypi dist/*\n# publish package (pypi)\npython -m twine upload dist/*\n\n```\n\n## Copyright\n\n```\nCopyright (c) 2023 Old Dominion University\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThis work shall be cited in the bibliography as:\n\n    Yasith Jayawardana, Vikas G. Ashok, and Sampath Jayarathna. 2022.\n    StreamingHub: interactive stream analysis workflows. In Proceedings of\n    the 22nd ACM/IEEE Joint Conference on Digital Libraries (JCDL '22).\n    Association for Computing Machinery, New York, NY, USA, Article 15, 1-10.\n    https://doi.org/10.1145/3529372.3530936\n\n    Yasith Jayawardana and Sampath Jayarathna. 2020. Streaming Analytics and\n    Workflow Automation for DFS. In Proceedings of the 20th ACM/IEEE Joint\n    Conference on Digital Libraries (JCDL '20).\n    Association for Computing Machinery, New York, NY, USA, 513-514.\n    https://doi.org/10.1145/3383583.3398589\n\n    Yasith Jayawardana and Sampath Jayarathna. 2019. DFS: A Dataset File\n    System for Data Discovering Users. In Proceedings of the 19th ACM/IEEE\n    Joint Conference on Digital Libraries in 2019 (JCDL '19).\n    Association for Computing Machinery, New York, NY, USA, 355-356.\n    https://doi.org/10.1109/JCDL.2019.00068\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n```\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2023 Old Dominion University  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  This work shall be cited in the bibliography as:  Yasith Jayawardana, Vikas G. Ashok, and Sampath Jayarathna. 2022. StreamingHub: interactive stream analysis workflows. In Proceedings of the 22nd ACM/IEEE Joint Conference on Digital Libraries (JCDL '22). Association for Computing Machinery, New York, NY, USA, Article 15, 1-10. https://doi.org/10.1145/3529372.3530936  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A library to stream data into real-time analytics pipelines",
    "version": "0.1.7",
    "project_urls": {
        "homepage": "https://github.com/nirdslab/streaminghub/tree/master/datamux"
    },
    "split_keywords": [
        "dfds",
        "metadata",
        "parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e10faff3307bfd34a587dbde4cc62ca741734b19120bfff79c19d54dea223a8c",
                "md5": "d341036f966ddf14b50015e9e5751662",
                "sha256": "1c8190cebd479d29abfef4bc207d35bb923506d47706c7d9e8b35c925bf0c8b8"
            },
            "downloads": -1,
            "filename": "streaminghub_datamux-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d341036f966ddf14b50015e9e5751662",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 33551,
            "upload_time": "2024-01-29T19:37:03",
            "upload_time_iso_8601": "2024-01-29T19:37:03.351422Z",
            "url": "https://files.pythonhosted.org/packages/e1/0f/aff3307bfd34a587dbde4cc62ca741734b19120bfff79c19d54dea223a8c/streaminghub_datamux-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e23c3aa714e8963101d8d7e49ede4da81ef4f319fe56ead40c406a69ead5184",
                "md5": "1674f1b6fcb1eb8649538b2cf475b069",
                "sha256": "95f0e40f81b02c8b859019395c87d1711addb742742ef93f3841ba17649e2b11"
            },
            "downloads": -1,
            "filename": "streaminghub-datamux-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "1674f1b6fcb1eb8649538b2cf475b069",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 28489,
            "upload_time": "2024-01-29T19:37:05",
            "upload_time_iso_8601": "2024-01-29T19:37:05.689369Z",
            "url": "https://files.pythonhosted.org/packages/4e/23/c3aa714e8963101d8d7e49ede4da81ef4f319fe56ead40c406a69ead5184/streaminghub-datamux-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-29 19:37:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nirdslab",
    "github_project": "streaminghub",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "streaminghub-datamux"
}
        
Elapsed time: 0.20861s