@@ -972,6 +972,9 @@ def get_model_files(os_path: str, model_format: ModelFormat) -> List[str]:
972
972
# todo: revisit this logic to account for .bin files. In the current state, .bin and .safetensor models
973
973
# are grouped in one category and validation checks for config.json files only.
974
974
if model_format == ModelFormat .SAFETENSORS :
975
+ model_files .extend (
976
+ list_os_files_with_extension (oss_path = os_path , extension = ".safetensors" )
977
+ )
975
978
try :
976
979
load_config (
977
980
file_path = os_path ,
@@ -1022,10 +1025,12 @@ def get_hf_model_files(model_name: str, model_format: ModelFormat) -> List[str]:
1022
1025
1023
1026
for model_sibling in model_siblings :
1024
1027
extension = pathlib .Path (model_sibling .rfilename ).suffix [1 :].upper ()
1025
- if model_format == ModelFormat .SAFETENSORS :
1026
- if model_sibling .rfilename == AQUA_MODEL_ARTIFACT_CONFIG :
1027
- model_files .append (model_sibling .rfilename )
1028
- elif extension == model_format .value :
1028
+ if (
1029
+ model_format == ModelFormat .SAFETENSORS
1030
+ and model_sibling .rfilename == AQUA_MODEL_ARTIFACT_CONFIG
1031
+ ):
1032
+ model_files .append (model_sibling .rfilename )
1033
+ if extension == model_format .value :
1029
1034
model_files .append (model_sibling .rfilename )
1030
1035
1031
1036
return model_files
@@ -1061,7 +1066,10 @@ def _validate_model(
1061
1066
safetensors_model_files = self .get_hf_model_files (
1062
1067
model_name , ModelFormat .SAFETENSORS
1063
1068
)
1064
- if safetensors_model_files :
1069
+ if (
1070
+ safetensors_model_files
1071
+ and AQUA_MODEL_ARTIFACT_CONFIG in safetensors_model_files
1072
+ ):
1065
1073
hf_download_config_present = True
1066
1074
gguf_model_files = self .get_hf_model_files (model_name , ModelFormat .GGUF )
1067
1075
else :
@@ -1173,14 +1181,20 @@ def _validate_safetensor_format(
1173
1181
model_name : str = None ,
1174
1182
):
1175
1183
if import_model_details .download_from_hf :
1176
- # validates config.json exists for safetensors model from hugginface
1177
- if not hf_download_config_present :
1184
+ # validates config.json exists for safetensors model from huggingface
1185
+ if not (
1186
+ hf_download_config_present
1187
+ or import_model_details .ignore_model_artifact_check
1188
+ ):
1178
1189
raise AquaRuntimeError (
1179
1190
f"The model { model_name } does not contain { AQUA_MODEL_ARTIFACT_CONFIG } file as required "
1180
1191
f"by { ModelFormat .SAFETENSORS .value } format model."
1181
1192
f" Please check if the model name is correct in Hugging Face repository."
1182
1193
)
1194
+ validation_result .telemetry_model_name = model_name
1183
1195
else :
1196
+ # validate if config.json is available from object storage, and get model name for telemetry
1197
+ model_config = None
1184
1198
try :
1185
1199
model_config = load_config (
1186
1200
file_path = import_model_details .os_path ,
@@ -1191,22 +1205,25 @@ def _validate_safetensor_format(
1191
1205
f"Exception occurred while loading config file from { import_model_details .os_path } "
1192
1206
f"Exception message: { ex } "
1193
1207
)
1194
- raise AquaRuntimeError (
1195
- f"The model path { import_model_details .os_path } does not contain the file config.json. "
1196
- f"Please check if the path is correct or the model artifacts are available at this location."
1197
- ) from ex
1198
- else :
1208
+ if not import_model_details .ignore_model_artifact_check :
1209
+ raise AquaRuntimeError (
1210
+ f"The model path { import_model_details .os_path } does not contain the file config.json. "
1211
+ f"Please check if the path is correct or the model artifacts are available at this location."
1212
+ ) from ex
1213
+
1214
+ if verified_model :
1215
+ # model_type validation, log message if metadata field doesn't match.
1199
1216
try :
1200
1217
metadata_model_type = verified_model .custom_metadata_list .get (
1201
1218
AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE
1202
1219
).value
1203
- if metadata_model_type :
1220
+ if metadata_model_type and model_config is not None :
1204
1221
if AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE in model_config :
1205
1222
if (
1206
1223
model_config [AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE ]
1207
1224
!= metadata_model_type
1208
1225
):
1209
- raise AquaRuntimeError (
1226
+ logger . debug (
1210
1227
f"The { AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE } attribute in { AQUA_MODEL_ARTIFACT_CONFIG } "
1211
1228
f" at { import_model_details .os_path } is invalid, expected { metadata_model_type } for "
1212
1229
f"the model { model_name } . Please check if the path is correct or "
@@ -1219,21 +1236,22 @@ def _validate_safetensor_format(
1219
1236
f"{ AQUA_MODEL_ARTIFACT_CONFIG } . Proceeding with model registration."
1220
1237
)
1221
1238
except Exception :
1239
+ # todo: raise exception if model_type doesn't match. Currently log message and pass since service
1240
+ # models do not have this metadata.
1222
1241
pass
1223
- if verified_model :
1224
- validation_result .telemetry_model_name = verified_model .display_name
1225
- elif (
1226
- model_config is not None
1227
- and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME in model_config
1228
- ):
1229
- validation_result .telemetry_model_name = f"{ AQUA_MODEL_TYPE_CUSTOM } _{ model_config [AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME ]} "
1230
- elif (
1231
- model_config is not None
1232
- and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE in model_config
1233
- ):
1234
- validation_result .telemetry_model_name = f"{ AQUA_MODEL_TYPE_CUSTOM } _{ model_config [AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE ]} "
1235
- else :
1236
- validation_result .telemetry_model_name = AQUA_MODEL_TYPE_CUSTOM
1242
+ validation_result .telemetry_model_name = verified_model .display_name
1243
+ elif (
1244
+ model_config is not None
1245
+ and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME in model_config
1246
+ ):
1247
+ validation_result .telemetry_model_name = f"{ AQUA_MODEL_TYPE_CUSTOM } _{ model_config [AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME ]} "
1248
+ elif (
1249
+ model_config is not None
1250
+ and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE in model_config
1251
+ ):
1252
+ validation_result .telemetry_model_name = f"{ AQUA_MODEL_TYPE_CUSTOM } _{ model_config [AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE ]} "
1253
+ else :
1254
+ validation_result .telemetry_model_name = AQUA_MODEL_TYPE_CUSTOM
1237
1255
1238
1256
@staticmethod
1239
1257
def _validate_gguf_format (
0 commit comments