Package: kiwipy
kiwiPykiwiPyis a library that makes remote messaging using RabbitMQ (and possibly other message brokers) EASY.  It was
designed to support high-throughput workflows in big-data and computational science settings and is currently used
byAiiDAfor computational materials research around the world.  That said, kiwiPy is entirely general and can
be used anywhere where high-throughput and robust messaging are needed.Here’s what you get:RPCBroadcast (with filters)Task queue messagesLet’s dive in, with some examples taken from thermq tutorial.  To see more detail head over to thedocumentation.RPCThe client:importkiwipywithkiwipy.connect('amqp://localhost')ascomm:# Send an RPC messageprint(" [x] Requesting fib(30)")response=comm.rpc_send('fib',30).result()print((" [.] Got%r"%response))(rmq_rpc_client.py source)The server:importthreadingimportkiwipydeffib(comm,num):ifnum==0:return0ifnum==1:return1returnfib(comm,num-1)+fib(comm,num-2)withkiwipy.connect('amqp://127.0.0.1')ascomm:# Register an RPC subscriber with the name 'fib'comm.add_rpc_subscriber(fib,'fib')# Now wait indefinitely for fibonacci callsthreading.Event().wait()(rmq_rpc_server.py source)WorkerCreate a new task:importsysimportkiwipymessage=' '.join(sys.argv[1:])or"Hello World!"withrmq.connect('amqp://localhost')ascomm:comm.task_send(message)(rmq_new_task.py source)And the worker:importtimeimportthreadingimportkiwipyprint(' [*] Waiting for messages. To exit press CTRL+C')defcallback(_comm,task):print((" [x] Received%r"%task))time.sleep(task.count(b'.'))print(" [x] Done")try:withkiwipy.connect('amqp://localhost')ascomm:comm.add_task_subscriber(callback)threading.Event().wait()exceptKeyboardInterrupt:pass(rmq_worker.py source)CitingIf you use kiwiPy directly or indirectly (e.g. by usingAiiDA) then please cite:Uhrin, M., & Huber, S. P. (2020). kiwiPy : Robust , high-volume , messaging for big-data and computational science workflows, 5, 4–6.http://doi.org/10.21105/joss.02351This helps us to keep making community software.VersioningThis software followsSemantic VersioningContributingWant a new feature? Found a bug? Want to contribute more documentation or a translation perhaps?Help is always welcome, get started with thecontributing guide.DevelopmentThis package utilisestoxfor unit test automation, andpre-commitfor code style formatting and test automation.To install these development dependencies:pipinstalltoxpre-commitTo run the unit tests:toxFor thermqtests you will require a running instance of RabbitMQ.
One way to achieve this is using Docker and launchingtest/rmq/docker-compose.yml.To run the pre-commit tests:pre-commitrun--allTo build the documentation:tox-edocs-cleanChanges should be submitted as Pull Requests (PRs) to thedevelopbranch.Publishing ReleasesCreate a release PR/commit to thedevelopbranch, updatingkiwipy/version.pyandCHANGELOG.md.Fast-forward mergedevelopinto themasterbranchCreate a release on GitHub (https://github.com/aiidateam/kiwipy/releases/new), pointing to the release commit onmaster, namedv.X.Y.Z(identical to version inkiwipy/version.py)This will trigger thecontinuous-deploymentGitHub workflow which, if all tests pass, will publish the package to PyPi. Check this has successfully completed in the GitHub Actions tab (https://github.com/aiidateam/kiwipy/actions).(if the release fails, delete the release and tag)