{ "info": { "author": "RedisLabs", "author_email": "oss@redislabs.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Database", "Topic :: Software Development :: Testing" ], "description": "[![license](https://img.shields.io/github/license/RedisAI/redisai-py.svg)](https://github.com/RedisAI/redisai-py)\n[![PyPI version](https://badge.fury.io/py/redisai.svg)](https://badge.fury.io/py/redisai)\n[![CircleCI](https://circleci.com/gh/RedisAI/redisai-py/tree/master.svg?style=svg)](https://circleci.com/gh/RedisAI/redisai-py/tree/master)\n[![GitHub issues](https://img.shields.io/github/release/RedisAI/redisai-py.svg)](https://github.com/RedisAI/redisai-py/releases/latest)\n[![Codecov](https://codecov.io/gh/RedisAI/redisai-py/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisAI/redisai-py)\n\n\n# RedisAI Python Client\n\n\n## Installation\n\n1. Install Redis 5.0 or above\n\n2. [Install RedisAI](http://redisai.io)\n\n3. Install the python client\n\n```sh\n$ pip install redisai\n```\n\n4. Install serialization-deserialization utility (optional)\n```sh\n$ pip install ml2rt\n```\n\n[RedisAI example repo](https://github.com/RedisAI/redisai-examples) shows few examples made using redisai-py under `python_client` section. Checkout [ml2rt](https://github.com/hhsecond/ml2rt) for convenient functions those might help in converting models (sparkml, sklearn, xgboost to ONNX), serializing models to disk, loading it back to redisai-py etc.\n\nFor a quick walk through, checkout this example\n\n```python\n\n\nprint(client.tensorget('mul'))\n\n# Try with a script\nscript = ml2rt.load_script('test/testdata/script.txt')\nclient.scriptset('ket', Device.cpu, script)\nclient.scriptrun('ket', 'bar', input=['a', 'b'], output='c')\n```\n\n## Documentation\nAPIs available in redisai-py\n\n### tensorset\nSet the values of the tensor on the server using the provided tensor object\n\n##### Parameters\n- name: Key on which tensor is saved\n- tensor: a `Tensor` object\n- shape: Shape of the tensor\n- dtype: redisai.DType object represents data type of the tensor. Required if input is a `list`/`tuple`\n\n##### Example\n```python\nfrom redisai import Client, DType\nclient = Client()\narr = np.array([2, 3])\nclient.tensorset('x', arr)\nclient.tensorget('y', [1, 2], dtype=DType.float)\nclient.tensorget('z', [3, 4, 5, 6], dtype=DType.float, shape=(1, 2, 2))\n```\n\n### tensorget\n\n##### Parameters\nRetrieve the value of a tensor from the server. By default it returns the numpy array\nbut it can be controlled using `as_type` and `meta_only` arguments\n- name: Key from where the tensor is saved\n- as_type: the resultant tensor type. Returns numpy array if None\n- meta_only: if true, then the value is not retrieved, only the shape and the type\n\n##### Example\n```python\nfrom redisai import Tensor\nx = client.tensorget('x') # numpy array\ny = client.tensorget('y', as_type=Tensor) # A Tensor object\nz = client.tensorget('z', meta_only=True) # A Tensor object but without value\n```\n\n### loadbackend\nRedisAI by default won't load any backends. User can either explicitly\nload the backend by using this function or let RedisAI load the required\nbackend from the default path on-demand.\n\n##### Parameters\n- identifier: String representing which backend. Allowed values - TF, TORCH & ONNX\n- path: Path to the shared object of the backend\n\n##### Example\n```python\nclient.loadbackend('TORCH', 'install-cpu/backends/redisai_torch/redisai_torch.so')\n```\n\n\n### modelset\nStore a model of Tensorflow/PyTorch/ONNX format in RedisAI\n\n##### Parameters\n- name: Key on which model should be saved\n- backend: redisai.Backend object - tf, torch or onnx\n- device: redisai.Device object - cpu or gpu\n- data: model as a byte string. `ml2rt.load_model(path)` returns this. \n\n##### Example\nTensorflow requires the input and output nodes of the graph while storing the model. For\nexporting a normal tensorflow session to pb file, you could use `ml2rt` package\n```python\nimport ml2rt\nml2rt.save_tensorflow(sess, 'path/to/graph.pb', output_nodes)\nmodel = ml2rt.load_model('path/to/graph.pb')\nclient.modelset('m', Backend.tf,\n Device.cpu,\n input=['input_1', 'input_2'],\n output='output',\n data=model)\n```\nTorch doesn't need input and output node information. You could use ml2rt for exporting torch\nmodel as well but ml2rt needs torchscript model rather than normal torch model. Checkout\nthe [document](https://pytorch.org/docs/stable/jit.html) to learn more. \n```python\nimport ml2rt\nml2rt.save_torch('optimized_graph', 'path/to/graph.pt')\nmodel = ml2rt.load_model('path/to/graph.pt')\nclient.modelset('m', Backend.torch, Device.cpu, data=model)\n```\n\n### modelget\nFetch the stored model from RedisAI\n\n##### Parameters\nname: the name of the model\n\n##### Example\n```python\nmod_det = client.modelget('m')\nprint(mod_det['backend'], mod_det['device'])\nmodel_binary = mod_det['data']\n```\n\n### modeldel\nDelete a stored model from RedisAI\n\n##### Parameters\n- name: Key of the model\n\n##### Example\n```python\nclient.modeldel('m')\n```\n\n\n### modelrun\nExecute a model. Required inputs must be present in RedisAI before calling `modelrun`\n\n##### Parameters\n- name: Key of the model\n- inputs: Key of the input tensors. It can be a single key or a list of keys\n- outputs: Key on which the output tensors will be saved. It can be a single key or list of keys\n\n##### Example\n```python\nclient.tensorset('a', [2, 3], dtype=DType.float, shape=(2,))\nclient.tensorset('b', [12, 10], dtype=DType.float)\nmodel = ml2rt.load_model('test/testdata/graph.pt')\nclient.modelset('m', Backend.torch,\n Device.cpu,\n input=['input_1', 'input_2'],\n output='output',\n data=model)\nclient.modelrun('m', ['a', 'b'], ['mul'])\nout = client.tensorget('mul')\n```\n\n### scriptset\nStore a SCRIPT in RedisAI. SCRIPT is a subset of python language itself but will be executed\non high performance C++ runtime. RedisAI uses TORCH runtime to execute SCRIPT and it must\nfollow the format required by the [doc](https://pytorch.org/docs/stable/jit.html).\n\n##### Parameters\n- name: Key on which SCRIPT should be saved\n- device: redisai.Device object - cpu or gpu\n- script: SCRIPT as defined in [TorchScript documentation](https://pytorch.org/docs/stable/jit.html). SCRIPT must have functions defined in it (you can have multiple functions).\n\n##### Example\n```python\nscript = \"\"\"\ndef myfunc(a, b):\n return a + b\n\"\"\"\nclient.scriptset('script', Device.cpu, script)\n```\n\n\n### scriptget\nFetch a stored SCRIPT from RedisAI\n\n##### Parameters\n- name: Key from which SCRIPT can be retrieved\n\n##### Example\n```python\nscript_details = client.scriptget('script')\ndevice = script_details['device']\nscript = script_details['script']\n```\n\n\n### scriptdel\nDelete a stored SCRIPT from RedisAI\n\n##### Parameters\n- name: Key from which SCRIPT can be retrieved\n\n##### Example\n```python\nclient.scriptdel('script')\n```\n\n\n### scriptrun\nExecute a SCRIPT. Required inputs must be present in RedisAI before calling `modelrun`\n\n##### Parameters\n- name: Key from which SCRIPT can be retrieved\n- function: name of the function to call. The function that you call can call other functions in the same SCRIPT\n- inputs: Key of the input tensors. It can be a single key or a list of keys\n- outputs: Key on which the output tensors will be saved. It can be a single key or list of keys\n\n##### Example\n```python\nscript = \"\"\"\ndef myfunc(a, b):\n return a + b\n\"\"\"\nclient.scriptset('script', Device.cpu, script)\nclient.tensorget('a', [1, 2], dtype=DType.float)\nclient.tensorget('b', [3, 4], dtype=DType.float)\nclient.scriptrun('script', 'mufunc', ['a', 'b'], 'out')\nout = client.tensorget('out') # => [4, 6]\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/RedisAI/redisai-py", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "redisai", "package_url": "https://pypi.org/project/redisai/", "platform": "", "project_url": "https://pypi.org/project/redisai/", "project_urls": { "Homepage": "http://github.com/RedisAI/redisai-py" }, "release_url": "https://pypi.org/project/redisai/0.4.0/", "requires_dist": null, "requires_python": "", "summary": "RedisAI Python Client", "version": "0.4.0" }, "last_serial": 5742044, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3f13988a478b415a0ed46e9832664fd8", "sha256": "4e01939e47be64a35266fa44fc46493f354b1bbc3d71ed91f288da7ab6df8db0" }, "downloads": -1, "filename": "redisai-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3f13988a478b415a0ed46e9832664fd8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3670, "upload_time": "2019-03-31T12:07:14", "url": "https://files.pythonhosted.org/packages/36/57/c2d98aca054c270cfc6489b0c789f65093e416a3050e0c47a9d31f74985f/redisai-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5ce91f5ed0589d78f06c71c393811cdc", "sha256": "321e8422f479ca830d09a0174447a13d59c2df205961b31ff63a7429fa892837" }, "downloads": -1, "filename": "redisai-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5ce91f5ed0589d78f06c71c393811cdc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4663, "upload_time": "2019-04-02T16:24:26", "url": "https://files.pythonhosted.org/packages/9d/3f/40d2466fc9f507521247bf7dc7727d17372818d28ab18fb672d6cead2be1/redisai-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "086db5b619217c71941b6a819ed23349", "sha256": "7eda0ddbc8229eb62d774f42418bc20f1fee9026c1ed4d3e905e211b0f672298" }, "downloads": -1, "filename": "redisai-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "086db5b619217c71941b6a819ed23349", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6990, "upload_time": "2019-05-13T06:19:49", "url": "https://files.pythonhosted.org/packages/cd/54/b58264b1871e24e7f35f4230e9e37de47954bf24c7820d47922147626542/redisai-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fab7e7db3dbeb2d363e7590867c6ad4a", "sha256": "4425ac93e5ab1ccbc4c7f2e70cc9dc1a1a1bad6f1c0f646040929a4c7643ed13" }, "downloads": -1, "filename": "redisai-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fab7e7db3dbeb2d363e7590867c6ad4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6676, "upload_time": "2019-05-13T06:19:50", "url": "https://files.pythonhosted.org/packages/06/95/dab839c71335bae3cf25dbd70917fbbfbdac96b53dc28e3d180b70c1711b/redisai-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "fbaa939962eeabcfc263c329426e7a57", "sha256": "7494037bb9c24bdc0d4c0670c7f725e6b44a0cf945ebe7cd60e72f1afad99d66" }, "downloads": -1, "filename": "redisai-0.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "fbaa939962eeabcfc263c329426e7a57", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 5632, "upload_time": "2019-07-22T10:40:40", "url": "https://files.pythonhosted.org/packages/f5/44/bea582ae6618a70c2f5842d36e5242e4695ff90de81a9ea501cd32e48274/redisai-0.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "69f30ea6b461562b48607cbf919d046a", "sha256": "f3e0dbfa5da5ca457a6ca0d444fcdba9c3bdbb852120a483f05ff699fede4d36" }, "downloads": -1, "filename": "redisai-0.3.0.tar.gz", "has_sig": false, "md5_digest": "69f30ea6b461562b48607cbf919d046a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5568, "upload_time": "2019-07-22T10:40:42", "url": "https://files.pythonhosted.org/packages/4d/75/8e71be9bec8494c839d998ff0472ce927075967260a0d60fc930190d3875/redisai-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "2a7cbb01ed9e6ada40559b47d4c3e008", "sha256": "4974661576c68af33472279d0b35c60bc59f6060a9f347899f659b25271b18a0" }, "downloads": -1, "filename": "redisai-0.4.0.tar.gz", "has_sig": false, "md5_digest": "2a7cbb01ed9e6ada40559b47d4c3e008", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9556, "upload_time": "2019-08-28T11:49:13", "url": "https://files.pythonhosted.org/packages/97/42/a168b8c36c5b4f7f28df5daa2178f66b9a9abbb061e23eb7868393224a1a/redisai-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2a7cbb01ed9e6ada40559b47d4c3e008", "sha256": "4974661576c68af33472279d0b35c60bc59f6060a9f347899f659b25271b18a0" }, "downloads": -1, "filename": "redisai-0.4.0.tar.gz", "has_sig": false, "md5_digest": "2a7cbb01ed9e6ada40559b47d4c3e008", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9556, "upload_time": "2019-08-28T11:49:13", "url": "https://files.pythonhosted.org/packages/97/42/a168b8c36c5b4f7f28df5daa2178f66b9a9abbb061e23eb7868393224a1a/redisai-0.4.0.tar.gz" } ] }