You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let ai.scriptget and ai.modelget commands run successfully without optional args (#791)
* Align script get command, so it will return both source and meta if no optional argument is specified.
* Documentation fixes
* Add default behaviour for AI.MODELGET + documentation
***META**: will return the model's meta information on backend, device, tag and batching parameters
226
-
***BLOB**: will return the model's blob containing the serialized model
225
+
***META**: will return only the model's meta information on backend, device, tag and batching parameters
226
+
***BLOB**: will return only the model's blob containing the serialized model
227
227
228
228
_Return_
229
229
@@ -237,7 +237,7 @@ An array of alternating key-value pairs as follows:
237
237
1.**INPUTS**: array reply with one or more names of the model's input nodes (applicable only for TensorFlow models)
238
238
1.**OUTPUTS**: array reply with one or more names of the model's output nodes (applicable only for TensorFlow models)
239
239
1.**MINBATCHTIMEOUT**: The time in milliseconds for which the engine will wait before executing a request to run the model, when the number of incoming requests is lower than `MINBATCHSIZE`. When `MINBATCHTIMEOUT` is 0, the engine will not run the model before it receives at least `MINBATCHSIZE` requests.
240
-
1.**BLOB**: a blob containing the serialized model (when called with the `BLOB` argument) as a String. If the size of the serialized model exceeds `MODEL_CHUNK_SIZE` (see `AI.CONFIG` command), then an array of chunks is returned. The full serialized model can be obtained by concatenating the chunks.
240
+
1.**BLOB**: a blob containing the serialized model as a String. If the size of the serialized model exceeds `MODEL_CHUNK_SIZE` (see `AI.CONFIG` command), then an array of chunks is returned. The full serialized model can be obtained by concatenating the chunks.
241
241
242
242
**Examples**
243
243
@@ -415,7 +415,7 @@ The **`AI.SCRIPTSTORE`** command stores a [TorchScript](https://pytorch.org/docs
***GPU:0**, ..., **GPU:n**: a specific GPU device on a multi-GPU system
430
-
***ENTRY_POINTS** A list of entry points to be used in the script. Each entry point should have the signature of `def entry_point(tensors: List[Tensor], keys: List[str], args: List[str])`. The purpose of each list is as follows:
430
+
***ENTRY_POINTS** A list of function names in the script to be used as entry points upon execution. Each entry point should have the signature of `def entry_point(tensors: List[Tensor], keys: List[str], args: List[str])`. The purpose of each list is as follows:
431
431
*`tensors`: A list holding the input tensors to the function.
432
432
*`keys`: A list of keys that the torch script is about to preform read/write operations on.
433
433
*`args`: A list of additional arguments to the function. If the desired argument is not from type string, it is up to the caller to cast it to the right type, within the script.
***META**: will return the script's meta information on deviceand tag
514
-
***SOURCE**: will return a string containing [TorchScript](https://pytorch.org/docs/stable/jit.html) source code
513
+
***META**: will return only the script's meta information on device, tag and entry points.
514
+
***SOURCE**: will return only the string containing [TorchScript](https://pytorch.org/docs/stable/jit.html) source code
515
515
516
516
_Return_
517
517
518
518
An array with alternating entries that represent the following key-value pairs:
519
-
!!!!The command returns a list of key-value strings, namely `DEVICE device TAG tag [SOURCE source]`.
519
+
!!!!The command returns a list of key-value strings, namely `DEVICE device TAG tag ENTRY_POINTS [entry_point ...] SOURCE source`.
520
520
521
521
1.**DEVICE**: the script's device as a String
522
522
2.**TAG**: the scripts's tag as a String
523
523
3.**SOURCE**: the script's source code as a String
524
-
4.**ENTRY_POINTS** will return an array containing the script entry points
524
+
4.**ENTRY_POINTS** will return an array containing the script entry point functions
525
525
526
526
**Examples**
527
527
@@ -570,7 +570,7 @@ OK
570
570
571
571
## AI.SCRIPTEXECUTE
572
572
573
-
The **`AI.SCRIPTEXECUTE`** command runs a script stored as a key's value on its specified device. It a list of keys, input tensors and addtional script args.
573
+
The **`AI.SCRIPTEXECUTE`** command runs a script stored as a key's value on its specified device. It receives a list of Redis keys, a list of input tensors and an additional list of arguments to be used in the script.
574
574
575
575
The run request is put in a queue and is executed asynchronously by a worker thread. The client that had issued the run request is blocked until the script run is completed. When needed, tensors data is automatically copied to the device prior to execution.
576
576
@@ -583,25 +583,25 @@ A `TIMEOUT t` argument can be specified to cause a request to be removed from th
583
583
584
584
```
585
585
AI.SCRIPTEXECUTE <key> <function>
586
-
[KEYS n <key> [keys...]]
587
-
[INPUTS m <input> [input ...]]
588
-
[ARGS k <arg> [arg...]]
589
-
[OUTPUTS k <output> [output ...] [TIMEOUT t]]+
586
+
[KEYS <keys_count> <key> [keys...]]
587
+
[INPUTS <input_count> <input> [input ...]]
588
+
[ARGS <args_count> <arg> [arg...]]
589
+
[OUTPUTS <outputs_count> <output> [output ...]]
590
+
[TIMEOUT t]
590
591
```
591
592
592
593
_Arguments_
593
594
594
-
***key**: the script's key name
595
-
***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.
597
-
***INPUTS**: Denotes the beginning of the input parameters list, followed by its length and one or more input tensors.
598
-
***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`.
599
-
595
+
***key**: the script's key name.
596
+
***function**: the name of the entry point function to run.
597
+
***KEYS**: Denotes the beginning of a list of Redis key names that the script will access to during its execution, for both read and/or write operations.
598
+
***INPUTS**: Denotes the beginning of the input tensors list, followed by its length and one or more input tensors.
599
+
***ARGS**: Denotes the beginning of a list of 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`.
600
600
***OUTPUTS**: denotes the beginning of the output tensors keys' list, followed by its length and one or more key names.
601
601
***TIMEOUT**: the time (in ms) after which the client is unblocked and a `TIMEDOUT` string is returned
602
602
603
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.
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 potential key accesses are done to the right shard.
605
605
606
606
_Return_
607
607
@@ -611,27 +611,12 @@ A simple 'OK' string, a simple `TIMEDOUT` string, or an error.
611
611
612
612
The following is an example of running the previously-created 'myscript' on two input tensors:
613
613
614
-
```
615
-
redis> AI.TENSORSET mytensor1 FLOAT 1 VALUES 40
616
-
OK
617
-
redis> AI.TENSORSET mytensor2 FLOAT 1 VALUES 2
618
-
OK
619
-
redis> AI.SCRIPTEXECUTE myscript addtwo KEYS 3 mytensor1 mytensor2 result INPUTS 2 mytensor1 mytensor2 OUTPUTS 1 result
620
-
OK
621
-
redis> AI.TENSORGET result VALUES
622
-
1) FLOAT
623
-
2) 1) (integer) 1
624
-
3) 1) "42"
625
-
```
626
-
627
-
Note: The above command could be executed with a shorter version, given all the keys are tagged with the same tag:
Note: for the time being, as `AI.SCRIPTSET` is still avialable to use, `AI.SCRIPTEXECUTE` still supports running functions that are part of scripts stored with `AI.SCRIPTSET` or imported from old RDB/AOF files. Meaning calling `AI.SCRIPTEXECUTE` over a function without the dedicated signature of `(tensors: List[Tensor], keys: List[str], args: List[str]` will yield a "best effort" execution to match the deprecated API `AI.SCRIPTRUN` function execution. This will map `INPUTS` tensors only, to their counterpart input arguments in the function, according to the order which they apear.
648
+
Note: for the time being, as `AI.SCRIPTSET` is still available to use, `AI.SCRIPTEXECUTE` still supports running functions that are part of scripts stored with `AI.SCRIPTSET` or imported from old RDB/AOF files. Meaning calling `AI.SCRIPTEXECUTE` over a function without the dedicated signature of `(tensors: List[Tensor], keys: List[str], args: List[str]` will yield a "best effort" execution to match the deprecated API `AI.SCRIPTRUN` function execution. This will map `INPUTS` tensors only, to their counterpart input arguments in the function, according to the order which they appear.
664
649
665
650
### Redis Commands support.
666
-
In RedisAI TorchScript now supports simple (non-blocking) Redis commnands via the `redis.execute` API. The following script gets a key name (`x{1}`), and an `int` value (3). First, the script `SET`s the value in the key. Next, the script `GET`s the value back from the key, and sets it in a tensor which is eventually stored under the key 'y{1}'. Note that the inputs are `str` and `int`. The script sets and gets the value and set it into a tensor.
651
+
In RedisAI TorchScript now supports simple (non-blocking) Redis commands via the `redis.execute` API. The following script gets a key name (`x{1}`), and an `int` value (3). First, the script `SET`s the value in the key. Next, the script `GET`s the value back from the key, and sets it in a tensor which is eventually stored under the key 'y{1}'. Note that the inputs are `str` and `int`. The script sets and gets the value and set it into a tensor.
667
652
668
653
```
669
654
def redis_int_to_tensor(redis_value: int):
@@ -692,13 +677,13 @@ The command receives 3 inputs:
692
677
Return value - the model execution output tensors (List of torch.Tensor)
693
678
The following script creates two tensors, and executes the (tensorflow) model which is stored under the name 'tf_mul{1}' with these two tensors as inputs.
***LOAD**: denotes the beginning of the input tensors keys' list, followed by the number of keys, and one or more key names
846
831
***PERSIST**: denotes the beginning of the output tensors keys' list, followed by the number of keys, and one or more key names
847
-
***ROUTING**: denotes the a key name or a tag that will assist in routing the dag execution command to the right shard. Redis will verify that all potential key accesses are done to within the target shard.
832
+
***ROUTING**: denotes a key to be used in the DAG or a tag that will assist in routing the dag execution command to the right shard. Redis will verify that all potential key accesses are done to within the target shard.
848
833
849
834
_While each of the LOAD, PERSIST and ROUTING sections are optional (and may appear at most once in the command), the command must contain **at least one** of these 3 keywords._
850
835
***TIMEOUT**: an optional argument, denotes the time (in ms) after which the client is unblocked and a `TIMEDOUT` string is returned
0 commit comments