-
Notifications
You must be signed in to change notification settings - Fork 106
Improve script API for RedisAI 1.2 #792
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #792 +/- ##
==========================================
+ Coverage 79.92% 79.95% +0.02%
==========================================
Files 52 53 +1
Lines 7767 8035 +268
==========================================
+ Hits 6208 6424 +216
- Misses 1559 1611 +52
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, much cleaner logic for executing scripts! I added many comments about missing tests (sorry...), and I saw that many tests were disabled (most of them in tests_deprecated_commands.py
), for a reason that I couldn't understand...
tests/flow/tests_pytorch.py
Outdated
if not TEST_PT: | ||
env.debugPrint("skipping {} since TEST_PT=0".format(sys._getframe().f_code.co_name), force=True) | ||
return | ||
|
||
con = env.getConnection() | ||
|
||
check_error(env, con, 'AI.SCRIPTSET', 'ket{1}', DEVICE, 'SOURCE', 'return 1') | ||
check_error(env, con, 'AI.SCRIPTSTORE', 'ket{1}', DEVICE, 'SOURCE', 'return 1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we check for the error message in these 4 tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added few more comments. Also, there are still some parsing errors in script execute that are not tested. I'm suppose to talk with Meir on Sunday about making the KEYS not mandatory, then we could close this PR...
One last thing - the aof issue. I see that we are still not covering aof rewrite which is very strange. I will take a look and fix it a new PR
docs/commands.md
Outdated
## AI.SCRIPTSET | ||
_This command is deprecated and will not be available in future versions. consider using AI.MODELSTORE command instead._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using AI.SCRIPTSTORE command instead._
src/backends/libtorch_c/torch_c.cpp
Outdated
return function->getSchema().arguments().size(); | ||
} | ||
|
||
extern "C" TorchScriptFunctionArgumentType torchScript_FunctionArgumentType(void* scriptCtx, size_t fn_index, size_t arg_index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this function still needed now that we have torchScript_FunctionArgumentTypeByFunctionName
?
src/backends/libtorch_c/torch_c.cpp
Outdated
@@ -687,8 +593,27 @@ extern "C" size_t torchScript_FunctionArgumentCount(void* scriptCtx, size_t fn_i | |||
return functions[fn_index]->getSchema().arguments().size(); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO we still need torchScript_FunctionArgumentCount
now that we have torchScript_FunctionArgumentCountByFunctionName
?
for (size_t i = 0; i < nEntryPoints; i++) { | ||
const char *entryPoint; | ||
if (AC_GetString(&ac, &entryPoint, NULL, 0) != AC_OK) { | ||
return RedisModule_ReplyWithError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test?
tests/flow/tests_commands.py
Outdated
check_error_message(env, con, "Already encountered KEYS scope in current command", | ||
"AI.DAGEXECUTE KEYS 1 a{1} |> AI.SCRIPTEXECUTE script{1} bar KEYS 1 a{1}") | ||
# # ERR KEYS section in an inner AI.SCRIPTEXEUTE command within a DAG is not allowed. | ||
# check_error_message(env, con, "Already encountered KEYS scope in current command", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... ok let's leave it open, I'll discuss it with Meir on Sunday
tests/flow/tests_commands.py
Outdated
"AI.DAGEXECUTE KEYS 1 a{1} |> AI.SCRIPTEXECUTE script{1} bar KEYS 1 a{1}") | ||
# # ERR KEYS section in an inner AI.SCRIPTEXEUTE command within a DAG is not allowed. | ||
# check_error_message(env, con, "Already encountered KEYS scope in current command", | ||
# "AI.DAGEXECUTE KEYS 1 a{1} |> AI.SCRIPTEXECUTE script{1} bar KEYS 1 a{1}") | ||
|
||
|
||
# Todo: this test should change once the script store command is implemented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that the #todo comment is no longer needed since script store is now implemented. Also, I think that the tests for AI.SCRIPTSTORE syntax (i.e., tests that catches errors in the RedisAI parsing phase, before we call torch.CompileScript
) should be in this file, as we did for similar tests of the AI.MODELSTORE command.
if (localArgpos >= argc) { | ||
RAI_SetError(error, RAI_ESCRIPTRUN, "ERR Invalid arguments provided to AI.SCRIPTEXECUTE"); | ||
return REDISMODULE_ERR; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if there is any difference, these errors are not tested....
4e67931
to
6de3a1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! final 3 comments... and lets merge it!
This PR introduces
AI.SCRIPTSTORE
command which will replaceAI.SCRIPTSET
. In the new command, user will have to specify entry points for the script, all with the signaturedef entry_point(tensors: List[Tensor], keys: List[Str], args: List[Str])
, so theAI.SCRIPTSTORE
command will look likeAI.SCRIPTSTORE <key> ENTRY_POINTS <n_ep> <ep_1> ... <ep_n> SOURCE <script>
AI.SCRIPTEXECUTE
command which introduced a new but awkward interface. In the new modification the user will have to specify eitherINPUTS
which are RedisAI tensors (either from keyspace or from DAG execution context),KEYS
which are the keys that the function will touch during its execution (by callingredis.Execute
command in the function, andARGS
which are strings representing any value the user needs. Those values should be cast later by the user in the script itself.AI.SCRIPTSTORE
commandAI.SCRIPTEXECUTE
command