How to install Python packages to RedisGears docker image

Dear all,

I am using the Docker image redislabs/redismod and trying to install additional Python packages, for example Numpy, from the Dockerfile such that it can be used within a Gears.

I have tried this by following the examples provided in EdgeRealtimeVideoAnalytics and AnimalRecognitionDemo. However, these use a different base image which does not seem to be supported anymore and I was not able to apply the same approach to the redismod image.

Any help is appreciated!

Thanks a lot!

Best regards,

manl

@manl

Have you tried the quickest way to try RedisGears is by launching its official Docker container image:

docker run -p 6379:6379 redislabs/redisgears:latest

A Redis Cluster with RedisGears variant is also available:

docker run -p 30001:30001 -p 30002:30002 -p 30003:30003 redislabs/rgcluster:latest

Reference: https://oss.redislabs.com/redisgears/quickstart.html

@manl you can install packages using the REQUIREMENTS option on the RG.PYEXECUTE command (https://oss.redislabs.com/redisgears/commands.html#rgpyexecute). So basically you can install numpy like this:

127.0.0.1:6379> RG.PYEXECUTE “GearsBuilder(reader=‘ShardsIDReader’).map(lambda x: str(import(‘numpy’))).run()” REQUIREMENTS “numpy”

    1. “<module ‘numpy’ from ‘/var/opt/redislabs/modules/rg/python3_99.99.99/lib/python3.7/site-packages/numpy/init.py’>”
  1. (empty array)
    (5.53s)

Thanks a lot, @meirsh! But does this mean that the respective host has to have a constant connection to the internet? We need to adress situations where a connection to the internet for downloading additional packages is not available. Hence, it would be good to know whether

  • one is able to specify a local file system providing already downloaded Python packages
  • or how packages can be defined in a Dockerfile?

Again, thanks for your support!

Best regards,

manl

@manl we currently do not support local file system but we do have a solution, what you need to do is to spin a docker image of RedisGears in an environment that has internet and use ‘Gears-cli
install-requirements’ (https://github.com/RedisGears/gears-cli) to install whatever requirements you need. Then you can use ‘Gears-cli export-requirements’ to export the requirements you installed, it will create a zip that can then be import (again using ‘Gears-cli import-requirements’) to the environment without an internet.
Let me know if you have any issue with that.

Thanks a lot @meirsh! It works like a charm!

Best regards and stay healthy,

Marc-André

1 Like