Skip to content

Commit 215ae7f

Browse files
committed
black formatting
1 parent 3da8c99 commit 215ae7f

File tree

10 files changed

+586
-416
lines changed

10 files changed

+586
-416
lines changed

docs/conf.py

+22-20
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
project = 'redisai-py'
2-
copyright = '2020, RedisLabs'
3-
author = 'RedisLabs'
4-
release = '1.0.1'
5-
extensions = ['sphinx.ext.autodoc',
6-
'sphinx.ext.autosummary',
7-
'sphinx.ext.extlinks',
8-
'sphinx.ext.napoleon',
9-
'sphinx.ext.todo',
10-
'sphinx.ext.intersphinx',
11-
"sphinx_rtd_theme"]
12-
templates_path = ['_templates']
13-
source_suffix = '.rst'
14-
master_doc = 'index'
15-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
16-
html_theme = 'sphinx_rtd_theme'
1+
project = "redisai-py"
2+
copyright = "2020, RedisLabs"
3+
author = "RedisLabs"
4+
release = "1.0.1"
5+
extensions = [
6+
"sphinx.ext.autodoc",
7+
"sphinx.ext.autosummary",
8+
"sphinx.ext.extlinks",
9+
"sphinx.ext.napoleon",
10+
"sphinx.ext.todo",
11+
"sphinx.ext.intersphinx",
12+
"sphinx_rtd_theme",
13+
]
14+
templates_path = ["_templates"]
15+
source_suffix = ".rst"
16+
master_doc = "index"
17+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
18+
html_theme = "sphinx_rtd_theme"
1719
html_use_smartypants = True
18-
html_last_updated_fmt = '%b %d, %Y'
20+
html_last_updated_fmt = "%b %d, %Y"
1921
html_split_index = False
2022
html_sidebars = {
21-
'**': ['searchbox.html', 'globaltoc.html', 'sourcelink.html'],
23+
"**": ["searchbox.html", "globaltoc.html", "sourcelink.html"],
2224
}
23-
html_short_title = '%s-%s' % (project, release)
25+
html_short_title = "%s-%s" % (project, release)
2426

2527
napoleon_use_ivar = True
2628
napoleon_use_rtype = True
@@ -29,4 +31,4 @@
2931

3032
add_module_names = False
3133
doctest_test_doctest_blocks = None
32-
autoclass_content = 'class'
34+
autoclass_content = "class"

redisai/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .client import Client
22

3-
__version__ = '1.0.1'
3+
__version__ = "1.0.1"

redisai/client.py

+77-46
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ class Client(StrictRedis):
3838
>>> from redisai import Client
3939
>>> con = Client(host='localhost', port=6379)
4040
"""
41-
REDISAI_COMMANDS_RESPONSE_CALLBACKS = {
42-
}
41+
42+
REDISAI_COMMANDS_RESPONSE_CALLBACKS = {}
4343

4444
def __init__(self, debug=False, enable_postprocess=True, *args, **kwargs):
4545
super().__init__(*args, **kwargs)
4646
if debug:
4747
self.execute_command = enable_debug(super().execute_command)
4848
self.enable_postprocess = enable_postprocess
4949

50-
def pipeline(self, transaction: bool = True, shard_hint: bool = None) -> 'Pipeline':
50+
def pipeline(self, transaction: bool = True, shard_hint: bool = None) -> "Pipeline":
5151
"""
5252
It follows the same pipeline implementation of native redis client but enables it
5353
to access redisai operation as well. This function is experimental in the
@@ -61,13 +61,17 @@ def pipeline(self, transaction: bool = True, shard_hint: bool = None) -> 'Pipeli
6161
>>> pipe.execute()
6262
[True, b'OK']
6363
"""
64-
return Pipeline(self.enable_postprocess,
65-
self.connection_pool,
66-
self.response_callbacks,
67-
transaction=True, shard_hint=None)
64+
return Pipeline(
65+
self.enable_postprocess,
66+
self.connection_pool,
67+
self.response_callbacks,
68+
transaction=True,
69+
shard_hint=None,
70+
)
6871

69-
def dag(self, load: Sequence = None, persist: Sequence = None,
70-
readonly: bool = False) -> 'Dag':
72+
def dag(
73+
self, load: Sequence = None, persist: Sequence = None, readonly: bool = False
74+
) -> "Dag":
7175
"""
7276
It returns a DAG object on which other DAG-allowed operations can be called. For
7377
more details about DAG in RedisAI, refer to the RedisAI documentation.
@@ -101,7 +105,9 @@ def dag(self, load: Sequence = None, persist: Sequence = None,
101105
>>> # You can even chain the operations
102106
>>> result = dag.tensorset(**akwargs).modelrun(**bkwargs).tensorget(**ckwargs).run()
103107
"""
104-
return Dag(load, persist, self.execute_command, readonly, self.enable_postprocess)
108+
return Dag(
109+
load, persist, self.execute_command, readonly, self.enable_postprocess
110+
)
105111

106112
def loadbackend(self, identifier: AnyStr, path: AnyStr) -> str:
107113
"""
@@ -130,16 +136,18 @@ def loadbackend(self, identifier: AnyStr, path: AnyStr) -> str:
130136
res = self.execute_command(*args)
131137
return res if not self.enable_postprocess else processor.loadbackend(res)
132138

133-
def modelset(self,
134-
key: AnyStr,
135-
backend: str,
136-
device: str,
137-
data: ByteString,
138-
batch: int = None,
139-
minbatch: int = None,
140-
tag: AnyStr = None,
141-
inputs: Union[AnyStr, List[AnyStr]] = None,
142-
outputs: Union[AnyStr, List[AnyStr]] = None) -> str:
139+
def modelset(
140+
self,
141+
key: AnyStr,
142+
backend: str,
143+
device: str,
144+
data: ByteString,
145+
batch: int = None,
146+
minbatch: int = None,
147+
tag: AnyStr = None,
148+
inputs: Union[AnyStr, List[AnyStr]] = None,
149+
outputs: Union[AnyStr, List[AnyStr]] = None,
150+
) -> str:
143151
"""
144152
Set the model on provided key.
145153
@@ -184,8 +192,9 @@ def modelset(self,
184192
... inputs=['a', 'b'], outputs=['mul'], tag='v1.0')
185193
'OK'
186194
"""
187-
args = builder.modelset(key, backend, device, data,
188-
batch, minbatch, tag, inputs, outputs)
195+
args = builder.modelset(
196+
key, backend, device, data, batch, minbatch, tag, inputs, outputs
197+
)
189198
res = self.execute_command(*args)
190199
return res if not self.enable_postprocess else processor.modelset(res)
191200

@@ -238,10 +247,12 @@ def modeldel(self, key: AnyStr) -> str:
238247
res = self.execute_command(*args)
239248
return res if not self.enable_postprocess else processor.modeldel(res)
240249

241-
def modelrun(self,
242-
key: AnyStr,
243-
inputs: Union[AnyStr, List[AnyStr]],
244-
outputs: Union[AnyStr, List[AnyStr]]) -> str:
250+
def modelrun(
251+
self,
252+
key: AnyStr,
253+
inputs: Union[AnyStr, List[AnyStr]],
254+
outputs: Union[AnyStr, List[AnyStr]],
255+
) -> str:
245256
"""
246257
Run the model using input(s) which are already in the scope and are associated
247258
to some keys. Modelrun also needs the output key name(s) to store the output
@@ -296,17 +307,22 @@ def modelscan(self) -> List[List[AnyStr]]:
296307
>>> con.modelscan()
297308
[['pt_model', ''], ['m', 'v1.2']]
298309
"""
299-
warnings.warn("Experimental: Model List API is experimental and might change "
300-
"in the future without any notice", UserWarning)
310+
warnings.warn(
311+
"Experimental: Model List API is experimental and might change "
312+
"in the future without any notice",
313+
UserWarning,
314+
)
301315
args = builder.modelscan()
302316
res = self.execute_command(*args)
303317
return res if not self.enable_postprocess else processor.modelscan(res)
304318

305-
def tensorset(self,
306-
key: AnyStr,
307-
tensor: Union[np.ndarray, list, tuple],
308-
shape: Sequence[int] = None,
309-
dtype: str = None) -> str:
319+
def tensorset(
320+
self,
321+
key: AnyStr,
322+
tensor: Union[np.ndarray, list, tuple],
323+
shape: Sequence[int] = None,
324+
dtype: str = None,
325+
) -> str:
310326
"""
311327
Set the tensor to a key in RedisAI
312328
@@ -338,9 +354,13 @@ def tensorset(self,
338354
res = self.execute_command(*args)
339355
return res if not self.enable_postprocess else processor.tensorset(res)
340356

341-
def tensorget(self,
342-
key: AnyStr, as_numpy: bool = True, as_numpy_mutable: bool = False,
343-
meta_only: bool = False) -> Union[dict, np.ndarray]:
357+
def tensorget(
358+
self,
359+
key: AnyStr,
360+
as_numpy: bool = True,
361+
as_numpy_mutable: bool = False,
362+
meta_only: bool = False,
363+
) -> Union[dict, np.ndarray]:
344364
"""
345365
Retrieve the value of a tensor from the server. By default it returns the numpy
346366
array but it can be controlled using the `as_type` and `meta_only` argument.
@@ -375,9 +395,15 @@ def tensorget(self,
375395
"""
376396
args = builder.tensorget(key, as_numpy, meta_only)
377397
res = self.execute_command(*args)
378-
return res if not self.enable_postprocess else processor.tensorget(res, as_numpy, as_numpy_mutable, meta_only)
398+
return (
399+
res
400+
if not self.enable_postprocess
401+
else processor.tensorget(res, as_numpy, as_numpy_mutable, meta_only)
402+
)
379403

380-
def scriptset(self, key: AnyStr, device: str, script: str, tag: AnyStr = None) -> str:
404+
def scriptset(
405+
self, key: AnyStr, device: str, script: str, tag: AnyStr = None
406+
) -> str:
381407
"""
382408
Set the script to RedisAI. Action similar to Modelset. RedisAI uses the TorchScript
383409
engine to execute the script. So the script should have only TorchScript supported
@@ -469,12 +495,13 @@ def scriptdel(self, key: AnyStr) -> str:
469495
res = self.execute_command(*args)
470496
return res if not self.enable_postprocess else processor.scriptdel(res)
471497

472-
def scriptrun(self,
473-
key: AnyStr,
474-
function: AnyStr,
475-
inputs: Union[AnyStr, Sequence[AnyStr]],
476-
outputs: Union[AnyStr, Sequence[AnyStr]]
477-
) -> str:
498+
def scriptrun(
499+
self,
500+
key: AnyStr,
501+
function: AnyStr,
502+
inputs: Union[AnyStr, Sequence[AnyStr]],
503+
outputs: Union[AnyStr, Sequence[AnyStr]],
504+
) -> str:
478505
"""
479506
Run an already set script. Similar to modelrun
480507
@@ -520,8 +547,11 @@ def scriptscan(self) -> List[List[AnyStr]]:
520547
>>> con.scriptscan()
521548
[['ket1', 'v1.0'], ['ket2', '']]
522549
"""
523-
warnings.warn("Experimental: Script List API is experimental and might change "
524-
"in the future without any notice", UserWarning)
550+
warnings.warn(
551+
"Experimental: Script List API is experimental and might change "
552+
"in the future without any notice",
553+
UserWarning,
554+
)
525555
args = builder.scriptscan()
526556
res = self.execute_command(*args)
527557
return res if not self.enable_postprocess else processor.scriptscan(res)
@@ -584,4 +614,5 @@ def enable_debug(f):
584614
def wrapper(*args):
585615
print(*args)
586616
return f(*args)
617+
587618
return wrapper

0 commit comments

Comments
 (0)