17
17
)
18
18
19
19
import onnxruntime
20
+ from huggingface_hub .utils import EntryNotFoundError
20
21
from optimum .onnxruntime import (
21
22
ONNX_WEIGHTS_NAME ,
22
23
ORTModelForCausalLM ,
@@ -50,9 +51,8 @@ def test_load_model_from_hub(self):
50
51
self .assertIsInstance (model .config , PretrainedConfig )
51
52
52
53
def test_load_model_from_hub_without_onnx_model (self ):
53
- with self .assertRaises (Exception ) as context :
54
+ with self .assertRaises (EntryNotFoundError ) :
54
55
ORTModel .from_pretrained (self .FAIL_ONNX_MODEL_ID )
55
- self .assertEqual ("Not Found" , context .exception .response .reason )
56
56
57
57
@require_hf_token
58
58
def test_load_model_from_hub_private (self ):
@@ -72,10 +72,11 @@ def test_save_model(self):
72
72
def test_save_model_with_different_name (self ):
73
73
with tempfile .TemporaryDirectory () as tmpdirname :
74
74
test_model_name = "model-test.onnx"
75
- local_model_path = str (Path (self .LOCAL_MODEL_PATH ).joinpath ("model.onnx" ).absolute ())
76
- # copy two models to simulate a optimization
77
- shutil .copy (local_model_path , os .path .join (tmpdirname , test_model_name ))
78
- shutil .copy (local_model_path , os .path .join (tmpdirname , "model.onnx" ))
75
+ model = ORTModel .from_pretrained (self .LOCAL_MODEL_PATH )
76
+
77
+ # save two models to simulate a optimization
78
+ model .save_pretrained (tmpdirname )
79
+ model .save_pretrained (tmpdirname , file_name = test_model_name )
79
80
80
81
model = ORTModel .from_pretrained (tmpdirname , file_name = test_model_name )
81
82
0 commit comments