redisgears-py
redisgears-py copied to clipboard
RedisGears python client
redisgears-py
RedisGears python client (support python3 only!)
Example: Using the Python Client:
from gearsclient import GearsRemoteBuilder as GearsBuilder
from gearsclient import execute
import redis
conn = redis.Redis(host='localhost', port=6379)
# count for each genre how many times it appears
res = GearsBuilder('KeysOnlyReader', r=conn).\
map(lambda x:execute('hget', x, 'genres')).\
filter(lambda x:x != '\\N').\
flatmap(lambda x: x.split(',')).\
map(lambda x: x.strip()).\
countby().\
run()
for r in res[0]:
print('%-15s: %d' % (r['key'], r['value']))
Installing
pip install git+https://github.com/RedisGears/redisgears-py.git
Notice that the library also need to be installed in RedisGears virtual env.
Developing
- Create a virtualenv to manage your python dependencies, and ensure it's active.
virtualenv -v venv - Install pypoetry to manage your dependencies.
pip install poetry - Install dependencies.
poetry install
tox runs all tests as its default target. Running tox by itself will run unit tests. Ensure you have a running redis, with the module loaded.