@@ -583,6 +583,66 @@ def test_pytorch_scriptrun_errors(env):
583
583
env .assertEqual (type (exception ), redis .exceptions .ResponseError )
584
584
585
585
586
+ def test_pytorch_scriptrun_errors (env ):
587
+ if not TEST_PT :
588
+ env .debugPrint ("skipping {} since TEST_PT=0" .format (sys ._getframe ().f_code .co_name ), force = True )
589
+ return
590
+
591
+ con = env .getConnection ()
592
+
593
+ test_data_path = os .path .join (os .path .dirname (__file__ ), 'test_data' )
594
+ script_filename = os .path .join (test_data_path , 'script.txt' )
595
+
596
+ with open (script_filename , 'rb' ) as f :
597
+ script = f .read ()
598
+
599
+ ret = con .execute_command ('AI.SCRIPTSET' , 'ket' , DEVICE , 'TAG' , 'asdf' , 'SOURCE' , script )
600
+ env .assertEqual (ret , b'OK' )
601
+
602
+ ret = con .execute_command ('AI.TENSORSET' , 'a' , 'FLOAT' , 2 , 2 , 'VALUES' , 2 , 3 , 2 , 3 )
603
+ env .assertEqual (ret , b'OK' )
604
+ ret = con .execute_command ('AI.TENSORSET' , 'b' , 'FLOAT' , 2 , 2 , 'VALUES' , 2 , 3 , 2 , 3 )
605
+ env .assertEqual (ret , b'OK' )
606
+
607
+ ensureSlaveSynced (con , env )
608
+
609
+ # ERR Variadic input key is empty
610
+ try :
611
+ con .execute_command ('DEL' , 'EMPTY' )
612
+ con .execute_command ('AI.SCRIPTRUN' , 'ket' , 'bar_variadic' , 'INPUTS' , 'a' , '$' , 'EMPTY' , 'b' , 'OUTPUTS' , 'c' )
613
+ except Exception as e :
614
+ exception = e
615
+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
616
+ env .assertEqual ("tensor key is empty" , exception .__str__ ())
617
+
618
+ # ERR Variadic input key not tensor
619
+ try :
620
+ con .execute_command ('SET' , 'NOT_TENSOR' , 'BAR' )
621
+ con .execute_command ('AI.SCRIPTRUN' , 'ket' , 'bar_variadic' , 'INPUTS' , 'a' , '$' , 'NOT_TENSOR' , 'b' , 'OUTPUTS' , 'c' )
622
+ except Exception as e :
623
+ exception = e
624
+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
625
+ env .assertEqual ("WRONGTYPE Operation against a key holding the wrong kind of value" , exception .__str__ ())
626
+
627
+ try :
628
+ con .execute_command ('AI.SCRIPTRUN' , 'ket' , 'bar_variadic' , 'INPUTS' , 'b' , '$' , 'OUTPUTS' , 'c' )
629
+ except Exception as e :
630
+ exception = e
631
+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
632
+
633
+ try :
634
+ con .execute_command ('AI.SCRIPTRUN' , 'ket' , 'bar_variadic' , 'INPUTS' , 'b' , '$' , 'OUTPUTS' )
635
+ except Exception as e :
636
+ exception = e
637
+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
638
+
639
+ try :
640
+ con .execute_command ('AI.SCRIPTRUN' , 'ket' , 'bar_variadic' , 'INPUTS' , '$' , 'OUTPUTS' )
641
+ except Exception as e :
642
+ exception = e
643
+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
644
+
645
+
586
646
def test_pytorch_scriptinfo (env ):
587
647
if not TEST_PT :
588
648
env .debugPrint ("skipping {} since TEST_PT=0" .format (sys ._getframe ().f_code .co_name ), force = True )
0 commit comments