oracle-ads 2.12.11__py3-none-any.whl → 2.13.1__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 (83) hide show
  1. ads/aqua/__init__.py +7 -1
  2. ads/aqua/app.py +41 -27
  3. ads/aqua/client/client.py +48 -11
  4. ads/aqua/common/entities.py +28 -1
  5. ads/aqua/common/enums.py +32 -21
  6. ads/aqua/common/errors.py +3 -4
  7. ads/aqua/common/utils.py +10 -15
  8. ads/aqua/config/container_config.py +203 -0
  9. ads/aqua/config/evaluation/evaluation_service_config.py +5 -181
  10. ads/aqua/constants.py +1 -1
  11. ads/aqua/evaluation/constants.py +7 -7
  12. ads/aqua/evaluation/errors.py +3 -4
  13. ads/aqua/evaluation/evaluation.py +4 -4
  14. ads/aqua/extension/base_handler.py +4 -0
  15. ads/aqua/extension/model_handler.py +41 -27
  16. ads/aqua/extension/models/ws_models.py +5 -6
  17. ads/aqua/finetuning/constants.py +3 -3
  18. ads/aqua/finetuning/finetuning.py +2 -3
  19. ads/aqua/model/constants.py +7 -7
  20. ads/aqua/model/entities.py +2 -3
  21. ads/aqua/model/enums.py +4 -5
  22. ads/aqua/model/model.py +46 -29
  23. ads/aqua/modeldeployment/deployment.py +6 -14
  24. ads/aqua/modeldeployment/entities.py +5 -3
  25. ads/aqua/server/__init__.py +4 -0
  26. ads/aqua/server/__main__.py +24 -0
  27. ads/aqua/server/app.py +47 -0
  28. ads/aqua/server/aqua_spec.yml +1291 -0
  29. ads/aqua/ui.py +5 -199
  30. ads/common/auth.py +50 -28
  31. ads/common/extended_enum.py +52 -44
  32. ads/common/utils.py +91 -11
  33. ads/config.py +3 -0
  34. ads/llm/__init__.py +12 -8
  35. ads/llm/langchain/plugins/embeddings/__init__.py +4 -0
  36. ads/llm/langchain/plugins/embeddings/oci_data_science_model_deployment_endpoint.py +184 -0
  37. ads/llm/langchain/plugins/llms/oci_data_science_model_deployment_endpoint.py +32 -23
  38. ads/model/artifact_downloader.py +6 -4
  39. ads/model/common/utils.py +15 -3
  40. ads/model/datascience_model.py +422 -71
  41. ads/model/generic_model.py +3 -3
  42. ads/model/model_metadata.py +70 -24
  43. ads/model/model_version_set.py +5 -3
  44. ads/model/service/oci_datascience_model.py +487 -17
  45. ads/opctl/anomaly_detection.py +11 -0
  46. ads/opctl/backend/marketplace/helm_helper.py +13 -14
  47. ads/opctl/cli.py +4 -5
  48. ads/opctl/cmds.py +28 -32
  49. ads/opctl/config/merger.py +8 -11
  50. ads/opctl/config/resolver.py +25 -30
  51. ads/opctl/forecast.py +11 -0
  52. ads/opctl/operator/cli.py +9 -9
  53. ads/opctl/operator/common/backend_factory.py +56 -60
  54. ads/opctl/operator/common/const.py +5 -5
  55. ads/opctl/operator/common/utils.py +16 -0
  56. ads/opctl/operator/lowcode/anomaly/const.py +8 -9
  57. ads/opctl/operator/lowcode/common/data.py +5 -2
  58. ads/opctl/operator/lowcode/common/transformations.py +2 -12
  59. ads/opctl/operator/lowcode/feature_store_marketplace/operator_utils.py +43 -48
  60. ads/opctl/operator/lowcode/forecast/__main__.py +5 -5
  61. ads/opctl/operator/lowcode/forecast/const.py +6 -6
  62. ads/opctl/operator/lowcode/forecast/model/arima.py +6 -3
  63. ads/opctl/operator/lowcode/forecast/model/automlx.py +61 -31
  64. ads/opctl/operator/lowcode/forecast/model/base_model.py +66 -40
  65. ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py +79 -13
  66. ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +5 -2
  67. ads/opctl/operator/lowcode/forecast/model/prophet.py +28 -15
  68. ads/opctl/operator/lowcode/forecast/model_evaluator.py +13 -15
  69. ads/opctl/operator/lowcode/forecast/schema.yaml +1 -1
  70. ads/opctl/operator/lowcode/forecast/whatifserve/deployment_manager.py +7 -0
  71. ads/opctl/operator/lowcode/forecast/whatifserve/score.py +19 -11
  72. ads/opctl/operator/lowcode/pii/constant.py +6 -7
  73. ads/opctl/operator/lowcode/recommender/constant.py +12 -7
  74. ads/opctl/operator/runtime/marketplace_runtime.py +4 -10
  75. ads/opctl/operator/runtime/runtime.py +4 -6
  76. ads/pipeline/ads_pipeline_run.py +13 -25
  77. ads/pipeline/visualizer/graph_renderer.py +3 -4
  78. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1.dist-info}/METADATA +18 -15
  79. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1.dist-info}/RECORD +82 -74
  80. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1.dist-info}/WHEEL +1 -1
  81. ads/aqua/config/evaluation/evaluation_service_model_config.py +0 -8
  82. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1.dist-info}/entry_points.txt +0 -0
  83. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1.dist-info/licenses}/LICENSE.txt +0 -0
@@ -1,20 +1,19 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*--
3
2
 
4
- # Copyright (c) 2024 Oracle and/or its affiliates.
3
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
5
4
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6
5
 
7
6
  from dataclasses import dataclass
8
7
  from typing import List, Optional
9
8
 
10
- from ads.aqua.evaluation.entities import AquaEvaluationSummary, AquaEvaluationDetail
11
- from ads.aqua.model.entities import AquaModelSummary, AquaModel
9
+ from ads.aqua.evaluation.entities import AquaEvaluationDetail, AquaEvaluationSummary
10
+ from ads.aqua.model.entities import AquaModel, AquaModelSummary
12
11
  from ads.aqua.modeldeployment.entities import AquaDeployment, AquaDeploymentDetail
13
- from ads.common.extended_enum import ExtendedEnumMeta
12
+ from ads.common.extended_enum import ExtendedEnum
14
13
  from ads.common.serializer import DataClassSerializable
15
14
 
16
15
 
17
- class RequestResponseType(str, metaclass=ExtendedEnumMeta):
16
+ class RequestResponseType(ExtendedEnum):
18
17
  ListEvaluations = "ListEvaluations"
19
18
  EvaluationDetails = "EvaluationDetails"
20
19
  ListDeployments = "ListDeployments"
@@ -2,10 +2,10 @@
2
2
  # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
3
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4
4
 
5
- from ads.common.extended_enum import ExtendedEnumMeta
5
+ from ads.common.extended_enum import ExtendedEnum
6
6
 
7
7
 
8
- class FineTuneCustomMetadata(str, metaclass=ExtendedEnumMeta):
8
+ class FineTuneCustomMetadata(ExtendedEnum):
9
9
  FINE_TUNE_SOURCE = "fine_tune_source"
10
10
  FINE_TUNE_SOURCE_NAME = "fine_tune_source_name"
11
11
  FINE_TUNE_OUTPUT_PATH = "fine_tune_output_path"
@@ -16,7 +16,7 @@ class FineTuneCustomMetadata(str, metaclass=ExtendedEnumMeta):
16
16
  SERVICE_MODEL_FINE_TUNE_CONTAINER = "finetune-container"
17
17
 
18
18
 
19
- class FineTuningRestrictedParams(str, metaclass=ExtendedEnumMeta):
19
+ class FineTuningRestrictedParams(ExtendedEnum):
20
20
  OPTIMIZER = "optimizer"
21
21
 
22
22
 
@@ -30,7 +30,6 @@ from ads.aqua.constants import (
30
30
  DEFAULT_FT_REPLICA,
31
31
  DEFAULT_FT_VALIDATION_SET_SIZE,
32
32
  JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING,
33
- UNKNOWN,
34
33
  UNKNOWN_DICT,
35
34
  )
36
35
  from ads.aqua.data import AquaResourceIdentifier
@@ -45,7 +44,7 @@ from ads.aqua.finetuning.entities import (
45
44
  )
46
45
  from ads.common.auth import default_signer
47
46
  from ads.common.object_storage_details import ObjectStorageDetails
48
- from ads.common.utils import get_console_link
47
+ from ads.common.utils import UNKNOWN, get_console_link
49
48
  from ads.config import (
50
49
  AQUA_FINETUNING_CONTAINER_OVERRIDE_FLAG_METADATA_NAME,
51
50
  AQUA_JOB_SUBNET_ID,
@@ -592,7 +591,7 @@ class AquaFineTuningApp(AquaApp):
592
591
  Dict:
593
592
  A dict of allowed finetuning configs.
594
593
  """
595
- config = self.get_config(model_id, AQUA_MODEL_FINETUNING_CONFIG)
594
+ config = self.get_config(model_id, AQUA_MODEL_FINETUNING_CONFIG).config
596
595
  if not config:
597
596
  logger.debug(
598
597
  f"Fine-tuning config for custom model: {model_id} is not available. Use defaults."
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python
2
- # Copyright (c) 2024 Oracle and/or its affiliates.
2
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
3
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4
4
 
5
5
  """
@@ -9,10 +9,10 @@ aqua.model.constants
9
9
  This module contains constants/enums used in Aqua Model.
10
10
  """
11
11
 
12
- from ads.common.extended_enum import ExtendedEnumMeta
12
+ from ads.common.extended_enum import ExtendedEnum
13
13
 
14
14
 
15
- class ModelCustomMetadataFields(str, metaclass=ExtendedEnumMeta):
15
+ class ModelCustomMetadataFields(ExtendedEnum):
16
16
  ARTIFACT_LOCATION = "artifact_location"
17
17
  DEPLOYMENT_CONTAINER = "deployment-container"
18
18
  EVALUATION_CONTAINER = "evaluation-container"
@@ -20,24 +20,24 @@ class ModelCustomMetadataFields(str, metaclass=ExtendedEnumMeta):
20
20
  DEPLOYMENT_CONTAINER_URI = "deployment-container-uri"
21
21
 
22
22
 
23
- class ModelTask(str, metaclass=ExtendedEnumMeta):
23
+ class ModelTask(ExtendedEnum):
24
24
  TEXT_GENERATION = "text-generation"
25
25
  IMAGE_TEXT_TO_TEXT = "image-text-to-text"
26
26
  IMAGE_TO_TEXT = "image-to-text"
27
27
 
28
28
 
29
- class FineTuningMetricCategories(str, metaclass=ExtendedEnumMeta):
29
+ class FineTuningMetricCategories(ExtendedEnum):
30
30
  VALIDATION = "validation"
31
31
  TRAINING = "training"
32
32
 
33
33
 
34
- class ModelType(str, metaclass=ExtendedEnumMeta):
34
+ class ModelType(ExtendedEnum):
35
35
  FT = "FT" # Fine Tuned Model
36
36
  BASE = "BASE" # Base model
37
37
 
38
38
 
39
39
  # TODO: merge metadata key used in create FT
40
- class FineTuningCustomMetadata(str, metaclass=ExtendedEnumMeta):
40
+ class FineTuningCustomMetadata(ExtendedEnum):
41
41
  FT_SOURCE = "fine_tune_source"
42
42
  FT_SOURCE_NAME = "fine_tune_source_name"
43
43
  FT_OUTPUT_PATH = "fine_tune_output_path"
@@ -23,7 +23,6 @@ from ads.aqua.constants import LIFECYCLE_DETAILS_MISSING_JOBRUN, UNKNOWN_VALUE
23
23
  from ads.aqua.data import AquaResourceIdentifier
24
24
  from ads.aqua.model.enums import FineTuningDefinedMetadata
25
25
  from ads.aqua.training.exceptions import exit_code_dict
26
- from ads.aqua.ui import ModelFormat
27
26
  from ads.common.serializer import DataClassSerializable
28
27
  from ads.common.utils import get_log_links
29
28
  from ads.model.datascience_model import DataScienceModel
@@ -46,7 +45,7 @@ class AquaFineTuneValidation(DataClassSerializable):
46
45
  @dataclass(repr=False)
47
46
  class ModelValidationResult:
48
47
  model_file: Optional[str] = None
49
- model_formats: List[ModelFormat] = field(default_factory=list)
48
+ model_formats: List[str] = field(default_factory=list)
50
49
  telemetry_model_name: str = None
51
50
  tags: Optional[dict] = None
52
51
 
@@ -89,7 +88,7 @@ class AquaModelSummary(DataClassSerializable):
89
88
  nvidia_gpu_supported: bool = False
90
89
  arm_cpu_supported: bool = False
91
90
  model_file: Optional[str] = None
92
- model_formats: List[ModelFormat] = field(default_factory=list)
91
+ model_formats: List[str] = field(default_factory=list)
93
92
 
94
93
 
95
94
  @dataclass(repr=False)
ads/aqua/model/enums.py CHANGED
@@ -1,18 +1,17 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # Copyright (c) 2024 Oracle and/or its affiliates.
2
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
4
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
- from ads.common.extended_enum import ExtendedEnumMeta
4
+ from ads.common.extended_enum import ExtendedEnum
6
5
 
7
6
 
8
- class FineTuningDefinedMetadata(str, metaclass=ExtendedEnumMeta):
7
+ class FineTuningDefinedMetadata(ExtendedEnum):
9
8
  """Represents the defined metadata keys used in Fine Tuning."""
10
9
 
11
10
  VAL_SET_SIZE = "val_set_size"
12
11
  TRAINING_DATA = "training_data"
13
12
 
14
13
 
15
- class FineTuningCustomMetadata(str, metaclass=ExtendedEnumMeta):
14
+ class FineTuningCustomMetadata(ExtendedEnum):
16
15
  """Represents the custom metadata keys used in Fine Tuning."""
17
16
 
18
17
  FT_SOURCE = "fine_tune_source"
ads/aqua/model/model.py CHANGED
@@ -15,9 +15,12 @@ from oci.data_science.models import JobRun, Metadata, Model, UpdateModelDetails
15
15
  from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID, logger
16
16
  from ads.aqua.app import AquaApp
17
17
  from ads.aqua.common.enums import (
18
+ ConfigFolder,
18
19
  CustomInferenceContainerTypeFamily,
19
20
  FineTuningContainerTypeFamily,
20
21
  InferenceContainerTypeFamily,
22
+ ModelFormat,
23
+ Platform,
21
24
  Tags,
22
25
  )
23
26
  from ads.aqua.common.errors import (
@@ -39,11 +42,13 @@ from ads.aqua.common.utils import (
39
42
  read_file,
40
43
  upload_folder,
41
44
  )
45
+ from ads.aqua.config.container_config import AquaContainerConfig
42
46
  from ads.aqua.constants import (
43
47
  AQUA_MODEL_ARTIFACT_CONFIG,
44
48
  AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME,
45
49
  AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE,
46
50
  AQUA_MODEL_ARTIFACT_FILE,
51
+ AQUA_MODEL_TOKENIZER_CONFIG,
47
52
  AQUA_MODEL_TYPE_CUSTOM,
48
53
  HF_METADATA_FOLDER,
49
54
  LICENSE_TXT,
@@ -54,7 +59,6 @@ from ads.aqua.constants import (
54
59
  READY_TO_IMPORT_STATUS,
55
60
  TRAINING_METRICS_FINAL,
56
61
  TRINING_METRICS,
57
- UNKNOWN,
58
62
  VALIDATION_METRICS,
59
63
  VALIDATION_METRICS_FINAL,
60
64
  )
@@ -71,13 +75,11 @@ from ads.aqua.model.entities import (
71
75
  AquaModelLicense,
72
76
  AquaModelSummary,
73
77
  ImportModelDetails,
74
- ModelFormat,
75
78
  ModelValidationResult,
76
79
  )
77
- from ads.aqua.ui import AquaContainerConfig, AquaContainerConfigItem
78
80
  from ads.common.auth import default_signer
79
81
  from ads.common.oci_resource import SEARCH_TYPE, OCIResource
80
- from ads.common.utils import get_console_link
82
+ from ads.common.utils import UNKNOWN, get_console_link
81
83
  from ads.config import (
82
84
  AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
83
85
  AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
@@ -568,6 +570,26 @@ class AquaModelApp(AquaApp):
568
570
  training_final,
569
571
  ]
570
572
 
573
+ def get_hf_tokenizer_config(self, model_id):
574
+ """Gets the default chat template for the given Aqua model.
575
+
576
+ Parameters
577
+ ----------
578
+ model_id: str
579
+ The OCID of the Aqua model.
580
+
581
+ Returns
582
+ -------
583
+ str:
584
+ Chat template string.
585
+ """
586
+ config = self.get_config(
587
+ model_id, AQUA_MODEL_TOKENIZER_CONFIG, ConfigFolder.ARTIFACT
588
+ ).config
589
+ if not config:
590
+ logger.debug(f"Tokenizer config for model: {model_id} is not available.")
591
+ return config
592
+
571
593
  @staticmethod
572
594
  def to_aqua_model(
573
595
  model: Union[
@@ -645,28 +667,24 @@ class AquaModelApp(AquaApp):
645
667
  except Exception:
646
668
  model_file = UNKNOWN
647
669
 
648
- inference_containers = AquaContainerConfig.from_container_index_json().inference
670
+ inference_containers = AquaContainerConfig.from_container_index_json(
671
+ config=get_container_config()
672
+ ).inference
649
673
 
650
674
  model_formats_str = freeform_tags.get(
651
- Tags.MODEL_FORMAT, ModelFormat.SAFETENSORS.value
675
+ Tags.MODEL_FORMAT, ModelFormat.SAFETENSORS
652
676
  ).upper()
653
- model_formats = [
654
- ModelFormat[model_format] for model_format in model_formats_str.split(",")
655
- ]
677
+ model_formats = model_formats_str.split(",")
656
678
 
657
- supported_platform: Set[AquaContainerConfigItem.Platform] = set()
679
+ supported_platform: Set[str] = set()
658
680
 
659
681
  for container in inference_containers.values():
660
682
  for model_format in model_formats:
661
683
  if model_format in container.model_formats:
662
684
  supported_platform.update(container.platforms)
663
685
 
664
- nvidia_gpu_supported = (
665
- AquaContainerConfigItem.Platform.NVIDIA_GPU in supported_platform
666
- )
667
- arm_cpu_supported = (
668
- AquaContainerConfigItem.Platform.ARM_CPU in supported_platform
669
- )
686
+ nvidia_gpu_supported = Platform.NVIDIA_GPU in supported_platform
687
+ arm_cpu_supported = Platform.ARM_CPU in supported_platform
670
688
 
671
689
  return {
672
690
  "compartment_id": model.compartment_id,
@@ -876,8 +894,7 @@ class AquaModelApp(AquaApp):
876
894
  tags.update(
877
895
  {
878
896
  Tags.MODEL_FORMAT: ",".join(
879
- model_format.value
880
- for model_format in validation_result.model_formats
897
+ model_format for model_format in validation_result.model_formats
881
898
  )
882
899
  }
883
900
  )
@@ -914,9 +931,9 @@ class AquaModelApp(AquaApp):
914
931
  category="Other",
915
932
  )
916
933
 
917
- inference_containers = (
918
- AquaContainerConfig.from_container_index_json().inference
919
- )
934
+ inference_containers = AquaContainerConfig.from_container_index_json(
935
+ config=get_container_config()
936
+ ).inference
920
937
  smc_container_set = {
921
938
  container.family for container in inference_containers.values()
922
939
  }
@@ -991,13 +1008,13 @@ class AquaModelApp(AquaApp):
991
1008
  return model
992
1009
 
993
1010
  @staticmethod
994
- def get_model_files(os_path: str, model_format: ModelFormat) -> List[str]:
1011
+ def get_model_files(os_path: str, model_format: str) -> List[str]:
995
1012
  """
996
1013
  Get a list of model files based on the given OS path and model format.
997
1014
 
998
1015
  Args:
999
1016
  os_path (str): The OS path where the model files are located.
1000
- model_format (ModelFormat): The format of the model files.
1017
+ model_format (str): The format of the model files.
1001
1018
 
1002
1019
  Returns:
1003
1020
  List[str]: A list of model file names.
@@ -1037,13 +1054,13 @@ class AquaModelApp(AquaApp):
1037
1054
  return model_files
1038
1055
 
1039
1056
  @staticmethod
1040
- def get_hf_model_files(model_name: str, model_format: ModelFormat) -> List[str]:
1057
+ def get_hf_model_files(model_name: str, model_format: str) -> List[str]:
1041
1058
  """
1042
1059
  Get a list of model files based on the given OS path and model format.
1043
1060
 
1044
1061
  Args:
1045
1062
  model_name (str): The huggingface model name.
1046
- model_format (ModelFormat): The format of the model files.
1063
+ model_format (str): The format of the model files.
1047
1064
 
1048
1065
  Returns:
1049
1066
  List[str]: A list of model file names.
@@ -1075,7 +1092,7 @@ class AquaModelApp(AquaApp):
1075
1092
  and model_sibling.rfilename == AQUA_MODEL_ARTIFACT_CONFIG
1076
1093
  ):
1077
1094
  model_files.append(model_sibling.rfilename)
1078
- if extension == model_format.value:
1095
+ if extension == model_format:
1079
1096
  model_files.append(model_sibling.rfilename)
1080
1097
 
1081
1098
  logger.debug(
@@ -1130,8 +1147,8 @@ class AquaModelApp(AquaApp):
1130
1147
 
1131
1148
  if not (safetensors_model_files or gguf_model_files):
1132
1149
  raise AquaRuntimeError(
1133
- f"The model {model_name} does not contain either {ModelFormat.SAFETENSORS.value} "
1134
- f"or {ModelFormat.GGUF.value} files in {import_model_details.os_path} or Hugging Face repository. "
1150
+ f"The model {model_name} does not contain either {ModelFormat.SAFETENSORS} "
1151
+ f"or {ModelFormat.GGUF} files in {import_model_details.os_path} or Hugging Face repository. "
1135
1152
  f"Please check if the path is correct or the model artifacts are available at this location."
1136
1153
  )
1137
1154
 
@@ -1239,7 +1256,7 @@ class AquaModelApp(AquaApp):
1239
1256
  ):
1240
1257
  raise AquaRuntimeError(
1241
1258
  f"The model {model_name} does not contain {AQUA_MODEL_ARTIFACT_CONFIG} file as required "
1242
- f"by {ModelFormat.SAFETENSORS.value} format model."
1259
+ f"by {ModelFormat.SAFETENSORS} format model."
1243
1260
  f" Please check if the model name is correct in Hugging Face repository."
1244
1261
  )
1245
1262
  validation_result.telemetry_model_name = model_name
@@ -7,10 +7,7 @@ from typing import Dict, List, Optional, Union
7
7
 
8
8
  from ads.aqua.app import AquaApp, logger
9
9
  from ads.aqua.common.entities import ContainerSpec
10
- from ads.aqua.common.enums import (
11
- InferenceContainerTypeFamily,
12
- Tags,
13
- )
10
+ from ads.aqua.common.enums import InferenceContainerTypeFamily, ModelFormat, Tags
14
11
  from ads.aqua.common.errors import AquaRuntimeError, AquaValueError
15
12
  from ads.aqua.common.utils import (
16
13
  get_combined_params,
@@ -30,19 +27,14 @@ from ads.aqua.constants import (
30
27
  AQUA_MODEL_TYPE_CUSTOM,
31
28
  AQUA_MODEL_TYPE_SERVICE,
32
29
  MODEL_BY_REFERENCE_OSS_PATH_KEY,
33
- UNKNOWN,
34
30
  UNKNOWN_DICT,
35
31
  )
36
32
  from ads.aqua.data import AquaResourceIdentifier
37
33
  from ads.aqua.finetuning.finetuning import FineTuneCustomMetadata
38
34
  from ads.aqua.model import AquaModelApp
39
- from ads.aqua.modeldeployment.entities import (
40
- AquaDeployment,
41
- AquaDeploymentDetail,
42
- )
43
- from ads.aqua.ui import ModelFormat
35
+ from ads.aqua.modeldeployment.entities import AquaDeployment, AquaDeploymentDetail
44
36
  from ads.common.object_storage_details import ObjectStorageDetails
45
- from ads.common.utils import get_log_links
37
+ from ads.common.utils import UNKNOWN, get_log_links
46
38
  from ads.config import (
47
39
  AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
48
40
  AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
@@ -293,13 +285,13 @@ class AquaDeploymentApp(AquaApp):
293
285
  )
294
286
 
295
287
  model_formats_str = aqua_model.freeform_tags.get(
296
- Tags.MODEL_FORMAT, ModelFormat.SAFETENSORS.value
288
+ Tags.MODEL_FORMAT, ModelFormat.SAFETENSORS
297
289
  ).upper()
298
290
  model_format = model_formats_str.split(",")
299
291
 
300
292
  # Figure out a better way to handle this in future release
301
293
  if (
302
- ModelFormat.GGUF.value in model_format
294
+ ModelFormat.GGUF in model_format
303
295
  and container_type_key.lower()
304
296
  == InferenceContainerTypeFamily.AQUA_LLAMA_CPP_CONTAINER_FAMILY
305
297
  ):
@@ -661,7 +653,7 @@ class AquaDeploymentApp(AquaApp):
661
653
  Dict:
662
654
  A dict of allowed deployment configs.
663
655
  """
664
- config = self.get_config(model_id, AQUA_MODEL_DEPLOYMENT_CONFIG)
656
+ config = self.get_config(model_id, AQUA_MODEL_DEPLOYMENT_CONFIG).config
665
657
  if not config:
666
658
  logger.debug(
667
659
  f"Deployment config for custom model: {model_id} is not available. Use defaults."
@@ -11,10 +11,10 @@ from oci.data_science.models import (
11
11
  )
12
12
 
13
13
  from ads.aqua.common.enums import Tags
14
- from ads.aqua.constants import UNKNOWN, UNKNOWN_DICT
14
+ from ads.aqua.constants import UNKNOWN_DICT
15
15
  from ads.aqua.data import AquaResourceIdentifier
16
16
  from ads.common.serializer import DataClassSerializable
17
- from ads.common.utils import get_console_link
17
+ from ads.common.utils import UNKNOWN, get_console_link
18
18
 
19
19
 
20
20
  @dataclass
@@ -41,6 +41,7 @@ class AquaDeployment(DataClassSerializable):
41
41
  id: str = None
42
42
  display_name: str = None
43
43
  aqua_service_model: bool = None
44
+ model_id: str = None
44
45
  aqua_model_name: str = None
45
46
  state: str = None
46
47
  description: str = None
@@ -97,7 +98,7 @@ class AquaDeployment(DataClassSerializable):
97
98
  else None
98
99
  ),
99
100
  )
100
-
101
+ model_id = oci_model_deployment._model_deployment_configuration_details.model_configuration_details.model_id
101
102
  tags = {}
102
103
  tags.update(oci_model_deployment.freeform_tags or UNKNOWN_DICT)
103
104
  tags.update(oci_model_deployment.defined_tags or UNKNOWN_DICT)
@@ -110,6 +111,7 @@ class AquaDeployment(DataClassSerializable):
110
111
 
111
112
  return AquaDeployment(
112
113
  id=oci_model_deployment.id,
114
+ model_id=model_id,
113
115
  display_name=oci_model_deployment.display_name,
114
116
  aqua_service_model=aqua_service_model_tag is not None,
115
117
  aqua_model_name=aqua_model_name,
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) 2025 Oracle and/or its affiliates.
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) 2025 Oracle and/or its affiliates.
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
+
6
+ import os
7
+ from logging import getLogger
8
+
9
+ from dotenv import load_dotenv
10
+
11
+ from ads.aqua.server.app import start_server
12
+
13
+ logger = getLogger(__name__)
14
+ config_location = os.path.join(os.getcwd(), ".env")
15
+ if os.path.exists(config_location):
16
+ logger.info(f"Loading environment variables from {config_location}")
17
+ load_dotenv(dotenv_path=config_location)
18
+ logger.info("Environment variables loaded successfully")
19
+ else:
20
+ logger.warning(
21
+ f"{config_location} not found. Consider using `.env` file to setup default environment variables"
22
+ )
23
+
24
+ start_server()
ads/aqua/server/app.py ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) 2025 Oracle and/or its affiliates.
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
+
6
+ import os
7
+ from logging import getLogger
8
+
9
+ import tornado.ioloop
10
+ import tornado.web
11
+
12
+ from ads.aqua.extension import __handlers__
13
+
14
+ logger = getLogger(__name__)
15
+ AQUA_PORT = "AQUA_PORT"
16
+ AQUA_HOST = "AQUA_HOST"
17
+ AQUA_PROCESS_COUNT = "AQUA_PROCESS_COUNT"
18
+ AQUA_CORS_ENABLE = "AQUA_CORS_ENABLE"
19
+
20
+ URL_PATTERN = r"/aqua/"
21
+
22
+
23
+ def prepare(self):
24
+ self.set_header("Access-Control-Allow-Origin", "*")
25
+
26
+
27
+ def make_app():
28
+ # Patch the prepare method to allow CORS request
29
+ if os.environ.get(AQUA_CORS_ENABLE, "0") == "1":
30
+ for _, handler in __handlers__:
31
+ handler.prepare = prepare
32
+ handlers = [(URL_PATTERN + url, handler) for url, handler in __handlers__]
33
+ # logger.debug(handlers)
34
+ return tornado.web.Application(handlers)
35
+
36
+
37
+ def start_server():
38
+ app = make_app()
39
+ server = tornado.httpserver.HTTPServer(app)
40
+ port = int(os.environ.get(AQUA_PORT, 8080))
41
+ host = os.environ.get(AQUA_HOST, "0.0.0.0")
42
+ processes = int(os.environ.get(AQUA_PROCESS_COUNT, 0))
43
+ server.bind(port=port, address=host)
44
+ server.start(processes)
45
+ logger.info(f"Starting the server from directory: {os.getcwd()}")
46
+ logger.info(f"Aqua API server running on http://{host}:{port}")
47
+ tornado.ioloop.IOLoop.current().start()