2323from sagemaker .serve .detector .pickler import save_pkl
2424from sagemaker .serve .model_server .triton .config_template import CONFIG_TEMPLATE
2525from sagemaker .serve .validations .check_integrity import (
26- generate_secret_key ,
2726 compute_hash ,
2827)
2928
@@ -213,7 +212,7 @@ def _prepare_for_triton(self):
213212 export_path .mkdir (parents = True )
214213
215214 if self .model :
216- self . secret_key = "dummy secret key for onnx backend"
215+ # ONNX path: no pickle serialization, no serve.pkl, no integrity check needed.
217216
218217 if self ._framework == "pytorch" :
219218 self ._export_pytorch_to_onnx (
@@ -237,26 +236,23 @@ def _prepare_for_triton(self):
237236
238237 self ._pack_conda_env (pkl_path = pkl_path )
239238
240- self ._hmac_signing ()
239+ self ._compute_integrity_hash ()
241240
242241 return
243242
244243 raise ValueError ("Either model or inference_spec should be provided to ModelBuilder." )
245244
246- def _hmac_signing (self ):
247- """Perform HMAC signing on picke file for integrity check"""
248- secret_key = generate_secret_key ()
245+ def _compute_integrity_hash (self ):
246+ """Compute SHA-256 integrity hash on pickle file for integrity check"""
249247 pkl_path = Path (self .model_path ).joinpath ("model_repository" ).joinpath ("model" )
250248
251249 with open (str (pkl_path .joinpath ("serve.pkl" )), "rb" ) as f :
252250 buffer = f .read ()
253- hash_value = compute_hash (buffer = buffer , secret_key = secret_key )
251+ hash_value = compute_hash (buffer = buffer )
254252
255253 with open (str (pkl_path .joinpath ("metadata.json" )), "wb" ) as metadata :
256254 metadata .write (_MetaData (hash_value ).to_json ())
257255
258- self .secret_key = secret_key
259-
260256 def _generate_config_pbtxt (self , pkl_path : Path ):
261257 config_path = pkl_path .joinpath ("config.pbtxt" )
262258
0 commit comments