data-place


Namedata-place JSON
Version 0.3.5 PyPI version JSON
download
home_pagehttps://github.com/Shahaf-F-S/data-place
SummaryA powerfull and flexible framework for designing async socket based data streaming and distribution systems, with automated parsing, dynamic data store and high-level control hooks.
upload_time2024-08-17 17:17:32
maintainerNone
docs_urlNone
authorShahaf Frank-Shapir
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements websockets
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # data-place

> A powerful and flexible framework for designing async socket based data streaming and distribution systems, with automated parsing, dynamic data store and high-level control hooks.

Installation
-----------
````
pip install data-place
````

example
-----------
* integrates with dataclasses and pydantic as a side effect

A definition of a data model. 
Can be either shared globally or reimplemented separately.
Also defines an async loop function that will be used to produce Data objects.

```python
from dataclasses import dataclass
import asyncio
import random
from uuid import uuid4
from dataplace import ModelIO, Controller


@dataclass(slots=True, frozen=True)
class Data(ModelIO):
    id: str
    value: int


async def produce(controller: Controller) -> None:
    while controller.running:
        await controller.async_hold()
        await controller.async_callback(
            Data(id=str(uuid4()), value=random.randint(0, 9))
        )

        await asyncio.sleep(1)
```

async socket based data sending server
```python
import asyncio
from dataplace import Sender, Controller, Callback, SpaceStore

store = SpaceStore[int, Data](lambda data: data.value, Data)

server = Sender.Socket.Server(host="127.0.0.1", port=5555)

controller = Controller(
    callbacks=[
        Callback(store.add, types={Data}),
        Callback(server.call, types={Data}),
        Callback(print, types={Data})
    ]
)

loop = asyncio.new_event_loop()
loop.create_task(produce(controller))
loop.create_task(server.start())
loop.run_forever()
```

async socket based data receiving client
```python
import asyncio
from dataplace import Receiver, Callback, SpaceStore

store = SpaceStore[int, Data](lambda data: data.value, Data)

client = Receiver.Socket.Client(
    host="127.0.0.1",
    port=5555,
    callbacks=[
        Callback(store.add, types={Data}),
        Callback(print, types={Data})
    ]
)

loop = asyncio.new_event_loop()
loop.create_task(client.start())
loop.run_forever()
```

async websocket based data sending server
```python
import asyncio
from dataplace import Sender, Controller, Callback, SpaceStore

store = SpaceStore[int, Data](lambda data: data.value, Data)

server = Sender.WebSocket.Server(host="127.0.0.1", port=5555)

controller = Controller(
    callbacks=[
        Callback(store.add, types={Data}),
        Callback(server.call, types={Data}),
        Callback(print, types={Data})
    ]
)

loop = asyncio.new_event_loop()
loop.create_task(produce(controller))
loop.create_task(server.start())
loop.run_forever()
```

async websocket based data receiving client
```python
import asyncio
from dataplace import Receiver, Callback, SpaceStore

store = SpaceStore[int, Data](lambda data: data.value, Data)

client = Receiver.WebSocket.Client(
    url="ws://127.0.0.1:5555",
    callbacks=[
        Callback(store.add, types={Data}),
        Callback(print, types={Data})
    ]
)

loop = asyncio.new_event_loop()
loop.create_task(client.start())
loop.run_forever()
```

async socket based data receiving server
```python
import asyncio
from dataplace import Receiver, Callback, SpaceStore

store = SpaceStore[int, Data](lambda data: data.value, Data)

server = Receiver.Socket.Server(
    host="127.0.0.1",
    port=5555,
    callbacks=[
        Callback(store.add, types={Data}),
        Callback(print, types={Data})
    ]
)

loop = asyncio.new_event_loop()
loop.create_task(server.start())
loop.run_forever()
```

async socket based data sending client
```python
    store = SpaceStore[int, Data](lambda data: data.value, Data)

client = Sender.Socket.Client(host="127.0.0.1", port=5555)

controller = Controller(
    callbacks=[
        Callback(store.add, types={Data}),
        Callback(client.call, types={Data}),
        Callback(print, types={Data})
    ]
)

loop = asyncio.new_event_loop()
loop.run_until_complete(client.start())
loop.create_task(produce(controller))
loop.run_forever()
```

async websocket based data receiving server
```python
import asyncio
from dataplace import Receiver, Callback, SpaceStore

store = SpaceStore[int, Data](lambda data: data.value, Data)

server = Receiver.WebSocket.Server(
    host="127.0.0.1",
    port=5555,
    callbacks=[
        Callback(store.add, types={Data}),
        Callback(print, types={Data})
    ]
)

loop = asyncio.new_event_loop()
loop.create_task(server.start())
loop.run_forever()
```

async websocket based data sending client
```python
import asyncio
from dataplace import Sender, Callback, SpaceStore

store = SpaceStore[int, Data](lambda data: data.value, Data)

client = Sender.WebSocket.Client(url="ws://127.0.0.1:5555")

controller = Controller(
    callbacks=[
        Callback(store.add, types={Data}),
        Callback(client.call, types={Data}),
        Callback(print, types={Data})
    ]
)

loop = asyncio.new_event_loop()
loop.run_until_complete(client.start())
loop.create_task(produce(controller))
loop.run_forever()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Shahaf-F-S/data-place",
    "name": "data-place",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Shahaf Frank-Shapir",
    "author_email": "shahaffrs@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/da/fd/bb8bd38e4c7a0a7d471354fcc050305be64110b48a98fb1c16e5b60a2efb/data-place-0.3.5.tar.gz",
    "platform": null,
    "description": "# data-place\r\n\r\n> A powerful and flexible framework for designing async socket based data streaming and distribution systems, with automated parsing, dynamic data store and high-level control hooks.\r\n\r\nInstallation\r\n-----------\r\n````\r\npip install data-place\r\n````\r\n\r\nexample\r\n-----------\r\n* integrates with dataclasses and pydantic as a side effect\r\n\r\nA definition of a data model. \r\nCan be either shared globally or reimplemented separately.\r\nAlso defines an async loop function that will be used to produce Data objects.\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\nimport asyncio\r\nimport random\r\nfrom uuid import uuid4\r\nfrom dataplace import ModelIO, Controller\r\n\r\n\r\n@dataclass(slots=True, frozen=True)\r\nclass Data(ModelIO):\r\n    id: str\r\n    value: int\r\n\r\n\r\nasync def produce(controller: Controller) -> None:\r\n    while controller.running:\r\n        await controller.async_hold()\r\n        await controller.async_callback(\r\n            Data(id=str(uuid4()), value=random.randint(0, 9))\r\n        )\r\n\r\n        await asyncio.sleep(1)\r\n```\r\n\r\nasync socket based data sending server\r\n```python\r\nimport asyncio\r\nfrom dataplace import Sender, Controller, Callback, SpaceStore\r\n\r\nstore = SpaceStore[int, Data](lambda data: data.value, Data)\r\n\r\nserver = Sender.Socket.Server(host=\"127.0.0.1\", port=5555)\r\n\r\ncontroller = Controller(\r\n    callbacks=[\r\n        Callback(store.add, types={Data}),\r\n        Callback(server.call, types={Data}),\r\n        Callback(print, types={Data})\r\n    ]\r\n)\r\n\r\nloop = asyncio.new_event_loop()\r\nloop.create_task(produce(controller))\r\nloop.create_task(server.start())\r\nloop.run_forever()\r\n```\r\n\r\nasync socket based data receiving client\r\n```python\r\nimport asyncio\r\nfrom dataplace import Receiver, Callback, SpaceStore\r\n\r\nstore = SpaceStore[int, Data](lambda data: data.value, Data)\r\n\r\nclient = Receiver.Socket.Client(\r\n    host=\"127.0.0.1\",\r\n    port=5555,\r\n    callbacks=[\r\n        Callback(store.add, types={Data}),\r\n        Callback(print, types={Data})\r\n    ]\r\n)\r\n\r\nloop = asyncio.new_event_loop()\r\nloop.create_task(client.start())\r\nloop.run_forever()\r\n```\r\n\r\nasync websocket based data sending server\r\n```python\r\nimport asyncio\r\nfrom dataplace import Sender, Controller, Callback, SpaceStore\r\n\r\nstore = SpaceStore[int, Data](lambda data: data.value, Data)\r\n\r\nserver = Sender.WebSocket.Server(host=\"127.0.0.1\", port=5555)\r\n\r\ncontroller = Controller(\r\n    callbacks=[\r\n        Callback(store.add, types={Data}),\r\n        Callback(server.call, types={Data}),\r\n        Callback(print, types={Data})\r\n    ]\r\n)\r\n\r\nloop = asyncio.new_event_loop()\r\nloop.create_task(produce(controller))\r\nloop.create_task(server.start())\r\nloop.run_forever()\r\n```\r\n\r\nasync websocket based data receiving client\r\n```python\r\nimport asyncio\r\nfrom dataplace import Receiver, Callback, SpaceStore\r\n\r\nstore = SpaceStore[int, Data](lambda data: data.value, Data)\r\n\r\nclient = Receiver.WebSocket.Client(\r\n    url=\"ws://127.0.0.1:5555\",\r\n    callbacks=[\r\n        Callback(store.add, types={Data}),\r\n        Callback(print, types={Data})\r\n    ]\r\n)\r\n\r\nloop = asyncio.new_event_loop()\r\nloop.create_task(client.start())\r\nloop.run_forever()\r\n```\r\n\r\nasync socket based data receiving server\r\n```python\r\nimport asyncio\r\nfrom dataplace import Receiver, Callback, SpaceStore\r\n\r\nstore = SpaceStore[int, Data](lambda data: data.value, Data)\r\n\r\nserver = Receiver.Socket.Server(\r\n    host=\"127.0.0.1\",\r\n    port=5555,\r\n    callbacks=[\r\n        Callback(store.add, types={Data}),\r\n        Callback(print, types={Data})\r\n    ]\r\n)\r\n\r\nloop = asyncio.new_event_loop()\r\nloop.create_task(server.start())\r\nloop.run_forever()\r\n```\r\n\r\nasync socket based data sending client\r\n```python\r\n    store = SpaceStore[int, Data](lambda data: data.value, Data)\r\n\r\nclient = Sender.Socket.Client(host=\"127.0.0.1\", port=5555)\r\n\r\ncontroller = Controller(\r\n    callbacks=[\r\n        Callback(store.add, types={Data}),\r\n        Callback(client.call, types={Data}),\r\n        Callback(print, types={Data})\r\n    ]\r\n)\r\n\r\nloop = asyncio.new_event_loop()\r\nloop.run_until_complete(client.start())\r\nloop.create_task(produce(controller))\r\nloop.run_forever()\r\n```\r\n\r\nasync websocket based data receiving server\r\n```python\r\nimport asyncio\r\nfrom dataplace import Receiver, Callback, SpaceStore\r\n\r\nstore = SpaceStore[int, Data](lambda data: data.value, Data)\r\n\r\nserver = Receiver.WebSocket.Server(\r\n    host=\"127.0.0.1\",\r\n    port=5555,\r\n    callbacks=[\r\n        Callback(store.add, types={Data}),\r\n        Callback(print, types={Data})\r\n    ]\r\n)\r\n\r\nloop = asyncio.new_event_loop()\r\nloop.create_task(server.start())\r\nloop.run_forever()\r\n```\r\n\r\nasync websocket based data sending client\r\n```python\r\nimport asyncio\r\nfrom dataplace import Sender, Callback, SpaceStore\r\n\r\nstore = SpaceStore[int, Data](lambda data: data.value, Data)\r\n\r\nclient = Sender.WebSocket.Client(url=\"ws://127.0.0.1:5555\")\r\n\r\ncontroller = Controller(\r\n    callbacks=[\r\n        Callback(store.add, types={Data}),\r\n        Callback(client.call, types={Data}),\r\n        Callback(print, types={Data})\r\n    ]\r\n)\r\n\r\nloop = asyncio.new_event_loop()\r\nloop.run_until_complete(client.start())\r\nloop.create_task(produce(controller))\r\nloop.run_forever()\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A powerfull and flexible framework for designing async socket based data streaming and distribution systems, with automated parsing, dynamic data store and high-level control hooks.",
    "version": "0.3.5",
    "project_urls": {
        "Homepage": "https://github.com/Shahaf-F-S/data-place"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dafdbb8bd38e4c7a0a7d471354fcc050305be64110b48a98fb1c16e5b60a2efb",
                "md5": "86f61874e7c016c63700179545015018",
                "sha256": "4de86eefb5e40b65c11b7ea667506f4edc5581698b0484a24981e422c4cc2b9d"
            },
            "downloads": -1,
            "filename": "data-place-0.3.5.tar.gz",
            "has_sig": false,
            "md5_digest": "86f61874e7c016c63700179545015018",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11972,
            "upload_time": "2024-08-17T17:17:32",
            "upload_time_iso_8601": "2024-08-17T17:17:32.256321Z",
            "url": "https://files.pythonhosted.org/packages/da/fd/bb8bd38e4c7a0a7d471354fcc050305be64110b48a98fb1c16e5b60a2efb/data-place-0.3.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-17 17:17:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Shahaf-F-S",
    "github_project": "data-place",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "websockets",
            "specs": []
        }
    ],
    "lcname": "data-place"
}
        
Elapsed time: 0.48770s