@@ -27,13 +27,15 @@ def get_client(self):
2727
2828 def test_set_tensor (self ):
2929 con = self .get_client ()
30- con .tensorset ('x' , Tensor . scalar ( DType . float , 2 , 3 ))
30+ con .tensorset ('x' , ( 2 , 3 ), dtype = DType . float )
3131 values = con .tensorget ('x' , as_type = Tensor )
3232 self .assertEqual ([2 , 3 ], values .value )
3333
3434 con .tensorset ('x' , Tensor .scalar (DType .int32 , 2 , 3 ))
3535 values = con .tensorget ('x' , as_type = Tensor ).value
3636 self .assertEqual ([2 , 3 ], values )
37+ meta = con .tensorget ('x' , meta_only = True )
38+ self .assertTrue ('<Tensor(shape=[2] type=DType.int32) at ' in repr (meta ))
3739
3840 self .assertRaises (Exception , con .tensorset , 1 )
3941 self .assertRaises (Exception , con .tensorset , 'x' )
@@ -86,15 +88,21 @@ def test_run_tf_model(self):
8688 con .modelrun ('m' , ['a' , 'b' ], 'c' )
8789 tensor = con .tensorget ('c' )
8890 self .assertTrue (np .allclose ([4 , 9 ], tensor ))
91+ model_det = con .modelget ('m' )
92+ self .assertTrue (model_det ['backend' ] == Backend .tf )
93+ self .assertTrue (model_det ['device' ] == Device .cpu )
94+ con .modeldel ('m' )
95+ self .assertRaises (ResponseError , con .modelget , 'm' )
8996
9097 def test_scripts (self ):
9198 con = self .get_client ()
9299 self .assertRaises (ResponseError , con .scriptset ,
93100 'ket' , Device .cpu , 'return 1' )
94- con . scriptset ( 'ket' , Device . cpu , r"""
101+ script = r"""
95102def bar(a, b):
96103 return a + b
97- """ )
104+ """
105+ con .scriptset ('ket' , Device .cpu , script )
98106 con .tensorset ('a' , Tensor .scalar (DType .float , 2 , 3 ))
99107 con .tensorset ('b' , Tensor .scalar (DType .float , 2 , 3 ))
100108 # try with bad arguments:
@@ -103,6 +111,12 @@ def bar(a, b):
103111 con .scriptrun ('ket' , 'bar' , inputs = ['a' , 'b' ], outputs = 'c' )
104112 tensor = con .tensorget ('c' , as_type = Tensor )
105113 self .assertEqual ([4 , 6 ], tensor .value )
114+ script_det = con .scriptget ('ket' )
115+ self .assertTrue (script_det ['device' ] == Device .cpu )
116+ self .assertTrue (script_det ['script' ] == script )
117+ self .assertTrue ("def bar(a, b):" in script_det ['script' ])
118+ con .scriptdel ('ket' )
119+ self .assertRaises (ResponseError , con .scriptget , 'ket' )
106120
107121 def test_run_onnxml_model (self ):
108122 mlmodel_path = os .path .join (MODEL_DIR , 'boston.onnx' )
0 commit comments