Skip to content

Commit 94d0499

Browse files
Sherin Thomaslantiga
Sherin Thomas
authored andcommitted
Python version restriction (#22)
* version bump * clean up * python version support 3.2+
1 parent 216467a commit 94d0499

File tree

6 files changed

+21
-26
lines changed

6 files changed

+21
-26
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
redisai.egg-info
66
.idea
77
.mypy_cache/
8+
build/
9+
dist/

README.md

-12
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ $ pip install ml2rt
2727

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

30-
For a quick walk through, checkout this example
31-
32-
```python
33-
34-
35-
print(client.tensorget('mul'))
36-
37-
# Try with a script
38-
script = ml2rt.load_script('test/testdata/script.txt')
39-
client.scriptset('ket', Device.cpu, script)
40-
client.scriptrun('ket', 'bar', input=['a', 'b'], output='c')
41-
```
4230

4331
## Documentation
4432
APIs available in redisai-py

redisai/client.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from redis import StrictRedis
2-
from typing import Union, Any, AnyStr, ByteString, Collection, Type
2+
from typing import Union, Any, AnyStr, ByteString, Sequence, Type
33

44
try:
55
import numpy as np
@@ -32,8 +32,8 @@ def modelset(self,
3232
backend: Backend,
3333
device: Device,
3434
data: ByteString,
35-
inputs: Union[AnyStr, Collection[AnyStr], None] = None,
36-
outputs: Union[AnyStr, Collection[AnyStr], None] = None
35+
inputs: Union[AnyStr, Sequence[AnyStr], None] = None,
36+
outputs: Union[AnyStr, Sequence[AnyStr], None] = None
3737
) -> AnyStr:
3838
args = ['AI.MODELSET', name, backend.value, device.value]
3939
if backend == Backend.tf:
@@ -58,8 +58,8 @@ def modeldel(self, name: AnyStr) -> AnyStr:
5858

5959
def modelrun(self,
6060
name: AnyStr,
61-
inputs: Union[AnyStr, Collection[AnyStr]],
62-
outputs: Union[AnyStr, Collection[AnyStr]]
61+
inputs: Union[AnyStr, Sequence[AnyStr]],
62+
outputs: Union[AnyStr, Sequence[AnyStr]]
6363
) -> AnyStr:
6464
args = ['AI.MODELRUN', name]
6565
args += ['INPUTS'] + str_or_strsequence(inputs)
@@ -69,7 +69,7 @@ def modelrun(self,
6969
def tensorset(self,
7070
key: AnyStr,
7171
tensor: Union[Tensor, np.ndarray, list, tuple],
72-
shape: Union[Collection[int], None] = None,
72+
shape: Union[Sequence[int], None] = None,
7373
dtype: Union[DType, None] = None) -> Any:
7474
"""
7575
Set the values of the tensor on the server using the provided Tensor object
@@ -140,8 +140,8 @@ def scriptdel(self, name):
140140
def scriptrun(self,
141141
name: AnyStr,
142142
function: AnyStr,
143-
inputs: Union[AnyStr, Collection[AnyStr]],
144-
outputs: Union[AnyStr, Collection[AnyStr]]
143+
inputs: Union[AnyStr, Sequence[AnyStr]],
144+
outputs: Union[AnyStr, Sequence[AnyStr]]
145145
) -> AnyStr:
146146
args = ['AI.SCRIPTRUN', name, function, 'INPUTS']
147147
args += str_or_strsequence(inputs)

redisai/tensor.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Union, ByteString, Collection
1+
from typing import Union, ByteString, Sequence
22
import warnings
33
from .utils import convert_to_num
44
from .constants import DType
@@ -13,7 +13,7 @@ class Tensor(object):
1313

1414
def __init__(self,
1515
dtype: DType,
16-
shape: Collection[int],
16+
shape: Sequence[int],
1717
value):
1818
warnings.warn("Tensor APIs are depricated and "
1919
"will be removed from the future release.", UserWarning)
@@ -44,7 +44,7 @@ def __repr__(self):
4444
id=id(self))
4545

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

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

6565
def __init__(self,
6666
dtype: DType,
67-
shape: Collection[int],
67+
shape: Sequence[int],
6868
*blobs: Union['BlobTensor', ByteString]
6969
):
7070
"""

redisai/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# 1) we don't load dependencies by storing it in __init__.py
33
# 2) we can import it in setup.py for the same reason
44
# 3) we can import it into your module module
5-
__version__ = '0.4.0'
5+
__version__ = '0.4.1'

setup.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
#!/usr/bin/env python
33
from setuptools import setup, find_packages
44

5-
exec(open('redisai/version.py', encoding='utf-8').read())
5+
try:
6+
exec(open('redisai/version.py', encoding='utf-8').read())
7+
except TypeError:
8+
exec(open('redisai/version.py').read())
9+
610
with open('README.md') as f:
711
long_description = f.read()
812

@@ -18,6 +22,7 @@
1822
author_email='[email protected]',
1923
packages=find_packages(),
2024
install_requires=['redis', 'hiredis', 'rmtest'],
25+
python_requires='>=3.2',
2126
classifiers=[
2227
'Development Status :: 4 - Beta',
2328
'Intended Audience :: Developers',

0 commit comments

Comments
 (0)