Skip to content

Commit 0cba685

Browse files
committed
sonarcube fix
1 parent 215ae7f commit 0cba685

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

redisai/command_builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def tensorset(
9191
)
9292
except AttributeError:
9393
raise TypeError(
94-
"tensorset() missing argument 'dtype' or " "value of 'dtype' is None"
94+
"tensorset() missing argument 'dtype' or value of 'dtype' is None"
9595
)
9696
if shape is None:
9797
shape = (len(tensor),)

test/test.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010

1111
DEBUG = False
12+
tf_graph = "graph.pb"
13+
torch_graph = "pt-minimal.pt"
1214

1315

1416
class Capturing(list):
@@ -114,7 +116,7 @@ def test_numpy_tensor(self):
114116
con.tensorset("trying", stringarr)
115117

116118
def test_modelset_errors(self):
117-
model_path = os.path.join(MODEL_DIR, "graph.pb")
119+
model_path = os.path.join(MODEL_DIR, tf_graph)
118120
model_pb = load_model(model_path)
119121
con = self.get_client()
120122
with self.assertRaises(ValueError):
@@ -139,7 +141,7 @@ def test_modelset_errors(self):
139141
)
140142

141143
def test_modelget_meta(self):
142-
model_path = os.path.join(MODEL_DIR, "graph.pb")
144+
model_path = os.path.join(MODEL_DIR, tf_graph)
143145
model_pb = load_model(model_path)
144146
con = self.get_client()
145147
con.modelset(
@@ -160,7 +162,7 @@ def test_modelget_meta(self):
160162
)
161163

162164
def test_modelrun_non_list_input_output(self):
163-
model_path = os.path.join(MODEL_DIR, "graph.pb")
165+
model_path = os.path.join(MODEL_DIR, tf_graph)
164166
model_pb = load_model(model_path)
165167
con = self.get_client()
166168
con.modelset(
@@ -173,7 +175,7 @@ def test_modelrun_non_list_input_output(self):
173175

174176
def test_nonasciichar(self):
175177
nonascii = "ĉ"
176-
model_path = os.path.join(MODEL_DIR, "graph.pb")
178+
model_path = os.path.join(MODEL_DIR, tf_graph)
177179
model_pb = load_model(model_path)
178180
con = self.get_client()
179181
con.modelset(
@@ -192,8 +194,8 @@ def test_nonasciichar(self):
192194
self.assertTrue((np.allclose(tensor, [4.0, 9.0])))
193195

194196
def test_run_tf_model(self):
195-
model_path = os.path.join(MODEL_DIR, "graph.pb")
196-
bad_model_path = os.path.join(MODEL_DIR, "pt-minimal.pt")
197+
model_path = os.path.join(MODEL_DIR, tf_graph)
198+
bad_model_path = os.path.join(MODEL_DIR, torch_graph)
197199

198200
model_pb = load_model(model_path)
199201
wrong_model_pb = load_model(bad_model_path)
@@ -295,7 +297,7 @@ def test_run_onnxdl_model(self):
295297
self.assertTrue(np.allclose(outtensor, [4.0]))
296298

297299
def test_run_pytorch_model(self):
298-
model_path = os.path.join(MODEL_DIR, "pt-minimal.pt")
300+
model_path = os.path.join(MODEL_DIR, torch_graph)
299301
ptmodel = load_model(model_path)
300302
con = self.get_client()
301303
con.modelset("pt_model", "torch", "cpu", ptmodel, tag="v1.0")
@@ -317,7 +319,7 @@ def test_run_tflite_model(self):
317319
self.assertTrue(np.allclose(output, [8]))
318320

319321
def test_info(self):
320-
model_path = os.path.join(MODEL_DIR, "graph.pb")
322+
model_path = os.path.join(MODEL_DIR, tf_graph)
321323
model_pb = load_model(model_path)
322324
con = self.get_client()
323325
con.modelset("m", "tf", "cpu", model_pb, inputs=["a", "b"], outputs=["mul"])
@@ -345,13 +347,13 @@ def test_info(self):
345347
self.assertEqual(first_info, third_info) # before modelrun and after reset
346348

347349
def test_model_scan(self):
348-
model_path = os.path.join(MODEL_DIR, "graph.pb")
350+
model_path = os.path.join(MODEL_DIR, tf_graph)
349351
model_pb = load_model(model_path)
350352
con = self.get_client()
351353
con.modelset(
352354
"m", "tf", "cpu", model_pb, inputs=["a", "b"], outputs=["mul"], tag="v1.2"
353355
)
354-
model_path = os.path.join(MODEL_DIR, "pt-minimal.pt")
356+
model_path = os.path.join(MODEL_DIR, torch_graph)
355357
ptmodel = load_model(model_path)
356358
con = self.get_client()
357359
# TODO: RedisAI modelscan issue
@@ -377,7 +379,7 @@ class DagTestCase(RedisAITestBase):
377379
def setUp(self):
378380
super().setUp()
379381
con = self.get_client()
380-
model_path = os.path.join(MODEL_DIR, "pt-minimal.pt")
382+
model_path = os.path.join(MODEL_DIR, torch_graph)
381383
ptmodel = load_model(model_path)
382384
con.modelset("pt_model", "torch", "cpu", ptmodel, tag="v7.0")
383385

0 commit comments

Comments
 (0)