{ "info": { "author": "Lo\u00efc Peron", "author_email": "peronloic.us@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "simpy-events\n============ \n\n|license| |python version| |build-status| |docs| |coverage| |pypi package|\n\n.. |license| image:: https://img.shields.io/github/license/loicpw/simpy-events.svg\n.. |build-status| image:: https://travis-ci.org/loicpw/simpy-events.svg?branch=master\n :target: https://travis-ci.org/loicpw/simpy-events\n.. |docs| image:: https://readthedocs.org/projects/simpy-events/badge/?version=latest\n :target: http://simpy-events.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n.. |coverage| image:: https://coveralls.io/repos/github/loicpw/simpy-events/badge.svg?branch=master\n :target: https://coveralls.io/github/loicpw/simpy-events?branch=master\n.. |pypi package| image:: https://badge.fury.io/py/simpy-events.svg\n :target: https://badge.fury.io/py/simpy-events\n.. |python version| image:: https://img.shields.io/pypi/pyversions/simpy-events.svg\n :target: https://pypi.python.org/pypi/simpy-events\n\nevent system with `SimPy`_ to decouple simulation code and increase reusability\n\n\n\n( >>>>>>> **WORK IN PROGRESS** <<<<<<< )\n\n\n\nA basic example\n=======================\n\n.. note:: `SimPy`_ is a process-based discrete-event simulation framework based on standard Python.\n\n+ Our simplified scenario is composed of:\n\n - satellites emitting signals\n - receivers receiving and processing signals\n\n+ basic imports and creating the root namespace:\n\n .. code-block:: python\n\n from simpy_events.manager import RootNameSpace\n import simpy\n\n root = RootNameSpace()\n\n+ implementing a satellite model:\n\n .. code-block:: python\n\n sat = root.ns('satellite')\n\n class Satellite:\n chunk = 4\n\n def __init__(self, name, data):\n self.signal = sat.event('signal', sat=name)\n self.data = tuple(map(str, data))\n\n def process(self, env):\n signal = self.signal\n data = self.data\n chunk = self.chunk\n # slice data in chunks\n for chunk in [data[chunk*i:chunk*i+chunk]\n for i in range(int(len(data) / chunk))]:\n event = env.timeout(1, ','.join(chunk))\n yield signal(event)\n\n+ implementing a receiver model:\n\n .. code-block:: python\n\n receiver = root.ns('receiver')\n signals = receiver.topic('signals') \n\n @signals.after\n def receive_signal(context, event):\n env = event.env\n metadata = context.event.metadata\n header = str({key: val for key, val in metadata.items()\n if key not in ('name', 'ns')})\n env.process(process_signal(env, header, event.value))\n\n def process_signal(env, header, signal):\n receive = receiver.event('process')\n for data in signal.split(','):\n yield receive(env.timeout(0, f'{header}: {data}'))\n\n+ creating code to analyse what's going on:\n\n .. code-block:: python\n\n @root.enable('analyse')\n def new_process(context, event):\n metadata = context.event.metadata\n context = {key: str(val) for key, val in metadata.items()}\n print(f'new signal process: {context}')\n\n @root.after('analyse')\n def signal(context, event):\n metadata = context.event.metadata\n ns = metadata['ns']\n print(f'signal: {ns.path}: {event.value}') \n\n+ setting up our simulation:\n\n .. code-block:: python\n\n root.topic('receiver::signals').extend([\n '::satellite::signal',\n ])\n root.topic('analyse').extend([\n '::satellite::signal',\n '::receiver::process',\n ])\n\n def run(env):\n # create some actors\n s1 = Satellite('sat1', range(8))\n s2 = Satellite('sat2', range(100, 108))\n env.process(s1.process(env))\n env.process(s2.process(env))\n\n # execute\n root.enabled = True\n env.run()\n\n+ running the simulation ::\n\n new signal process: {'ns': '::satellite', 'name': 'signal', 'sat': 'sat1'}\n new signal process: {'ns': '::satellite', 'name': 'signal', 'sat': 'sat2'}\n signal: ::satellite: 0,1,2,3\n new signal process: {'ns': '::receiver', 'name': 'process'}\n signal: ::satellite: 100,101,102,103\n new signal process: {'ns': '::receiver', 'name': 'process'}\n signal: ::receiver: {'sat': 'sat1'}: 0\n signal: ::receiver: {'sat': 'sat2'}: 100\n signal: ::receiver: {'sat': 'sat1'}: 1\n signal: ::receiver: {'sat': 'sat2'}: 101\n signal: ::receiver: {'sat': 'sat1'}: 2\n signal: ::receiver: {'sat': 'sat2'}: 102\n signal: ::receiver: {'sat': 'sat1'}: 3\n signal: ::receiver: {'sat': 'sat2'}: 103\n signal: ::satellite: 4,5,6,7\n new signal process: {'ns': '::receiver', 'name': 'process'}\n signal: ::satellite: 104,105,106,107\n new signal process: {'ns': '::receiver', 'name': 'process'}\n signal: ::receiver: {'sat': 'sat1'}: 4\n signal: ::receiver: {'sat': 'sat2'}: 104\n signal: ::receiver: {'sat': 'sat1'}: 5\n signal: ::receiver: {'sat': 'sat2'}: 105\n signal: ::receiver: {'sat': 'sat1'}: 6\n signal: ::receiver: {'sat': 'sat2'}: 106\n signal: ::receiver: {'sat': 'sat1'}: 7\n signal: ::receiver: {'sat': 'sat2'}: 107\n\ninstall and test\n=======================\n\ninstall from pypi\n********************\n\nusing pip:\n\n.. code-block:: bash\n\n $ pip install simpy-events\n\ndev install\n****************\n\nThere is a makefile in the project root directory:\n\n.. code-block:: bash\n\n $ make dev\n\nUsing pip, the above is equivalent to:\n\n.. code-block:: bash\n\n $ pip install -r requirements-dev.txt \n $ pip install -e .\n\nrun the tests\n******************\n\nUse the makefile in the project root directory:\n\n.. code-block:: bash\n\n $ make test\n\nThis runs the tests generating a coverage html report\n\nbuild the doc\n******************\n\nThe documentation is made with sphinx, you can use the makefile in the\nproject root directory to build html doc:\n\n.. code-block:: bash\n\n $ make doc\n\nDocumentation\n=======================\n\nDocumentation on `Read The Docs`_.\n\nMeta\n=======================\n\nloicpw - peronloic.us@gmail.com\n\nDistributed under the MIT license. See ``LICENSE.txt`` for more information.\n\nhttps://github.com/loicpw\n\n\n.. _Read The Docs: http://simpy-events.readthedocs.io/en/latest/\n.. _SimPy: https://simpy.readthedocs.org\n\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/loicpw/simpy-events.git", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/loicpw/simpy-events", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "simpy-events", "package_url": "https://pypi.org/project/simpy-events/", "platform": "", "project_url": "https://pypi.org/project/simpy-events/", "project_urls": { "Download": "https://github.com/loicpw/simpy-events.git", "Homepage": "https://github.com/loicpw/simpy-events" }, "release_url": "https://pypi.org/project/simpy-events/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "event system with simpy to decouple simulation code and increase reusability", "version": "0.0.1" }, "last_serial": 4956013, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "148b65940566b48fd993c7ab02782fad", "sha256": "9d4da355d7e70df73c3cdd4d8faaeef94309bd3f3421ac35ad1185a8204031fc" }, "downloads": -1, "filename": "simpy_events-0.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "148b65940566b48fd993c7ab02782fad", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21256, "upload_time": "2019-03-18T21:40:13", "url": "https://files.pythonhosted.org/packages/51/df/17936d35c0b340e2e0b2061bba5c61fc4625616d9809a89b9654f6f8bf3d/simpy_events-0.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5b7d144182f9094873ffd0da1df2ed3b", "sha256": "3b831f0f5ff15e6a4348207822fd88fa4384e2f60243015015c6be3c8ab168b2" }, "downloads": -1, "filename": "simpy_events-0.0.0.tar.gz", "has_sig": false, "md5_digest": "5b7d144182f9094873ffd0da1df2ed3b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20573, "upload_time": "2019-03-18T21:40:15", "url": "https://files.pythonhosted.org/packages/54/eb/2774b1ec4b669b2a90ecc7f4a8c0cbacdfa14b27fd9fe23835f4b225871f/simpy_events-0.0.0.tar.gz" } ], "0.0.1": [ { "comment_text": "", "digests": { "md5": "d61de20b1535393d9f448012ceadc0c1", "sha256": "9260a788b0f902509475349471b560dc37b47a77bf5f7a1ab21aef20b194eaa2" }, "downloads": -1, "filename": "simpy_events-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d61de20b1535393d9f448012ceadc0c1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21256, "upload_time": "2019-03-18T21:39:53", "url": "https://files.pythonhosted.org/packages/a4/d3/e9cf700baff92ac8e562dfec9ff38e2f64bb3d1973dce4fc376400f63a15/simpy_events-0.0.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d61de20b1535393d9f448012ceadc0c1", "sha256": "9260a788b0f902509475349471b560dc37b47a77bf5f7a1ab21aef20b194eaa2" }, "downloads": -1, "filename": "simpy_events-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d61de20b1535393d9f448012ceadc0c1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21256, "upload_time": "2019-03-18T21:39:53", "url": "https://files.pythonhosted.org/packages/a4/d3/e9cf700baff92ac8e562dfec9ff38e2f64bb3d1973dce4fc376400f63a15/simpy_events-0.0.1-py3-none-any.whl" } ] }