@@ -339,7 +339,7 @@ def test_infer_export_when_loading(self):
339
339
340
340
def test_find_files_matching_pattern (self ):
341
341
model_id = "echarlaix/tiny-random-PhiForCausalLM"
342
- pattern = r"(.*)?openvino(.*)?\_model.xml"
342
+ pattern = r"(.*)?openvino(.*)?\_model.xml$ "
343
343
# hub model
344
344
for revision in ("main" , "ov" , "itrex" ):
345
345
ov_files = _find_files_matching_pattern (
@@ -360,7 +360,7 @@ def test_find_files_matching_pattern(self):
360
360
361
361
@parameterized .expand (("stable-diffusion" , "stable-diffusion-openvino" ))
362
362
def test_find_files_matching_pattern_sd (self , model_arch ):
363
- pattern = r"(.*)?openvino(.*)?\_model.xml"
363
+ pattern = r"(.*)?openvino(.*)?\_model.xml$ "
364
364
model_id = MODEL_NAMES [model_arch ]
365
365
# hub model
366
366
ov_files = _find_files_matching_pattern (model_id , pattern = pattern )
@@ -374,6 +374,23 @@ def test_find_files_matching_pattern_sd(self, model_arch):
374
374
ov_files = _find_files_matching_pattern (local_dir , pattern = pattern )
375
375
self .assertTrue (len (ov_files ) > 0 if "openvino" in model_id else len (ov_files ) == 0 )
376
376
377
+ @parameterized .expand (("" , "openvino" ))
378
+ def test_find_files_matching_pattern_with_config_in_root (self , subfolder ):
379
+ # Notably, the model has a config.json file in the root directory and not in the subfolder
380
+ model_id = "sentence-transformers-testing/stsb-bert-tiny-openvino"
381
+ pattern = r"(.*)?openvino(.*)?\_model.xml$"
382
+ # hub model
383
+ ov_files = _find_files_matching_pattern (model_id , pattern = pattern , subfolder = subfolder )
384
+ self .assertTrue (len (ov_files ) == 1 if subfolder == "openvino" else len (ov_files ) == 0 )
385
+
386
+ # local model
387
+ api = HfApi ()
388
+ with tempfile .TemporaryDirectory () as tmpdirname :
389
+ local_dir = Path (tmpdirname ) / "model"
390
+ api .snapshot_download (repo_id = model_id , local_dir = local_dir )
391
+ ov_files = _find_files_matching_pattern (local_dir , pattern = pattern , subfolder = subfolder )
392
+ self .assertTrue (len (ov_files ) == 1 if subfolder == "openvino" else len (ov_files ) == 0 )
393
+
377
394
378
395
class PipelineTest (unittest .TestCase ):
379
396
def test_load_model_from_hub (self ):
0 commit comments