Robust, high-volume, message based communication made easy.
Project description
kiwiPy
kiwiPy is 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 by AiiDA for 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:
RPC
Broadcast (with filters)
Task queue messages
Let’s dive in, with some examples taken from the rmq tutorial. To see more detail head over to the documentation.
RPC
The client:
import kiwipy
with kiwipy.connect('amqp://localhost') as comm:
# Send an RPC message
print(" [x] Requesting fib(30)")
response = comm.rpc_send('fib', 30).result()
print((" [.] Got %r" % response))
The server:
import threading
import kiwipy
def fib(comm, num):
if num == 0:
return 0
if num == 1:
return 1
return fib(comm, num - 1) + fib(comm, num - 2)
with kiwipy.connect('amqp://127.0.0.1') as comm:
# Register an RPC subscriber with the name 'fib'
comm.add_rpc_subscriber(fib, 'fib')
# Now wait indefinitely for fibonacci calls
threading.Event().wait()
Worker
Create a new task:
import sys
import kiwipy
message = ' '.join(sys.argv[1:]) or "Hello World!"
with rmq.connect('amqp://localhost') as comm:
comm.task_send(message)
And the worker:
import time
import threading
import kiwipy
print(' [*] Waiting for messages. To exit press CTRL+C')
def callback(_comm, task):
print((" [x] Received %r" % task))
time.sleep(task.count(b'.'))
print(" [x] Done")
try:
with kiwipy.connect('amqp://localhost') as comm:
comm.add_task_subscriber(callback)
threading.Event().wait()
except KeyboardInterrupt:
pass
Citing
If you use kiwiPy directly or indirectly (e.g. by using AiiDA) 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.02351
This helps us to keep making community software.
Versioning
This software follows Semantic Versioning
Contributing
Want a new feature? Found a bug? Want to contribute more documentation or a translation perhaps?
Help is always welcome, get started with the contributing guide.
Development
This package utilises tox for unit test automation, and pre-commit for code style formatting and test automation.
To install these development dependencies:
pip install tox pre-commit
To run the unit tests:
tox
For the rmq tests you will require a running instance of RabbitMQ. One way to achieve this is using Docker and launching test/rmq/docker-compose.yml.
To run the pre-commit tests:
pre-commit run --all
To build the documentation:
tox -e docs-clean
Changes should be submitted as Pull Requests (PRs) to the develop branch.
Publishing Releases
Create a release PR/commit to the develop branch, updating kiwipy/version.py and CHANGELOG.md.
Fast-forward merge develop into the master branch
Create a release on GitHub (https://github.com/aiidateam/kiwipy/releases/new), pointing to the release commit on master, named v.X.Y.Z (identical to version in kiwipy/version.py)
This will trigger the continuous-deployment GitHub 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kiwipy-0.8.4.tar.gz
.
File metadata
- Download URL: kiwipy-0.8.4.tar.gz
- Upload date:
- Size: 40.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 625830fa07faac2c2a307bd3aa1caedac6596f37f9b9aba31b7f84c3d9c9f57a |
|
MD5 | f499a508a53f922461c09cdfd26a1e0a |
|
BLAKE2b-256 | 0eae3831e1562f1273195e686796690cba656e8937f414d2efcf47466ebfd949 |
File details
Details for the file kiwipy-0.8.4-py3-none-any.whl
.
File metadata
- Download URL: kiwipy-0.8.4-py3-none-any.whl
- Upload date:
- Size: 41.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2b260f1595689a0d835f1e2bf5373714001203d17c4d94e56ec299e793da495 |
|
MD5 | 61b68ac8c17b602dbc128d6fb0297021 |
|
BLAKE2b-256 | f7fead668377767dcc44d94258ac3ccbedbd55645cba893da842ed820c4ed937 |