Skip to content

Commit

Permalink
Python version restriction (#22)
Browse files Browse the repository at this point in the history
* version bump

* clean up

* python version support 3.2+
  • Loading branch information
Sherin Thomas authored and lantiga committed Sep 4, 2019
1 parent 216467a commit 94d0499
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
redisai.egg-info
.idea
.mypy_cache/
build/
dist/
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ $ pip install ml2rt

[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.

For a quick walk through, checkout this example

```python


print(client.tensorget('mul'))

# Try with a script
script = ml2rt.load_script('test/testdata/script.txt')
client.scriptset('ket', Device.cpu, script)
client.scriptrun('ket', 'bar', input=['a', 'b'], output='c')
```

## Documentation
APIs available in redisai-py
Expand Down
16 changes: 8 additions & 8 deletions redisai/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from redis import StrictRedis
from typing import Union, Any, AnyStr, ByteString, Collection, Type
from typing import Union, Any, AnyStr, ByteString, Sequence, Type

try:
import numpy as np
Expand Down Expand Up @@ -32,8 +32,8 @@ def modelset(self,
backend: Backend,
device: Device,
data: ByteString,
inputs: Union[AnyStr, Collection[AnyStr], None] = None,
outputs: Union[AnyStr, Collection[AnyStr], None] = None
inputs: Union[AnyStr, Sequence[AnyStr], None] = None,
outputs: Union[AnyStr, Sequence[AnyStr], None] = None
) -> AnyStr:
args = ['AI.MODELSET', name, backend.value, device.value]
if backend == Backend.tf:
Expand All @@ -58,8 +58,8 @@ def modeldel(self, name: AnyStr) -> AnyStr:

def modelrun(self,
name: AnyStr,
inputs: Union[AnyStr, Collection[AnyStr]],
outputs: Union[AnyStr, Collection[AnyStr]]
inputs: Union[AnyStr, Sequence[AnyStr]],
outputs: Union[AnyStr, Sequence[AnyStr]]
) -> AnyStr:
args = ['AI.MODELRUN', name]
args += ['INPUTS'] + str_or_strsequence(inputs)
Expand All @@ -69,7 +69,7 @@ def modelrun(self,
def tensorset(self,
key: AnyStr,
tensor: Union[Tensor, np.ndarray, list, tuple],
shape: Union[Collection[int], None] = None,
shape: Union[Sequence[int], None] = None,
dtype: Union[DType, None] = None) -> Any:
"""
Set the values of the tensor on the server using the provided Tensor object
Expand Down Expand Up @@ -140,8 +140,8 @@ def scriptdel(self, name):
def scriptrun(self,
name: AnyStr,
function: AnyStr,
inputs: Union[AnyStr, Collection[AnyStr]],
outputs: Union[AnyStr, Collection[AnyStr]]
inputs: Union[AnyStr, Sequence[AnyStr]],
outputs: Union[AnyStr, Sequence[AnyStr]]
) -> AnyStr:
args = ['AI.SCRIPTRUN', name, function, 'INPUTS']
args += str_or_strsequence(inputs)
Expand Down
8 changes: 4 additions & 4 deletions redisai/tensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, ByteString, Collection
from typing import Union, ByteString, Sequence
import warnings
from .utils import convert_to_num
from .constants import DType
Expand All @@ -13,7 +13,7 @@ class Tensor(object):

def __init__(self,
dtype: DType,
shape: Collection[int],
shape: Sequence[int],
value):
warnings.warn("Tensor APIs are depricated and "
"will be removed from the future release.", UserWarning)
Expand Down Expand Up @@ -44,7 +44,7 @@ def __repr__(self):
id=id(self))

@classmethod
def from_resp(cls, dtype: DType, shape: Collection[int], value) -> 'Tensor':
def from_resp(cls, dtype: DType, shape: Sequence[int], value) -> 'Tensor':
convert_to_num(dtype, value)
return cls(dtype, shape, value)

Expand All @@ -64,7 +64,7 @@ class BlobTensor(Tensor):

def __init__(self,
dtype: DType,
shape: Collection[int],
shape: Sequence[int],
*blobs: Union['BlobTensor', ByteString]
):
"""
Expand Down
2 changes: 1 addition & 1 deletion redisai/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module
__version__ = '0.4.0'
__version__ = '0.4.1'
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
#!/usr/bin/env python
from setuptools import setup, find_packages

exec(open('redisai/version.py', encoding='utf-8').read())
try:
exec(open('redisai/version.py', encoding='utf-8').read())
except TypeError:
exec(open('redisai/version.py').read())

with open('README.md') as f:
long_description = f.read()

Expand All @@ -18,6 +22,7 @@
author_email='oss@redislabs.com',
packages=find_packages(),
install_requires=['redis', 'hiredis', 'rmtest'],
python_requires='>=3.2',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down

0 comments on commit 94d0499

Please sign in to comment.