Skip to content

Commit 769b65e

Browse files
committed
Return error if we run from MULTI or LUA.
Merge with master
2 parents 9d07aa5 + a3c18f3 commit 769b65e

File tree

16 files changed

+934
-867
lines changed

16 files changed

+934
-867
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ADD_LIBRARY(redisai_obj OBJECT
1212
dag.c
1313
dag_parser.c
1414
modelRun_ctx.c
15-
dag_llapi.c
15+
async_llapi.c
1616
backends.c
1717
backends/util.c
1818
model.c

src/async_llapi.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "dag.h"
2+
#include "redisai.h"
3+
#include "run_info.h"
4+
#include "async_llapi.h"
5+
#include "modelRun_ctx.h"
6+
7+
/* This file contains the implementation of the RedisAI low level API
8+
* for running models, scripts and DAGs asynchronously.
9+
*/
10+
11+
int RAI_ModelRunAsync(RAI_ModelRunCtx *mctx, RAI_OnFinishCB ModelAsyncFinish, void *private_data) {
12+
13+
RAI_Error error = {0};
14+
RedisAI_RunInfo *rinfo = Dag_CreateFromSingleModelRunOp(mctx, &error, NULL, NULL, NULL, 0);
15+
if (rinfo == NULL)
16+
return REDISMODULE_ERR;
17+
rinfo->OnFinish = (RedisAI_OnFinishCB)ModelAsyncFinish;
18+
rinfo->private_data = private_data;
19+
return DAG_InsertDAGToQueue(rinfo);
20+
}

src/async_llapi.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef REDISAI_ASYNC_LLAPI_H
2+
#define REDISAI_ASYNC_LLAPI_H
3+
4+
#include "model_struct.h"
5+
#include "run_info.h"
6+
7+
/**
8+
* Insert the ModelRunCtx to the run queues so it will run asynchronously.
9+
*
10+
* @param mctx ModelRunCtx to execute
11+
* @param ModelAsyncFinish A callback that will be called when the execution is finished.
12+
* @param private_data This is going to be sent to to the ModelAsyncFinish.
13+
* @return REDISMODULE_OK if the mctx was insert to the queues successfully, REDISMODULE_ERR
14+
* otherwise.
15+
*/
16+
17+
int RAI_ModelRunAsync(RAI_ModelRunCtx *mctx, RAI_OnFinishCB ModelAsyncFinish, void *private_data);
18+
19+
#endif // REDISAI_ASYNC_LLAPI_H

0 commit comments

Comments
 (0)