@@ -23,12 +23,12 @@ def modelstore(
23
23
inputs : Union [AnyStr , List [AnyStr ]],
24
24
outputs : Union [AnyStr , List [AnyStr ]],
25
25
) -> Sequence :
26
+ if name is None :
27
+ raise ValueError ("Model name was not given" )
26
28
if device .upper () not in utils .allowed_devices :
27
- raise ValueError (
28
- f"Device not allowed. Use any from { utils .allowed_devices } " )
29
+ raise ValueError (f"Device not allowed. Use any from { utils .allowed_devices } " )
29
30
if backend .upper () not in utils .allowed_backends :
30
- raise ValueError (
31
- f"Backend not allowed. Use any from { utils .allowed_backends } " )
31
+ raise ValueError (f"Backend not allowed. Use any from { utils .allowed_backends } " )
32
32
args = ["AI.MODELSTORE" , name , backend , device ]
33
33
34
34
if tag is not None :
@@ -64,8 +64,7 @@ def modelstore(
64
64
"Inputs and outputs keywords should not be specified for this backend"
65
65
)
66
66
chunk_size = 500 * 1024 * 1024 # TODO: this should be configurable.
67
- data_chunks = [data [i : i + chunk_size ]
68
- for i in range (0 , len (data ), chunk_size )]
67
+ data_chunks = [data [i : i + chunk_size ] for i in range (0 , len (data ), chunk_size )]
69
68
# TODO: need a test case for this
70
69
args += ["BLOB" , * data_chunks ]
71
70
return args
@@ -83,11 +82,9 @@ def modelset(
83
82
outputs : Union [AnyStr , List [AnyStr ]],
84
83
) -> Sequence :
85
84
if device .upper () not in utils .allowed_devices :
86
- raise ValueError (
87
- f"Device not allowed. Use any from { utils .allowed_devices } " )
85
+ raise ValueError (f"Device not allowed. Use any from { utils .allowed_devices } " )
88
86
if backend .upper () not in utils .allowed_backends :
89
- raise ValueError (
90
- f"Backend not allowed. Use any from { utils .allowed_backends } " )
87
+ raise ValueError (f"Backend not allowed. Use any from { utils .allowed_backends } " )
91
88
args = ["AI.MODELSET" , name , backend , device ]
92
89
93
90
if tag is not None :
@@ -101,13 +98,11 @@ def modelset(
101
98
102
99
if backend .upper () == "TF" :
103
100
if not (all ((inputs , outputs ))):
104
- raise ValueError (
105
- "Require keyword arguments input and output for TF models" )
101
+ raise ValueError ("Require keyword arguments input and output for TF models" )
106
102
args += ["INPUTS" , * utils .listify (inputs )]
107
103
args += ["OUTPUTS" , * utils .listify (outputs )]
108
104
chunk_size = 500 * 1024 * 1024
109
- data_chunks = [data [i : i + chunk_size ]
110
- for i in range (0 , len (data ), chunk_size )]
105
+ data_chunks = [data [i : i + chunk_size ] for i in range (0 , len (data ), chunk_size )]
111
106
# TODO: need a test case for this
112
107
args += ["BLOB" , * data_chunks ]
113
108
return args
@@ -130,6 +125,8 @@ def modelexecute(
130
125
outputs : Union [AnyStr , List [AnyStr ]],
131
126
timeout : int ,
132
127
) -> Sequence :
128
+ if name is None or inputs is None or outputs is None :
129
+ raise ValueError ("Missing required arguments for model execute command" )
133
130
args = [
134
131
"AI.MODELEXECUTE" ,
135
132
name ,
@@ -209,8 +206,7 @@ def tensorget(key: AnyStr, as_numpy: bool = True, meta_only: bool = False) -> Se
209
206
210
207
def scriptset (name : AnyStr , device : str , script : str , tag : AnyStr = None ) -> Sequence :
211
208
if device .upper () not in utils .allowed_devices :
212
- raise ValueError (
213
- f"Device not allowed. Use any from { utils .allowed_devices } " )
209
+ raise ValueError (f"Device not allowed. Use any from { utils .allowed_devices } " )
214
210
args = ["AI.SCRIPTSET" , name , device ]
215
211
if tag :
216
212
args += ["TAG" , tag ]
0 commit comments