Skip to content

Commit ee232d0

Browse files
author
DvirDukhan
committed
fixed PR comments
1 parent fc20b9b commit ee232d0

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

docs/commands.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ A `TIMEOUT t` argument can be specified to cause a request to be removed from th
583583

584584
```
585585
AI.SCRIPTEXECUTE <key> <function>
586-
KEYS n <key> [keys...]
587-
[INPUTS m <input> [input ...]
586+
[KEYS n <key> [keys...]]
587+
[INPUTS m <input> [input ...]]
588588
[ARGS k <arg> [arg...]]
589589
[OUTPUTS k <output> [output ...] [TIMEOUT t]]+
590590
```
@@ -593,13 +593,16 @@ _Arguments_
593593

594594
* **key**: the script's key name
595595
* **function**: the name of the function to run
596-
* **KEYS**: Either a squence of key names that the script will access before, during and after its execution, or a tag which all those keys share. `KEYS` is a mandatory scope in this command. Redis will verify that all potional key accesses are done to the right shard.
596+
* **KEYS**: Either a squence of key names that the script will access before, during and after its execution, or a tag which all those keys share.
597597
* **INPUTS**: Denotes the beginning of the input parameters list, followed by its length and one or more input tensors.
598598
* **ARGS**: A list additional arguments that a user can send to the script. All args are sent as strings, but can be casted to other types supported by torch script, such as `int`, or `float`.
599599

600600
* **OUTPUTS**: denotes the beginning of the output tensors keys' list, followed by its length and one or more key names.
601601
* **TIMEOUT**: the time (in ms) after which the client is unblocked and a `TIMEDOUT` string is returned
602602

603+
Note:
604+
Either `KEYS` or `INPUTS` scopes should be provided this command (one or both scopes are acceptable). Those scopes indicate keyspace access and such, the right shard to execute the command at. Redis will verify that all potional key accesses are done to the right shard.
605+
603606
_Return_
604607

605608
A simple 'OK' string, a simple `TIMEDOUT` string, or an error.
@@ -832,7 +835,7 @@ A `TIMEOUT t` argument can be specified to cause a request to be removed from th
832835
```
833836
AI.DAGEXECUTE [[LOAD <n> <key-1> <key-2> ... <key-n>] |
834837
[PERSIST <n> <key-1> <key-2> ... <key-n>] |
835-
[ROUTING <routing_tag>]]+
838+
[ROUTING <routing_tag>]]
836839
[TIMEOUT t]
837840
|> <command> [|> command ...]
838841
```

tests/flow/test_data/redis_scripts.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ def test_redis_error(tensors: List[Tensor], keys: List[str], args: List[str]):
2626
key = keys[0]
2727
redis.execute("SET", key)
2828

29+
def test_redis_command_error(tensors: List[Tensor], keys: List[str], args: List[str]):
30+
key = keys[0]
31+
redis.execute("SET", key) # missing the required value argument
32+
33+
def test_redis_error_message(tensors: List[Tensor], keys: List[str], args: List[str]):
34+
key = keys[0]
35+
redis.execute("HSET", key, "field", "value")
36+
redis.execute("RPUSH", key, "some_value") # list command on a hash type
37+
2938
def test_int_set_get(tensors: List[Tensor], keys: List[str], args: List[str]):
3039
key = keys[0]
3140
value = args[0]

tests/flow/test_torchscript_extensions.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@ def __init__(self):
2121
self.con = self.env.getConnection()
2222
script = load_file_content('redis_scripts.py')
2323
ret = self.con.execute_command(
24-
'AI.SCRIPTSTORE', 'redis_scripts{1}', DEVICE, 'ENTRY_POINTS', 11, 'test_redis_error', 'test_set_key', 'test_int_set_get', 'test_int_set_incr', 'test_float_set_get', 'test_int_list', 'test_str_list', 'test_hash', 'test_model_execute', 'test_model_execute_onnx', 'test_model_execute_onnx_bad_input', 'SOURCE', script)
24+
'AI.SCRIPTSTORE', 'redis_scripts{1}', DEVICE, 'ENTRY_POINTS', 13,
25+
'test_redis_error',
26+
'test_set_key',
27+
'test_int_set_get',
28+
'test_int_set_incr',
29+
'test_float_set_get',
30+
'test_int_list',
31+
'test_str_list',
32+
'test_hash',
33+
'test_model_execute',
34+
'test_model_execute_onnx',
35+
'test_model_execute_onnx_bad_input',
36+
'test_redis_command_error',
37+
'test_redis_error_message',
38+
'SOURCE', script)
2539
self.env.assertEqual(ret, b'OK')
2640
model_tf = load_file_content('graph.pb')
2741
ret = self.con.execute_command('AI.MODELSTORE', 'model_tf{1}', 'TF', DEVICE, 'INPUTS', 2, 'a', 'b', 'OUTPUTS', 1,
@@ -36,12 +50,12 @@ def __init__(self):
3650
ensureSlaveSynced(self.con, self.env)
3751

3852
def test_redis_error(self):
39-
try:
40-
self.con.execute_command(
41-
'AI.SCRIPTEXECUTE', 'redis_scripts', 'test_redis_error', 'KEYS', 1, "x{1}")
42-
self.env.assertTrue(False)
43-
except:
44-
pass
53+
check_error_message(self.env, self.con, "Redis command returned an error: Invalid argument",
54+
'AI.SCRIPTEXECUTE', 'redis_scripts{1}', 'test_redis_command_error', 'KEYS', 1, "x{1}", error_msg_is_substr=True)
55+
check_error_message(self.env, self.con, "Redis command returned an error: "
56+
"WRONGTYPE Operation against a key holding the wrong kind of value",
57+
'AI.SCRIPTEXECUTE', 'redis_scripts{1}', 'test_redis_error_message', 'KEYS', 1, "hash{1}", error_msg_is_substr=True)
58+
4559

4660
def test_simple_test_set(self):
4761
self.con.execute_command(

tests/flow/tests_dag_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,4 @@ def test_dag_crossslot_violation_errors(env):
235235
'INPUTS', 1, 'transactionTensor:{1}',
236236
'OUTPUTS', 1, 'resultTensor:{1}',
237237
)
238-
check_error_message(env, con, "ROUTING value specified in the command hash to slot which does not belong to the current shard", *command)
238+
check_error_message(env, con, "CROSSSLOT Keys in request don't hash to the same slot", *command)

0 commit comments

Comments
 (0)