From 9bfa5830f3f63b9be626ea48a84329b05bf2a9ae Mon Sep 17 00:00:00 2001 From: Luca Antiga Date: Fri, 6 Dec 2019 10:49:05 +0100 Subject: [PATCH 1/5] Enable AOF --- ramp.yml | 1 + src/config.h | 2 -- src/redisai.c | 6 ------ 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/ramp.yml b/ramp.yml index c2cb588d2..53efb6381 100644 --- a/ramp.yml +++ b/ramp.yml @@ -14,6 +14,7 @@ capabilities: - eviction_expiry - failover_migrate - persistence_rdb + - persistence_aof - clustering exclude_commands: - ai.modelset diff --git a/src/config.h b/src/config.h index f814f10be..ded120d35 100644 --- a/src/config.h +++ b/src/config.h @@ -22,6 +22,4 @@ typedef enum { #define RAI_COPY_RUN_OUTPUT #define RAI_PRINT_BACKEND_ERRORS -// #define RAI_OVERRIDE_AOF_CHECK - #endif /* SRC_CONFIG_H_ */ diff --git a/src/redisai.c b/src/redisai.c index 21ea1b979..9ef9d25c0 100644 --- a/src/redisai.c +++ b/src/redisai.c @@ -1486,12 +1486,6 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) == REDISMODULE_ERR) return REDISMODULE_ERR; int flags = RedisModule_GetContextFlags(ctx); - if (flags & REDISMODULE_CTX_FLAGS_AOF) { - RedisModule_Log(ctx, "warning", "ERR: AOF currently unsupported\r\n"); -#ifndef RAI_OVERRIDE_AOF_CHECK - return REDISMODULE_ERR; -#endif - } RAI_BackendsPath = NULL; From e5b01246cb56ef3c991c9de8e22259c1a0601251 Mon Sep 17 00:00:00 2001 From: Luca Antiga Date: Fri, 6 Dec 2019 14:33:52 +0100 Subject: [PATCH 2/5] Enable AOF in tests via env conf --- opt/Makefile | 2 +- test/basic_tests.py | 195 +++++++++++++++++++++++++------------------- 2 files changed, 114 insertions(+), 83 deletions(-) diff --git a/opt/Makefile b/opt/Makefile index 6c2619eb3..5b04198ab 100755 --- a/opt/Makefile +++ b/opt/Makefile @@ -135,7 +135,7 @@ endif $(SHOW)set -e ;\ cd $(ROOT)/test ;\ python3 -m RLTest $(TEST_ARGS) --test basic_tests.py --module $(INSTALL_DIR)/redisai.so --use-slaves ;\ - python3 -m RLTest $(TEST_ARGS) --test double-panda.py --module $(INSTALL_DIR)/redisai.so + python3 -m RLTest $(TEST_ARGS) --test double-panda.py --module $(INSTALL_DIR)/redisai.so #---------------------------------------------------------------------------------------------- diff --git a/test/basic_tests.py b/test/basic_tests.py index 043eac66e..63172fdd5 100644 --- a/test/basic_tests.py +++ b/test/basic_tests.py @@ -25,6 +25,12 @@ ''' +test_config = { + 'useAof': True, + 'useSlaves': True +} + + def check_cuda(): return os.system('which nvcc') @@ -33,8 +39,8 @@ def run_test_multiproc(env, n_procs, fn, args=tuple()): procs = [] def tmpfn(): - e = env.getConnection() - fn(e, *args) + con = env.getConnection() + fn(con, *args) return 1 for _ in range(n_procs): @@ -56,7 +62,8 @@ def test_example_multiproc(env): def test_set_tensor(env): - con = env + env = Env(**test_config) + con = env.getConnection() con.execute_command('AI.TENSORSET', 'x', 'FLOAT', 2, 'VALUES', 2, 3) tensor = con.execute_command('AI.TENSORGET', 'x', 'VALUES') values = tensor[-1] @@ -67,44 +74,44 @@ def test_set_tensor(env): env.assertEqual(values, [2, 3]) try: - env.execute_command('AI.TENSORSET', 1) + con.execute_command('AI.TENSORSET', 1) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.TENSORSET', 'y', 'FLOAT') + con.execute_command('AI.TENSORSET', 'y', 'FLOAT') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.TENSORSET', 'y', 'FLOAT', '2') + con.execute_command('AI.TENSORSET', 'y', 'FLOAT', '2') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.TENSORSET', 'y', 'FLOAT', 2, 'VALUES') + con.execute_command('AI.TENSORSET', 'y', 'FLOAT', 2, 'VALUES') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.TENSORSET', 'y', 'FLOAT', 2, 'VALUES', 1) + con.execute_command('AI.TENSORSET', 'y', 'FLOAT', 2, 'VALUES', 1) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.TENSORSET', 'y', 'FLOAT', 2, 'VALUES', '1') + con.execute_command('AI.TENSORSET', 'y', 'FLOAT', 2, 'VALUES', '1') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) time.sleep(0.1) - for _ in con.reloadingIterator(): + for _ in env.reloadingIterator(): env.assertExists('x') @@ -112,26 +119,30 @@ def test_del_tf_model(env): if not TEST_PT: return + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') model_filename = os.path.join(test_data_path, 'graph.pb') with open(model_filename, 'rb') as f: model_pb = f.read() - con = env - ret = con.execute_command('AI.MODELSET', 'm', 'TF', 'CPU', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', model_pb) - con.assertEqual(ret, b'OK') + env.assertEqual(ret, b'OK') con.execute_command('AI.MODELDEL', 'm') - con.assertFalse(con.execute_command('EXISTS', 'm')) + env.assertFalse(env.execute_command('EXISTS', 'm')) def test_run_tf_model(env): if not TEST_PT: return + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') model_filename = os.path.join(test_data_path, 'graph.pb') wrong_model_filename = os.path.join(test_data_path, 'pt-minimal.pt') @@ -142,11 +153,9 @@ def test_run_tf_model(env): with open(wrong_model_filename, 'rb') as f: wrong_model_pb = f.read() - con = env - ret = con.execute_command('AI.MODELSET', 'm', 'TF', 'CPU', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', model_pb) - con.assertEqual(ret, b'OK') + env.assertEqual(ret, b'OK') try: ret = con.execute_command('AI.MODELSET', 'm', 'TF', 'CPU', @@ -156,82 +165,82 @@ def test_run_tf_model(env): env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_1', 'TF', + con.execute_command('AI.MODELSET', 'm_1', 'TF', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_2', 'PORCH', 'CPU', + con.execute_command('AI.MODELSET', 'm_2', 'PORCH', 'CPU', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_3', 'TORCH', 'CPU', + con.execute_command('AI.MODELSET', 'm_3', 'TORCH', 'CPU', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_4', 'TF', + con.execute_command('AI.MODELSET', 'm_4', 'TF', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_5', 'TF', 'CPU', + con.execute_command('AI.MODELSET', 'm_5', 'TF', 'CPU', 'INPUTS', 'a', 'b', 'c', 'OUTPUTS', 'mul', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_6', 'TF', 'CPU', + con.execute_command('AI.MODELSET', 'm_6', 'TF', 'CPU', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mult', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_7', 'TF', 'CPU', model_pb) + con.execute_command('AI.MODELSET', 'm_7', 'TF', 'CPU', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_8', 'TF', 'CPU', + con.execute_command('AI.MODELSET', 'm_8', 'TF', 'CPU', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mul') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_8', 'TF', 'CPU', + con.execute_command('AI.MODELSET', 'm_8', 'TF', 'CPU', 'INPUTS', 'a_', 'b', 'OUTPUTS', 'mul') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_8', 'TF', 'CPU', + con.execute_command('AI.MODELSET', 'm_8', 'TF', 'CPU', 'INPUTS', 'a', 'b', 'OUTPUTS', 'mul_') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELRUN', 'm', 'INPUTS', 'a', 'b') + con.execute_command('AI.MODELRUN', 'm', 'INPUTS', 'a', 'b') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELRUN', 'm', 'OUTPUTS', 'c') + con.execute_command('AI.MODELRUN', 'm', 'OUTPUTS', 'c') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) @@ -243,15 +252,15 @@ def test_run_tf_model(env): tensor = con.execute_command('AI.TENSORGET', 'c', 'VALUES') values = tensor[-1] - con.assertEqual(values, [b'4', b'9', b'4', b'9']) + env.assertEqual(values, [b'4', b'9', b'4', b'9']) if env.useSlaves: con2 = env.getSlaveConnection() time.sleep(0.1) tensor2 = con2.execute_command('AI.TENSORGET', 'c', 'VALUES') - con.assertEqual(tensor2, tensor) + env.assertEqual(tensor2, tensor) - for _ in con.reloadingIterator(): + for _ in env.reloadingIterator(): env.assertExists('m') env.assertExists('a') env.assertExists('b') @@ -262,6 +271,9 @@ def test_run_torch_model(env): if not TEST_PT: return + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') model_filename = os.path.join(test_data_path, 'pt-minimal.pt') wrong_model_filename = os.path.join(test_data_path, 'graph.pb') @@ -272,10 +284,8 @@ def test_run_torch_model(env): with open(wrong_model_filename, 'rb') as f: wrong_model_pb = f.read() - con = env - ret = con.execute_command('AI.MODELSET', 'm', 'TORCH', 'CPU', model_pb) - con.assertEqual(ret, b'OK') + env.assertEqual(ret, b'OK') try: con.execute_command('AI.MODELSET', 'm', 'TORCH', 'CPU', wrong_model_pb) @@ -284,19 +294,19 @@ def test_run_torch_model(env): env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_1', 'TORCH', model_pb) + con.execute_command('AI.MODELSET', 'm_1', 'TORCH', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_2', model_pb) + con.execute_command('AI.MODELSET', 'm_2', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) - con.execute_command('AI.TENSORSET', 'a', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3) - con.execute_command('AI.TENSORSET', 'b', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3) + env.execute_command('AI.TENSORSET', 'a', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3) + env.execute_command('AI.TENSORSET', 'b', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3) try: con.execute_command('AI.MODELRUN', 'm_1', 'INPUTS', 'a', 'b', 'OUTPUTS') @@ -350,15 +360,15 @@ def test_run_torch_model(env): tensor = con.execute_command('AI.TENSORGET', 'c', 'VALUES') values = tensor[-1] - con.assertEqual(values, [b'4', b'6', b'4', b'6']) + env.assertEqual(values, [b'4', b'6', b'4', b'6']) if env.useSlaves: con2 = env.getSlaveConnection() time.sleep(0.1) tensor2 = con2.execute_command('AI.TENSORGET', 'c', 'VALUES') - con.assertEqual(tensor2, tensor) + env.assertEqual(tensor2, tensor) - for _ in con.reloadingIterator(): + for _ in env.reloadingIterator(): env.assertExists('m') env.assertExists('a') env.assertExists('b') @@ -369,6 +379,9 @@ def test_run_onnx_model(env): if not TEST_ONNX: return + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') model_filename = os.path.join(test_data_path, 'mnist.onnx') wrong_model_filename = os.path.join(test_data_path, 'graph.pb') @@ -383,10 +396,8 @@ def test_run_onnx_model(env): with open(sample_filename, 'rb') as f: sample_raw = f.read() - con = env - ret = con.execute_command('AI.MODELSET', 'm', 'ONNX', 'CPU', model_pb) - con.assertEqual(ret, b'OK') + env.assertEqual(ret, b'OK') try: con.execute_command('AI.MODELSET', 'm', 'ONNX', 'CPU', wrong_model_pb) @@ -395,13 +406,13 @@ def test_run_onnx_model(env): env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_1', 'ONNX', model_pb) + con.execute_command('AI.MODELSET', 'm_1', 'ONNX', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_2', model_pb) + con.execute_command('AI.MODELSET', 'm_2', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) @@ -468,9 +479,9 @@ def test_run_onnx_model(env): con2 = env.getSlaveConnection() time.sleep(0.1) tensor2 = con2.execute_command('AI.TENSORGET', 'b', 'VALUES') - con.assertEqual(tensor2, tensor) + env.assertEqual(tensor2, tensor) - for _ in con.reloadingIterator(): + for _ in env.reloadingIterator(): env.assertExists('m') env.assertExists('a') env.assertExists('b') @@ -480,6 +491,9 @@ def test_run_onnxml_model(env): if not TEST_ONNX: return + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') linear_model_filename = os.path.join(test_data_path, 'linear_iris.onnx') logreg_model_filename = os.path.join(test_data_path, 'logreg_iris.onnx') @@ -490,14 +504,11 @@ def test_run_onnxml_model(env): with open(logreg_model_filename, 'rb') as f: logreg_model = f.read() - con = env - ret = con.execute_command('AI.MODELSET', 'linear', 'ONNX', 'CPU', linear_model) - con.assertEqual(ret, b'OK') + env.assertEqual(ret, b'OK') - con = env ret = con.execute_command('AI.MODELSET', 'logreg', 'ONNX', 'CPU', logreg_model) - con.assertEqual(ret, b'OK') + env.assertEqual(ret, b'OK') con.execute_command('AI.TENSORSET', 'features', 'FLOAT', 1, 4, 'VALUES', 5.1, 3.5, 1.4, 0.2) @@ -518,7 +529,7 @@ def test_run_onnxml_model(env): env.assertEqual(linear_out, linear_out2) env.assertEqual(logreg_out, logreg_out2) - for _ in con.reloadingIterator(): + for _ in env.reloadingIterator(): env.assertExists('linear') env.assertExists('logreg') @@ -527,6 +538,9 @@ def test_run_tflite_model(env): if not TEST_TFLITE: return + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') model_filename = os.path.join(test_data_path, 'mnist_model_quant.tflite') wrong_model_filename = os.path.join(test_data_path, 'graph.pb') @@ -544,10 +558,8 @@ def test_run_tflite_model(env): with open(sample_filename, 'rb') as f: sample_raw = f.read() - con = env - ret = con.execute_command('AI.MODELSET', 'm', 'TFLITE', 'CPU', model_pb) - con.assertEqual(ret, b'OK') + env.assertEqual(ret, b'OK') # try: # con.execute_command('AI.MODELSET', 'm_1', 'TFLITE', 'CPU', wrong_model_pb) @@ -556,7 +568,7 @@ def test_run_tflite_model(env): # env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.MODELSET', 'm_1', 'TFLITE', model_pb) + con.execute_command('AI.MODELSET', 'm_1', 'TFLITE', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) @@ -564,7 +576,7 @@ def test_run_tflite_model(env): ret = con.execute_command('AI.MODELSET', 'm_2', 'TFLITE', 'CPU', model_pb2) try: - env.execute_command('AI.MODELSET', 'm_2', model_pb) + con.execute_command('AI.MODELSET', 'm_2', model_pb) except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) @@ -626,7 +638,7 @@ def test_run_tflite_model(env): env.assertEqual(value, 1) - for _ in con.reloadingIterator(): + for _ in env.reloadingIterator(): env.assertExists('m') env.assertExists('a') env.assertExists('b') @@ -635,9 +647,10 @@ def test_run_tflite_model(env): def test_set_tensor_multiproc(env): run_test_multiproc(env, 10, - lambda con: con.execute_command('AI.TENSORSET', 'x', 'FLOAT', 2, 'VALUES', 2, 3)) + lambda env: env.execute_command('AI.TENSORSET', 'x', 'FLOAT', 2, 'VALUES', 2, 3)) + + con = env.getConnection() - con = env tensor = con.execute_command('AI.TENSORGET', 'x', 'VALUES') values = tensor[-1] env.assertEqual(values, [b'2', b'3']) @@ -668,9 +681,11 @@ def test_run_mobilenet(env): if not TEST_TF: return + env = Env(**test_config) + con = env.getConnection() + input_var = 'input' output_var = 'MobilenetV2/Predictions/Reshape_1' - con = env model_pb, labels, img = load_mobilenet_test_data() @@ -704,18 +719,19 @@ def run_mobilenet(con, img, input_var, output_var): con.execute_command('AI.MODELRUN', 'mobilenet', 'INPUTS', 'input', 'OUTPUTS', 'output') - # con.execute_command('DEL', 'input') + # env.execute_command('DEL', 'input') def test_run_mobilenet_multiproc(env): if not TEST_TF: return + env = Env(**test_config) + con = env.getConnection() + input_var = 'input' output_var = 'MobilenetV2/Predictions/Reshape_1' - con = env - model_pb, labels, img = load_mobilenet_test_data() con.execute_command('AI.MODELSET', 'mobilenet', 'TF', 'CPU', 'INPUTS', input_var, 'OUTPUTS', output_var, model_pb) @@ -741,20 +757,23 @@ def test_run_mobilenet_multiproc(env): def test_set_incorrect_script(env): if not TEST_PT: return + + con = env.getConnection() + try: - env.execute_command('AI.SCRIPTSET', 'ket', 'CPU', 'return 1') + con.execute_command('AI.SCRIPTSET', 'ket', 'CPU', 'return 1') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.SCRIPTSET', 'nope') + con.execute_command('AI.SCRIPTSET', 'nope') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.SCRIPTSET', 'more', 'CPU') + con.execute_command('AI.SCRIPTSET', 'more', 'CPU') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) @@ -763,13 +782,17 @@ def test_set_incorrect_script(env): def test_set_correct_script(env): if not TEST_PT: return + + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') script_filename = os.path.join(test_data_path, 'script.txt') with open(script_filename, 'rb') as f: script = f.read() - env.execute_command('AI.SCRIPTSET', 'ket', 'CPU', script) + con.execute_command('AI.SCRIPTSET', 'ket', 'CPU', script) time.sleep(0.1) @@ -780,60 +803,68 @@ def test_set_correct_script(env): def test_del_script(env): if not TEST_PT: return + + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') script_filename = os.path.join(test_data_path, 'script.txt') with open(script_filename, 'rb') as f: script = f.read() - ret = env.execute_command('AI.SCRIPTSET', 'ket', 'CPU', script) + ret = con.execute_command('AI.SCRIPTSET', 'ket', 'CPU', script) env.assertEqual(ret, b'OK') - ret = env.execute_command('AI.SCRIPTDEL', 'ket') + ret = con.execute_command('AI.SCRIPTDEL', 'ket') env.assertFalse(env.execute_command('EXISTS', 'ket')) def test_run_script(env): if not TEST_PT: return + + env = Env(**test_config) + con = env.getConnection() + test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') script_filename = os.path.join(test_data_path, 'script.txt') with open(script_filename, 'rb') as f: script = f.read() - env.execute_command('AI.SCRIPTSET', 'ket', 'CPU', script) + con.execute_command('AI.SCRIPTSET', 'ket', 'CPU', script) - env.execute_command('AI.TENSORSET', 'a', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3) - env.execute_command('AI.TENSORSET', 'b', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3) + con.execute_command('AI.TENSORSET', 'a', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3) + con.execute_command('AI.TENSORSET', 'b', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3) try: - env.execute_command('AI.SCRIPTRUN', 'ket', 'bar', 'INPUTS', 'b', 'OUTPUTS', 'c') + con.execute_command('AI.SCRIPTRUN', 'ket', 'bar', 'INPUTS', 'b', 'OUTPUTS', 'c') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.SCRIPTRUN', 'ket', 'INPUTS', 'a', 'b', 'OUTPUTS', 'c') + con.execute_command('AI.SCRIPTRUN', 'ket', 'INPUTS', 'a', 'b', 'OUTPUTS', 'c') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.SCRIPTRUN', 'ket', 'bar', 'INPUTS', 'b', 'OUTPUTS') + con.execute_command('AI.SCRIPTRUN', 'ket', 'bar', 'INPUTS', 'b', 'OUTPUTS') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) try: - env.execute_command('AI.SCRIPTRUN', 'ket', 'bar', 'INPUTS', 'OUTPUTS') + con.execute_command('AI.SCRIPTRUN', 'ket', 'bar', 'INPUTS', 'OUTPUTS') except Exception as e: exception = e env.assertEqual(type(exception), redis.exceptions.ResponseError) - env.execute_command('AI.SCRIPTRUN', 'ket', 'bar', 'INPUTS', 'a', 'b', 'OUTPUTS', 'c') + con.execute_command('AI.SCRIPTRUN', 'ket', 'bar', 'INPUTS', 'a', 'b', 'OUTPUTS', 'c') - tensor = env.execute_command('AI.TENSORGET', 'c', 'VALUES') + tensor = con.execute_command('AI.TENSORGET', 'c', 'VALUES') values = tensor[-1] env.assertEqual(values, [b'4', b'6', b'4', b'6']) From ea4d61f0d837a1de07b0362e10b6cbb9c69edbf3 Mon Sep 17 00:00:00 2001 From: Luca Antiga Date: Mon, 9 Dec 2019 09:36:27 +0100 Subject: [PATCH 3/5] Fix use of Env in tests. Run test suite multiple times with different env configurations. --- opt/Makefile | 2 ++ test/basic_tests.py | 20 -------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/opt/Makefile b/opt/Makefile index 5b04198ab..260726a63 100755 --- a/opt/Makefile +++ b/opt/Makefile @@ -134,7 +134,9 @@ ifneq ($(NO_LFS),1) endif $(SHOW)set -e ;\ cd $(ROOT)/test ;\ + python3 -m RLTest $(TEST_ARGS) --test basic_tests.py --module $(INSTALL_DIR)/redisai.so ;\ python3 -m RLTest $(TEST_ARGS) --test basic_tests.py --module $(INSTALL_DIR)/redisai.so --use-slaves ;\ + python3 -m RLTest $(TEST_ARGS) --test basic_tests.py --module $(INSTALL_DIR)/redisai.so --use-aof ;\ python3 -m RLTest $(TEST_ARGS) --test double-panda.py --module $(INSTALL_DIR)/redisai.so #---------------------------------------------------------------------------------------------- diff --git a/test/basic_tests.py b/test/basic_tests.py index 63172fdd5..27b36053f 100644 --- a/test/basic_tests.py +++ b/test/basic_tests.py @@ -1,5 +1,3 @@ -from RLTest import Env - from multiprocessing import Pool, Process import redis @@ -25,12 +23,6 @@ ''' -test_config = { - 'useAof': True, - 'useSlaves': True -} - - def check_cuda(): return os.system('which nvcc') @@ -62,7 +54,6 @@ def test_example_multiproc(env): def test_set_tensor(env): - env = Env(**test_config) con = env.getConnection() con.execute_command('AI.TENSORSET', 'x', 'FLOAT', 2, 'VALUES', 2, 3) tensor = con.execute_command('AI.TENSORGET', 'x', 'VALUES') @@ -119,7 +110,6 @@ def test_del_tf_model(env): if not TEST_PT: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') @@ -140,7 +130,6 @@ def test_run_tf_model(env): if not TEST_PT: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') @@ -271,7 +260,6 @@ def test_run_torch_model(env): if not TEST_PT: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') @@ -379,7 +367,6 @@ def test_run_onnx_model(env): if not TEST_ONNX: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') @@ -491,7 +478,6 @@ def test_run_onnxml_model(env): if not TEST_ONNX: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') @@ -538,7 +524,6 @@ def test_run_tflite_model(env): if not TEST_TFLITE: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') @@ -681,7 +666,6 @@ def test_run_mobilenet(env): if not TEST_TF: return - env = Env(**test_config) con = env.getConnection() input_var = 'input' @@ -726,7 +710,6 @@ def test_run_mobilenet_multiproc(env): if not TEST_TF: return - env = Env(**test_config) con = env.getConnection() input_var = 'input' @@ -783,7 +766,6 @@ def test_set_correct_script(env): if not TEST_PT: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') @@ -804,7 +786,6 @@ def test_del_script(env): if not TEST_PT: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') @@ -824,7 +805,6 @@ def test_run_script(env): if not TEST_PT: return - env = Env(**test_config) con = env.getConnection() test_data_path = os.path.join(os.path.dirname(__file__), 'test_data') From 4e81bf2e3e935591c3911dc7ef55bd176cd74ee7 Mon Sep 17 00:00:00 2001 From: Luca Antiga Date: Mon, 9 Dec 2019 11:26:50 +0100 Subject: [PATCH 4/5] Comment out panda test --- opt/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opt/Makefile b/opt/Makefile index 260726a63..d11343ab5 100755 --- a/opt/Makefile +++ b/opt/Makefile @@ -136,8 +136,9 @@ endif cd $(ROOT)/test ;\ python3 -m RLTest $(TEST_ARGS) --test basic_tests.py --module $(INSTALL_DIR)/redisai.so ;\ python3 -m RLTest $(TEST_ARGS) --test basic_tests.py --module $(INSTALL_DIR)/redisai.so --use-slaves ;\ - python3 -m RLTest $(TEST_ARGS) --test basic_tests.py --module $(INSTALL_DIR)/redisai.so --use-aof ;\ - python3 -m RLTest $(TEST_ARGS) --test double-panda.py --module $(INSTALL_DIR)/redisai.so + python3 -m RLTest $(TEST_ARGS) --test basic_tests.py --module $(INSTALL_DIR)/redisai.so --use-aof + # Commented until the MacOS CI is available + # python3 -m RLTest $(TEST_ARGS) --test double-panda.py --module $(INSTALL_DIR)/redisai.so #---------------------------------------------------------------------------------------------- From 45fcd88cafba9f6d7794a4ce56a18bcc860752bb Mon Sep 17 00:00:00 2001 From: Luca Antiga Date: Mon, 9 Dec 2019 12:00:35 +0100 Subject: [PATCH 5/5] Update pack version and license in RAMP file --- ramp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ramp.yml b/ramp.yml index 53efb6381..7162c7c30 100644 --- a/ramp.yml +++ b/ramp.yml @@ -3,10 +3,10 @@ author: Orobix and RedisLabs email: luca.antiga@orobix.com description: Serving tensors and executing deep learning graphs homepage: https://oss.redislabs.com/redisai/ -license: GNU Affero General Public License v3.0 +license: Redis Source Available License v1.0 command_line_args: "" min_redis_version: "5.0.7" -min_redis_pack_version: "5.4" +min_redis_pack_version: "5.4.11" capabilities: - types - no_multi_key