66from tests .model_registry .model_catalog .utils import (
77 get_hf_catalog_str ,
88)
9- from tests .model_registry .utils import execute_get_command
109from tests .model_registry .model_catalog .huggingface .utils import (
1110 assert_huggingface_values_matches_model_catalog_api_values ,
1211 wait_for_huggingface_retrival_match ,
1312 wait_for_hugging_face_model_import ,
1413 wait_for_last_sync_update ,
14+ get_huggingface_model_from_api ,
1515)
1616from huggingface_hub import HfApi
1717from kubernetes .dynamic import DynamicClient
@@ -60,6 +60,7 @@ def test_huggingface_last_synced_custom(
6060 model_registry_rest_headers = model_registry_rest_headers ,
6161 model_catalog_rest_url = model_catalog_rest_url ,
6262 model_name = model_name ,
63+ source_id = "hf_id" ,
6364 initial_last_synced_values = float (initial_last_synced_values ),
6465 )
6566
@@ -85,7 +86,6 @@ class TestHuggingFaceModelValidation:
8586 def test_huggingface_model_metadata_last_synced (
8687 self : Self ,
8788 epoch_time_before_config_map_update : float ,
88- updated_catalog_config_map : tuple [ConfigMap , str , str ],
8989 model_catalog_rest_url : list [str ],
9090 model_registry_rest_headers : dict [str , str ],
9191 expected_catalog_values : dict [str , str ],
@@ -100,12 +100,12 @@ def test_huggingface_model_metadata_last_synced(
100100 )
101101 error = {}
102102 for model_name in expected_catalog_values :
103- url = f"{ model_catalog_rest_url [0 ]} sources/{ HF_SOURCE_ID } /models/{ model_name } "
104- result = execute_get_command (
105- url = url ,
106- headers = model_registry_rest_headers ,
103+ result = get_huggingface_model_from_api (
104+ model_catalog_rest_url = model_catalog_rest_url ,
105+ model_registry_rest_headers = model_registry_rest_headers ,
106+ model_name = model_name ,
107+ source_id = HF_SOURCE_ID ,
107108 )
108-
109109 error_msg = ""
110110 if result ["name" ] != model_name :
111111 error_msg += f"Expected model name { model_name } , but got { result ['name' ]} . "
@@ -115,17 +115,13 @@ def test_huggingface_model_metadata_last_synced(
115115 LOGGER .info (f"Model { model_name } last synced at: { last_synced } " )
116116
117117 # Validate that last_synced field exists and is not empty
118- if last_synced is None :
119- error_msg += f"last_synced field is None for model { model_name } . "
120- elif last_synced == "" :
121- error_msg += f"last_synced field is empty for model { model_name } . "
122- else :
123- # Compare timestamps: current_epoch_time should be earlier than last_synced
124- if epoch_time_before_config_map_update > float (last_synced ):
125- error_msg += (
126- f"Model { model_name } last_synced ({ last_synced } ) should be after "
127- f"test start time ({ epoch_time_before_config_map_update } ). "
128- )
118+ if not last_synced or last_synced == "" :
119+ error_msg += f"last_synced field is not present for model { model_name } . "
120+ elif epoch_time_before_config_map_update > float (last_synced ):
121+ error_msg += (
122+ f"Model { model_name } last_synced ({ last_synced } ) should be after "
123+ f"test start time ({ epoch_time_before_config_map_update } ). "
124+ )
129125 if error_msg :
130126 error [model_name ] = error_msg
131127 if error :
0 commit comments