MCPcopy Create free account
hub / github.com/RedisGears/RedisGears / DAGAddOpsFromString

Function DAGAddOpsFromString

plugins/python/redisgears_python.c:2578–2608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2576}
2577
2578static PyObject* DAGAddOpsFromString(PyObject *self, PyObject *args) {
2579 verifyRedisAILoaded();
2580 PyDAGRunner *pyDag = (PyDAGRunner *)self;
2581 if(!_IsDagAPISupported(RedisAI_DAGAddOpsFromString) || !_IsValidDag(pyDag)) {
2582 return NULL;
2583 }
2584
2585 if(PyTuple_Size(args) != 1){
2586 PyErr_SetString(GearsError, "Wrong number of args");
2587 return NULL;
2588 }
2589 PyObject* ops = PyTuple_GetItem(args, 0);
2590 if(!PyUnicode_Check(ops)){
2591 PyErr_SetString(GearsError, "ops argument must be a string");
2592 return NULL;
2593 }
2594 const char* opsStr = PyUnicode_AsUTF8AndSize(ops, NULL);
2595 RAI_Error *err;
2596 RedisAI_InitError(&err);
2597 RedisGears_LockHanlderAcquire(staticCtx);
2598 if (RedisAI_DAGAddOpsFromString(pyDag->dag, opsStr, err) != REDISMODULE_OK) {
2599 PyErr_SetString(GearsError, RedisAI_GetError(err));
2600 RedisAI_FreeError(err);
2601 RedisGears_LockHanlderRelease(staticCtx);
2602 return NULL;
2603 }
2604 RedisAI_FreeError(err);
2605 RedisGears_LockHanlderRelease(staticCtx);
2606 Py_INCREF(self);
2607 return self;
2608}
2609
2610static void FinishAsyncDAGRun(RAI_OnFinishCtx *onFinishCtx, void *private_data) {
2611

Callers

nothing calls this directly

Calls 2

_IsDagAPISupportedFunction · 0.85
_IsValidDagFunction · 0.85

Tested by

no test coverage detected