oracle-ads 2.12.2__py3-none-any.whl → 2.12.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. ads/aqua/common/enums.py +9 -0
  2. ads/aqua/common/utils.py +83 -6
  3. ads/aqua/config/config.py +0 -16
  4. ads/aqua/constants.py +2 -0
  5. ads/aqua/evaluation/entities.py +45 -50
  6. ads/aqua/evaluation/evaluation.py +26 -61
  7. ads/aqua/extension/deployment_handler.py +35 -0
  8. ads/aqua/extension/errors.py +1 -0
  9. ads/aqua/extension/evaluation_handler.py +0 -5
  10. ads/aqua/extension/finetune_handler.py +1 -2
  11. ads/aqua/extension/model_handler.py +38 -1
  12. ads/aqua/extension/ui_handler.py +22 -3
  13. ads/aqua/finetuning/entities.py +5 -4
  14. ads/aqua/finetuning/finetuning.py +13 -8
  15. ads/aqua/model/constants.py +1 -0
  16. ads/aqua/model/entities.py +2 -0
  17. ads/aqua/model/model.py +350 -140
  18. ads/aqua/modeldeployment/deployment.py +118 -62
  19. ads/aqua/modeldeployment/entities.py +10 -2
  20. ads/aqua/ui.py +29 -16
  21. ads/config.py +3 -8
  22. ads/dataset/dataset.py +2 -2
  23. ads/dataset/factory.py +1 -1
  24. ads/llm/deploy.py +6 -0
  25. ads/llm/guardrails/base.py +0 -1
  26. ads/llm/langchain/plugins/chat_models/oci_data_science.py +118 -41
  27. ads/llm/langchain/plugins/llms/oci_data_science_model_deployment_endpoint.py +18 -14
  28. ads/llm/templates/score_chain.jinja2 +0 -1
  29. ads/model/datascience_model.py +519 -16
  30. ads/model/deployment/model_deployment.py +13 -0
  31. ads/model/deployment/model_deployment_infrastructure.py +34 -0
  32. ads/model/generic_model.py +10 -0
  33. ads/model/model_properties.py +1 -0
  34. ads/model/service/oci_datascience_model.py +28 -0
  35. ads/opctl/operator/lowcode/anomaly/const.py +66 -1
  36. ads/opctl/operator/lowcode/anomaly/model/anomaly_merlion.py +161 -0
  37. ads/opctl/operator/lowcode/anomaly/model/autots.py +30 -15
  38. ads/opctl/operator/lowcode/anomaly/model/factory.py +15 -3
  39. ads/opctl/operator/lowcode/anomaly/model/randomcutforest.py +1 -1
  40. ads/opctl/operator/lowcode/anomaly/schema.yaml +10 -0
  41. ads/opctl/operator/lowcode/anomaly/utils.py +3 -0
  42. ads/opctl/operator/lowcode/forecast/cmd.py +3 -9
  43. ads/opctl/operator/lowcode/forecast/const.py +3 -4
  44. ads/opctl/operator/lowcode/forecast/model/factory.py +13 -12
  45. ads/opctl/operator/lowcode/forecast/model/ml_forecast.py +4 -3
  46. ads/opctl/operator/lowcode/forecast/operator_config.py +17 -10
  47. ads/opctl/operator/lowcode/forecast/schema.yaml +2 -2
  48. ads/oracledb/oracle_db.py +32 -20
  49. ads/secrets/adb.py +28 -6
  50. {oracle_ads-2.12.2.dist-info → oracle_ads-2.12.4.dist-info}/METADATA +3 -2
  51. {oracle_ads-2.12.2.dist-info → oracle_ads-2.12.4.dist-info}/RECORD +54 -55
  52. {oracle_ads-2.12.2.dist-info → oracle_ads-2.12.4.dist-info}/WHEEL +1 -1
  53. ads/aqua/config/deployment_config_defaults.json +0 -38
  54. ads/aqua/config/resource_limit_names.json +0 -9
  55. {oracle_ads-2.12.2.dist-info → oracle_ads-2.12.4.dist-info}/LICENSE.txt +0 -0
  56. {oracle_ads-2.12.2.dist-info → oracle_ads-2.12.4.dist-info}/entry_points.txt +0 -0
ads/aqua/model/model.py CHANGED
@@ -10,18 +10,24 @@ from typing import Dict, List, Optional, Set, Union
10
10
  import oci
11
11
  from cachetools import TTLCache
12
12
  from huggingface_hub import snapshot_download
13
- from oci.data_science.models import JobRun, Model
13
+ from oci.data_science.models import JobRun, Metadata, Model, UpdateModelDetails
14
14
 
15
15
  from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID, logger
16
16
  from ads.aqua.app import AquaApp
17
- from ads.aqua.common.enums import Tags
17
+ from ads.aqua.common.enums import (
18
+ FineTuningContainerTypeFamily,
19
+ InferenceContainerTypeFamily,
20
+ Tags,
21
+ )
18
22
  from ads.aqua.common.errors import AquaRuntimeError, AquaValueError
19
23
  from ads.aqua.common.utils import (
20
24
  LifecycleStatus,
21
25
  _build_resource_identifier,
22
26
  copy_model_config,
23
27
  create_word_icon,
28
+ generate_tei_cmd_var,
24
29
  get_artifact_path,
30
+ get_container_config,
25
31
  get_hf_model_info,
26
32
  list_os_files_with_extension,
27
33
  load_config,
@@ -67,7 +73,9 @@ from ads.common.auth import default_signer
67
73
  from ads.common.oci_resource import SEARCH_TYPE, OCIResource
68
74
  from ads.common.utils import get_console_link
69
75
  from ads.config import (
76
+ AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
70
77
  AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
78
+ AQUA_DEPLOYMENT_CONTAINER_URI_METADATA_NAME,
71
79
  AQUA_EVALUATION_CONTAINER_METADATA_NAME,
72
80
  AQUA_FINETUNING_CONTAINER_METADATA_NAME,
73
81
  COMPARTMENT_OCID,
@@ -75,7 +83,11 @@ from ads.config import (
75
83
  TENANCY_OCID,
76
84
  )
77
85
  from ads.model import DataScienceModel
78
- from ads.model.model_metadata import ModelCustomMetadata, ModelCustomMetadataItem
86
+ from ads.model.model_metadata import (
87
+ MetadataCustomCategory,
88
+ ModelCustomMetadata,
89
+ ModelCustomMetadataItem,
90
+ )
79
91
  from ads.telemetry import telemetry
80
92
 
81
93
 
@@ -229,6 +241,12 @@ class AquaModelApp(AquaApp):
229
241
  ModelCustomMetadataFields.DEPLOYMENT_CONTAINER,
230
242
  ModelCustomMetadataItem(key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER),
231
243
  ).value
244
+ inference_container_uri = ds_model.custom_metadata_list.get(
245
+ ModelCustomMetadataFields.DEPLOYMENT_CONTAINER_URI,
246
+ ModelCustomMetadataItem(
247
+ key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER_URI
248
+ ),
249
+ ).value
232
250
  evaluation_container = ds_model.custom_metadata_list.get(
233
251
  ModelCustomMetadataFields.EVALUATION_CONTAINER,
234
252
  ModelCustomMetadataItem(key=ModelCustomMetadataFields.EVALUATION_CONTAINER),
@@ -247,6 +265,7 @@ class AquaModelApp(AquaApp):
247
265
  project_id=ds_model.project_id,
248
266
  model_card=model_card,
249
267
  inference_container=inference_container,
268
+ inference_container_uri=inference_container_uri,
250
269
  finetuning_container=finetuning_container,
251
270
  evaluation_container=evaluation_container,
252
271
  artifact_location=artifact_location,
@@ -323,6 +342,96 @@ class AquaModelApp(AquaApp):
323
342
 
324
343
  return model_details
325
344
 
345
+ @telemetry(entry_point="plugin=model&action=delete", name="aqua")
346
+ def delete_model(self, model_id):
347
+ ds_model = DataScienceModel.from_id(model_id)
348
+ is_registered_model = ds_model.freeform_tags.get(Tags.BASE_MODEL_CUSTOM, None)
349
+ is_fine_tuned_model = ds_model.freeform_tags.get(
350
+ Tags.AQUA_FINE_TUNED_MODEL_TAG, None
351
+ )
352
+ if is_registered_model or is_fine_tuned_model:
353
+ return ds_model.delete()
354
+ else:
355
+ raise AquaRuntimeError(
356
+ f"Failed to delete model:{model_id}. Only registered models or finetuned model can be deleted."
357
+ )
358
+
359
+ @telemetry(entry_point="plugin=model&action=delete", name="aqua")
360
+ def edit_registered_model(self, id, inference_container, enable_finetuning, task):
361
+ """Edits the default config of unverified registered model.
362
+
363
+ Parameters
364
+ ----------
365
+ id: str
366
+ The model OCID.
367
+ inference_container: str.
368
+ The inference container family name
369
+ enable_finetuning: str
370
+ Flag to enable or disable finetuning over the model. Defaults to None
371
+ task:
372
+ The usecase type of the model. e.g , text-generation , text_embedding etc.
373
+
374
+ Returns
375
+ -------
376
+ Model:
377
+ The instance of oci.data_science.models.Model.
378
+
379
+ """
380
+ ds_model = DataScienceModel.from_id(id)
381
+ if ds_model.freeform_tags.get(Tags.BASE_MODEL_CUSTOM, None):
382
+ if ds_model.freeform_tags.get(Tags.AQUA_SERVICE_MODEL_TAG, None):
383
+ raise AquaRuntimeError(
384
+ f"Failed to edit model:{id}. Only registered unverified models can be edited."
385
+ )
386
+ else:
387
+ custom_metadata_list = ds_model.custom_metadata_list
388
+ freeform_tags = ds_model.freeform_tags
389
+ if inference_container:
390
+ custom_metadata_list.add(
391
+ key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER,
392
+ value=inference_container,
393
+ category=MetadataCustomCategory.OTHER,
394
+ description="Deployment container mapping for SMC",
395
+ replace=True,
396
+ )
397
+ if enable_finetuning is not None:
398
+ if enable_finetuning.lower() == "true":
399
+ custom_metadata_list.add(
400
+ key=ModelCustomMetadataFields.FINETUNE_CONTAINER,
401
+ value=FineTuningContainerTypeFamily.AQUA_FINETUNING_CONTAINER_FAMILY,
402
+ category=MetadataCustomCategory.OTHER,
403
+ description="Fine-tuning container mapping for SMC",
404
+ replace=True,
405
+ )
406
+ freeform_tags.update({Tags.READY_TO_FINE_TUNE: "true"})
407
+ elif enable_finetuning.lower() == "false":
408
+ try:
409
+ custom_metadata_list.remove(
410
+ ModelCustomMetadataFields.FINETUNE_CONTAINER
411
+ )
412
+ freeform_tags.pop(Tags.READY_TO_FINE_TUNE)
413
+ except Exception as ex:
414
+ raise AquaRuntimeError(
415
+ f"The given model already doesn't support finetuning: {ex}"
416
+ )
417
+
418
+ custom_metadata_list.remove("modelDescription")
419
+ if task:
420
+ freeform_tags.update({Tags.TASK: task})
421
+ updated_custom_metadata_list = [
422
+ Metadata(**metadata)
423
+ for metadata in custom_metadata_list.to_dict()["data"]
424
+ ]
425
+ update_model_details = UpdateModelDetails(
426
+ custom_metadata_list=updated_custom_metadata_list,
427
+ freeform_tags=freeform_tags,
428
+ )
429
+ AquaApp().update_model(id, update_model_details)
430
+ else:
431
+ raise AquaRuntimeError(
432
+ f"Failed to edit model:{id}. Only registered unverified models can be edited."
433
+ )
434
+
326
435
  def _fetch_metric_from_metadata(
327
436
  self,
328
437
  custom_metadata_list: ModelCustomMetadata,
@@ -619,6 +728,32 @@ class AquaModelApp(AquaApp):
619
728
  }
620
729
  return res
621
730
 
731
+ def clear_model_details_cache(self, model_id):
732
+ """
733
+ Allows user to clear model details cache item
734
+ Returns
735
+ -------
736
+ dict with the key used, and True if cache has the key that needs to be deleted.
737
+ """
738
+ res = {}
739
+ logger.info(f"Clearing _service_model_details_cache for {model_id}")
740
+ with self._cache_lock:
741
+ if model_id in self._service_model_details_cache:
742
+ self._service_model_details_cache.pop(key=model_id)
743
+ res = {"key": {"model_id": model_id}, "cache_deleted": True}
744
+
745
+ return res
746
+
747
+ @staticmethod
748
+ def list_valid_inference_containers():
749
+ containers = list(
750
+ AquaContainerConfig.from_container_index_json(
751
+ config=get_container_config(), enable_spec=True
752
+ ).inference.values()
753
+ )
754
+ family_values = [item.family for item in containers]
755
+ return family_values
756
+
622
757
  def _create_model_catalog_entry(
623
758
  self,
624
759
  os_path: str,
@@ -629,6 +764,7 @@ class AquaModelApp(AquaApp):
629
764
  validation_result: ModelValidationResult,
630
765
  compartment_id: Optional[str],
631
766
  project_id: Optional[str],
767
+ inference_container_uri: Optional[str],
632
768
  ) -> DataScienceModel:
633
769
  """Create model by reference from the object storage path
634
770
 
@@ -640,6 +776,7 @@ class AquaModelApp(AquaApp):
640
776
  verified_model (DataScienceModel): If set, then copies all the tags and custom metadata information from the service verified model
641
777
  compartment_id (Optional[str]): Compartment Id of the compartment where the model has to be created
642
778
  project_id (Optional[str]): Project id of the project where the model has to be created
779
+ inference_container_uri (Optional[str]): Inference container uri for BYOC
643
780
 
644
781
  Returns:
645
782
  DataScienceModel: Returns Datascience model instance.
@@ -685,6 +822,40 @@ class AquaModelApp(AquaApp):
685
822
  raise AquaRuntimeError(
686
823
  f"Require Inference container information. Model: {model_name} does not have associated inference container defaults. Check docs for more information on how to pass inference container."
687
824
  )
825
+ metadata.add(
826
+ key=AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
827
+ value=inference_container,
828
+ description=f"Inference container mapping for {model_name}",
829
+ category="Other",
830
+ )
831
+ if inference_container_uri:
832
+ metadata.add(
833
+ key=AQUA_DEPLOYMENT_CONTAINER_URI_METADATA_NAME,
834
+ value=inference_container_uri,
835
+ description=f"Inference container URI for {model_name}",
836
+ category="Other",
837
+ )
838
+
839
+ inference_containers = (
840
+ AquaContainerConfig.from_container_index_json().inference
841
+ )
842
+ smc_container_set = {
843
+ container.family for container in inference_containers.values()
844
+ }
845
+ # only add cmd vars if inference container is not an SMC
846
+ if (
847
+ inference_container not in smc_container_set
848
+ and inference_container
849
+ == InferenceContainerTypeFamily.AQUA_TEI_CONTAINER_FAMILY
850
+ ):
851
+ cmd_vars = generate_tei_cmd_var(os_path)
852
+ metadata.add(
853
+ key=AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
854
+ value=" ".join(cmd_vars),
855
+ description=f"Inference container cmd vars for {model_name}",
856
+ category="Other",
857
+ )
858
+
688
859
  if finetuning_container:
689
860
  tags[Tags.READY_TO_FINE_TUNE] = "true"
690
861
  metadata.add(
@@ -706,12 +877,6 @@ class AquaModelApp(AquaApp):
706
877
  category="Other",
707
878
  )
708
879
 
709
- metadata.add(
710
- key=AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
711
- value=inference_container,
712
- description=f"Inference container mapping for {model_name}",
713
- category="Other",
714
- )
715
880
  metadata.add(
716
881
  key=AQUA_EVALUATION_CONTAINER_METADATA_NAME,
717
882
  value="odsc-llm-evaluate",
@@ -933,139 +1098,176 @@ class AquaModelApp(AquaApp):
933
1098
  # now as we know that at least one type of model files exist, validate the content of oss path.
934
1099
  # for safetensors, we check if config.json files exist, and for gguf format we check if files with
935
1100
  # gguf extension exist.
936
- for model_format in model_formats:
1101
+ if {ModelFormat.SAFETENSORS, ModelFormat.GGUF}.issubset(set(model_formats)):
937
1102
  if (
938
- model_format == ModelFormat.SAFETENSORS
939
- and len(safetensors_model_files) > 0
1103
+ import_model_details.inference_container.lower()
1104
+ == InferenceContainerTypeFamily.AQUA_LLAMA_CPP_CONTAINER_FAMILY
940
1105
  ):
941
- if import_model_details.download_from_hf:
942
- # validates config.json exists for safetensors model from hugginface
943
- if not hf_download_config_present:
944
- raise AquaRuntimeError(
945
- f"The model {model_name} does not contain {AQUA_MODEL_ARTIFACT_CONFIG} file as required "
946
- f"by {ModelFormat.SAFETENSORS.value} format model."
947
- f" Please check if the model name is correct in Hugging Face repository."
948
- )
949
- else:
950
- try:
951
- model_config = load_config(
952
- file_path=import_model_details.os_path,
953
- config_file_name=AQUA_MODEL_ARTIFACT_CONFIG,
954
- )
955
- except Exception as ex:
956
- logger.error(
957
- f"Exception occurred while loading config file from {import_model_details.os_path}"
958
- f"Exception message: {ex}"
959
- )
960
- raise AquaRuntimeError(
961
- f"The model path {import_model_details.os_path} does not contain the file config.json. "
962
- f"Please check if the path is correct or the model artifacts are available at this location."
963
- ) from ex
964
- else:
965
- try:
966
- metadata_model_type = (
967
- verified_model.custom_metadata_list.get(
968
- AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE
969
- ).value
970
- )
971
- if metadata_model_type:
972
- if (
973
- AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE
974
- in model_config
975
- ):
976
- if (
977
- model_config[
978
- AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE
979
- ]
980
- != metadata_model_type
981
- ):
982
- raise AquaRuntimeError(
983
- f"The {AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE} attribute in {AQUA_MODEL_ARTIFACT_CONFIG}"
984
- f" at {import_model_details.os_path} is invalid, expected {metadata_model_type} for "
985
- f"the model {model_name}. Please check if the path is correct or "
986
- f"the correct model artifacts are available at this location."
987
- f""
988
- )
989
- else:
990
- logger.debug(
991
- f"Could not find {AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE} attribute in "
992
- f"{AQUA_MODEL_ARTIFACT_CONFIG}. Proceeding with model registration."
993
- )
994
- except Exception:
995
- pass
996
- if verified_model:
997
- validation_result.telemetry_model_name = (
998
- verified_model.display_name
999
- )
1000
- elif (
1001
- model_config is not None
1002
- and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME in model_config
1003
- ):
1004
- validation_result.telemetry_model_name = f"{AQUA_MODEL_TYPE_CUSTOM}_{model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME]}"
1005
- elif (
1006
- model_config is not None
1007
- and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE in model_config
1008
- ):
1009
- validation_result.telemetry_model_name = f"{AQUA_MODEL_TYPE_CUSTOM}_{model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE]}"
1106
+ self._validate_gguf_format(
1107
+ import_model_details=import_model_details,
1108
+ verified_model=verified_model,
1109
+ gguf_model_files=gguf_model_files,
1110
+ validation_result=validation_result,
1111
+ model_name=model_name,
1112
+ )
1113
+ else:
1114
+ self._validate_safetensor_format(
1115
+ import_model_details=import_model_details,
1116
+ verified_model=verified_model,
1117
+ validation_result=validation_result,
1118
+ hf_download_config_present=hf_download_config_present,
1119
+ model_name=model_name,
1120
+ )
1121
+ elif ModelFormat.SAFETENSORS in model_formats:
1122
+ self._validate_safetensor_format(
1123
+ import_model_details=import_model_details,
1124
+ verified_model=verified_model,
1125
+ validation_result=validation_result,
1126
+ hf_download_config_present=hf_download_config_present,
1127
+ model_name=model_name,
1128
+ )
1129
+ elif ModelFormat.GGUF in model_formats:
1130
+ self._validate_gguf_format(
1131
+ import_model_details=import_model_details,
1132
+ verified_model=verified_model,
1133
+ gguf_model_files=gguf_model_files,
1134
+ validation_result=validation_result,
1135
+ model_name=model_name,
1136
+ )
1137
+
1138
+ return validation_result
1139
+
1140
+ @staticmethod
1141
+ def _validate_safetensor_format(
1142
+ import_model_details: ImportModelDetails = None,
1143
+ verified_model: DataScienceModel = None,
1144
+ validation_result: ModelValidationResult = None,
1145
+ hf_download_config_present: bool = None,
1146
+ model_name: str = None,
1147
+ ):
1148
+ if import_model_details.download_from_hf:
1149
+ # validates config.json exists for safetensors model from hugginface
1150
+ if not hf_download_config_present:
1151
+ raise AquaRuntimeError(
1152
+ f"The model {model_name} does not contain {AQUA_MODEL_ARTIFACT_CONFIG} file as required "
1153
+ f"by {ModelFormat.SAFETENSORS.value} format model."
1154
+ f" Please check if the model name is correct in Hugging Face repository."
1155
+ )
1156
+ else:
1157
+ try:
1158
+ model_config = load_config(
1159
+ file_path=import_model_details.os_path,
1160
+ config_file_name=AQUA_MODEL_ARTIFACT_CONFIG,
1161
+ )
1162
+ except Exception as ex:
1163
+ logger.error(
1164
+ f"Exception occurred while loading config file from {import_model_details.os_path}"
1165
+ f"Exception message: {ex}"
1166
+ )
1167
+ raise AquaRuntimeError(
1168
+ f"The model path {import_model_details.os_path} does not contain the file config.json. "
1169
+ f"Please check if the path is correct or the model artifacts are available at this location."
1170
+ ) from ex
1171
+ else:
1172
+ try:
1173
+ metadata_model_type = verified_model.custom_metadata_list.get(
1174
+ AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE
1175
+ ).value
1176
+ if metadata_model_type:
1177
+ if AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE in model_config:
1178
+ if (
1179
+ model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE]
1180
+ != metadata_model_type
1181
+ ):
1182
+ raise AquaRuntimeError(
1183
+ f"The {AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE} attribute in {AQUA_MODEL_ARTIFACT_CONFIG}"
1184
+ f" at {import_model_details.os_path} is invalid, expected {metadata_model_type} for "
1185
+ f"the model {model_name}. Please check if the path is correct or "
1186
+ f"the correct model artifacts are available at this location."
1187
+ f""
1188
+ )
1010
1189
  else:
1011
- validation_result.telemetry_model_name = (
1012
- AQUA_MODEL_TYPE_CUSTOM
1190
+ logger.debug(
1191
+ f"Could not find {AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE} attribute in "
1192
+ f"{AQUA_MODEL_ARTIFACT_CONFIG}. Proceeding with model registration."
1013
1193
  )
1014
- elif model_format == ModelFormat.GGUF and len(gguf_model_files) > 0:
1015
- if import_model_details.finetuning_container and not safetensors_model_files:
1016
- raise AquaValueError(
1017
- "Fine-tuning is currently not supported with GGUF model format."
1018
- )
1019
- if verified_model:
1020
- try:
1021
- model_file = verified_model.custom_metadata_list.get(
1022
- AQUA_MODEL_ARTIFACT_FILE
1023
- ).value
1024
- except ValueError as err:
1025
- raise AquaRuntimeError(
1026
- f"The model {verified_model.display_name} does not contain the custom metadata {AQUA_MODEL_ARTIFACT_FILE}. "
1027
- f"Please check if the model has the valid metadata."
1028
- ) from err
1029
- else:
1030
- model_file = import_model_details.model_file
1031
-
1032
- model_files = gguf_model_files
1033
- # todo: have a separate error validation class for different type of error messages.
1034
- if model_file:
1035
- if model_file not in model_files:
1036
- raise AquaRuntimeError(
1037
- f"The model path {import_model_details.os_path} or the Hugging Face "
1038
- f"model repository for {model_name} does not contain the file "
1039
- f"{model_file}. Please check if the path is correct or the model "
1040
- f"artifacts are available at this location."
1041
- )
1042
- else:
1043
- validation_result.model_file = model_file
1044
- elif len(model_files) == 0:
1045
- raise AquaRuntimeError(
1046
- f"The model path {import_model_details.os_path} or the Hugging Face model "
1047
- f"repository for {model_name} does not contain any GGUF format files. "
1048
- f"Please check if the path is correct or the model artifacts are available "
1049
- f"at this location."
1050
- )
1051
- elif len(model_files) > 1:
1052
- raise AquaRuntimeError(
1053
- f"The model path {import_model_details.os_path} or the Hugging Face model "
1054
- f"repository for {model_name} contains multiple GGUF format files. "
1055
- f"Please specify the file that needs to be deployed using the model_file "
1056
- f"parameter."
1057
- )
1058
- else:
1059
- validation_result.model_file = model_files[0]
1060
-
1194
+ except Exception:
1195
+ pass
1061
1196
  if verified_model:
1062
1197
  validation_result.telemetry_model_name = verified_model.display_name
1063
- elif import_model_details.download_from_hf:
1064
- validation_result.telemetry_model_name = model_name
1198
+ elif (
1199
+ model_config is not None
1200
+ and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME in model_config
1201
+ ):
1202
+ validation_result.telemetry_model_name = f"{AQUA_MODEL_TYPE_CUSTOM}_{model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME]}"
1203
+ elif (
1204
+ model_config is not None
1205
+ and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE in model_config
1206
+ ):
1207
+ validation_result.telemetry_model_name = f"{AQUA_MODEL_TYPE_CUSTOM}_{model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE]}"
1065
1208
  else:
1066
1209
  validation_result.telemetry_model_name = AQUA_MODEL_TYPE_CUSTOM
1067
1210
 
1068
- return validation_result
1211
+ @staticmethod
1212
+ def _validate_gguf_format(
1213
+ import_model_details: ImportModelDetails = None,
1214
+ verified_model: DataScienceModel = None,
1215
+ gguf_model_files: List[str] = None,
1216
+ validation_result: ModelValidationResult = None,
1217
+ model_name: str = None,
1218
+ ):
1219
+ if import_model_details.finetuning_container:
1220
+ raise AquaValueError(
1221
+ "Fine-tuning is currently not supported with GGUF model format."
1222
+ )
1223
+ if verified_model:
1224
+ try:
1225
+ model_file = verified_model.custom_metadata_list.get(
1226
+ AQUA_MODEL_ARTIFACT_FILE
1227
+ ).value
1228
+ except ValueError as err:
1229
+ raise AquaRuntimeError(
1230
+ f"The model {verified_model.display_name} does not contain the custom metadata {AQUA_MODEL_ARTIFACT_FILE}. "
1231
+ f"Please check if the model has the valid metadata."
1232
+ ) from err
1233
+ else:
1234
+ model_file = import_model_details.model_file
1235
+
1236
+ model_files = gguf_model_files
1237
+ # todo: have a separate error validation class for different type of error messages.
1238
+ if model_file:
1239
+ if model_file not in model_files:
1240
+ raise AquaRuntimeError(
1241
+ f"The model path {import_model_details.os_path} or the Hugging Face "
1242
+ f"model repository for {model_name} does not contain the file "
1243
+ f"{model_file}. Please check if the path is correct or the model "
1244
+ f"artifacts are available at this location."
1245
+ )
1246
+ else:
1247
+ validation_result.model_file = model_file
1248
+ elif len(model_files) == 0:
1249
+ raise AquaRuntimeError(
1250
+ f"The model path {import_model_details.os_path} or the Hugging Face model "
1251
+ f"repository for {model_name} does not contain any GGUF format files. "
1252
+ f"Please check if the path is correct or the model artifacts are available "
1253
+ f"at this location."
1254
+ )
1255
+ elif len(model_files) > 1:
1256
+ raise AquaRuntimeError(
1257
+ f"The model path {import_model_details.os_path} or the Hugging Face model "
1258
+ f"repository for {model_name} contains multiple GGUF format files. "
1259
+ f"Please specify the file that needs to be deployed using the model_file "
1260
+ f"parameter."
1261
+ )
1262
+ else:
1263
+ validation_result.model_file = model_files[0]
1264
+
1265
+ if verified_model:
1266
+ validation_result.telemetry_model_name = verified_model.display_name
1267
+ elif import_model_details.download_from_hf:
1268
+ validation_result.telemetry_model_name = model_name
1269
+ else:
1270
+ validation_result.telemetry_model_name = AQUA_MODEL_TYPE_CUSTOM
1069
1271
 
1070
1272
  @staticmethod
1071
1273
  def _download_model_from_hf(
@@ -1193,21 +1395,28 @@ class AquaModelApp(AquaApp):
1193
1395
  validation_result=validation_result,
1194
1396
  compartment_id=import_model_details.compartment_id,
1195
1397
  project_id=import_model_details.project_id,
1398
+ inference_container_uri=import_model_details.inference_container_uri,
1196
1399
  )
1197
1400
  # registered model will always have inference and evaluation container, but
1198
1401
  # fine-tuning container may be not set
1199
1402
  inference_container = ds_model.custom_metadata_list.get(
1200
- ModelCustomMetadataFields.DEPLOYMENT_CONTAINER
1403
+ ModelCustomMetadataFields.DEPLOYMENT_CONTAINER,
1404
+ ModelCustomMetadataItem(key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER),
1405
+ ).value
1406
+ inference_container_uri = ds_model.custom_metadata_list.get(
1407
+ ModelCustomMetadataFields.DEPLOYMENT_CONTAINER_URI,
1408
+ ModelCustomMetadataItem(
1409
+ key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER_URI
1410
+ ),
1201
1411
  ).value
1202
1412
  evaluation_container = ds_model.custom_metadata_list.get(
1203
1413
  ModelCustomMetadataFields.EVALUATION_CONTAINER,
1414
+ ModelCustomMetadataItem(key=ModelCustomMetadataFields.EVALUATION_CONTAINER),
1415
+ ).value
1416
+ finetuning_container: str = ds_model.custom_metadata_list.get(
1417
+ ModelCustomMetadataFields.FINETUNE_CONTAINER,
1418
+ ModelCustomMetadataItem(key=ModelCustomMetadataFields.FINETUNE_CONTAINER),
1204
1419
  ).value
1205
- try:
1206
- finetuning_container = ds_model.custom_metadata_list.get(
1207
- ModelCustomMetadataFields.FINETUNE_CONTAINER,
1208
- ).value
1209
- except Exception:
1210
- finetuning_container = None
1211
1420
 
1212
1421
  aqua_model_attributes = dict(
1213
1422
  **self._process_model(ds_model, self.region),
@@ -1219,6 +1428,7 @@ class AquaModelApp(AquaApp):
1219
1428
  )
1220
1429
  ),
1221
1430
  inference_container=inference_container,
1431
+ inference_container_uri=inference_container_uri,
1222
1432
  finetuning_container=finetuning_container,
1223
1433
  evaluation_container=evaluation_container,
1224
1434
  artifact_location=artifact_path,