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
ads/aqua/__init__.py CHANGED
@@ -7,7 +7,13 @@ import os
7
7
  from logging import getLogger
8
8
 
9
9
  from ads import logger, set_auth
10
- from ads.aqua.client.client import AsyncClient, Client
10
+ from ads.aqua.client.client import (
11
+ AsyncClient,
12
+ Client,
13
+ HttpxOCIAuth,
14
+ get_async_httpx_client,
15
+ get_httpx_client,
16
+ )
11
17
  from ads.aqua.common.utils import fetch_service_compartment
12
18
  from ads.config import OCI_RESOURCE_PRINCIPAL_VERSION
13
19
 
ads/aqua/app.py CHANGED
@@ -6,14 +6,15 @@ import json
6
6
  import os
7
7
  import traceback
8
8
  from dataclasses import fields
9
- from typing import Dict, Union
9
+ from typing import Any, Dict, Optional, Union
10
10
 
11
11
  import oci
12
12
  from oci.data_science.models import UpdateModelDetails, UpdateModelProvenanceDetails
13
13
 
14
14
  from ads import set_auth
15
15
  from ads.aqua import logger
16
- from ads.aqua.common.enums import Tags
16
+ from ads.aqua.common.entities import ModelConfigResult
17
+ from ads.aqua.common.enums import ConfigFolder, Tags
17
18
  from ads.aqua.common.errors import AquaRuntimeError, AquaValueError
18
19
  from ads.aqua.common.utils import (
19
20
  _is_valid_mvs,
@@ -21,10 +22,9 @@ from ads.aqua.common.utils import (
21
22
  is_valid_ocid,
22
23
  load_config,
23
24
  )
24
- from ads.aqua.constants import UNKNOWN
25
25
  from ads.common import oci_client as oc
26
26
  from ads.common.auth import default_signer
27
- from ads.common.utils import extract_region, is_path_exists
27
+ from ads.common.utils import UNKNOWN, extract_region, is_path_exists
28
28
  from ads.config import (
29
29
  AQUA_TELEMETRY_BUCKET,
30
30
  AQUA_TELEMETRY_BUCKET_NS,
@@ -268,21 +268,31 @@ class AquaApp:
268
268
  logger.info(f"Artifact not found in model {model_id}.")
269
269
  return False
270
270
 
271
- def get_config(self, model_id: str, config_file_name: str) -> Dict:
272
- """Gets the config for the given Aqua model.
271
+ def get_config(
272
+ self,
273
+ model_id: str,
274
+ config_file_name: str,
275
+ config_folder: Optional[str] = ConfigFolder.CONFIG,
276
+ ) -> ModelConfigResult:
277
+ """
278
+ Gets the configuration for the given Aqua model along with the model details.
273
279
 
274
280
  Parameters
275
281
  ----------
276
- model_id: str
282
+ model_id : str
277
283
  The OCID of the Aqua model.
278
- config_file_name: str
279
- name of the config file
284
+ config_file_name : str
285
+ The name of the configuration file.
286
+ config_folder : Optional[str]
287
+ The subfolder path where config_file_name is searched.
288
+ Defaults to ConfigFolder.CONFIG. For model artifact directories, use ConfigFolder.ARTIFACT.
280
289
 
281
290
  Returns
282
291
  -------
283
- Dict:
284
- A dict of allowed configs.
292
+ ModelConfigResult
293
+ A Pydantic model containing the model_details (extracted from OCI) and the config dictionary.
285
294
  """
295
+ config_folder = config_folder or ConfigFolder.CONFIG
286
296
  oci_model = self.ds_client.get_model(model_id).data
287
297
  oci_aqua = (
288
298
  (
@@ -292,11 +302,11 @@ class AquaApp:
292
302
  if oci_model.freeform_tags
293
303
  else False
294
304
  )
295
-
296
305
  if not oci_aqua:
297
- raise AquaRuntimeError(f"Target model {oci_model.id} is not Aqua model.")
306
+ raise AquaRuntimeError(f"Target model {oci_model.id} is not an Aqua model.")
307
+
308
+ config: Dict[str, Any] = {}
298
309
 
299
- config = {}
300
310
  # if the current model has a service model tag, then
301
311
  if Tags.AQUA_SERVICE_MODEL_TAG in oci_model.freeform_tags:
302
312
  base_model_ocid = oci_model.freeform_tags[Tags.AQUA_SERVICE_MODEL_TAG]
@@ -304,23 +314,26 @@ class AquaApp:
304
314
  f"Base model found for the model: {oci_model.id}. "
305
315
  f"Loading {config_file_name} for base model {base_model_ocid}."
306
316
  )
307
- base_model = self.ds_client.get_model(base_model_ocid).data
308
- artifact_path = get_artifact_path(base_model.custom_metadata_list)
317
+ if config_folder == ConfigFolder.ARTIFACT:
318
+ artifact_path = get_artifact_path(oci_model.custom_metadata_list)
319
+ else:
320
+ base_model = self.ds_client.get_model(base_model_ocid).data
321
+ artifact_path = get_artifact_path(base_model.custom_metadata_list)
309
322
  else:
310
323
  logger.info(f"Loading {config_file_name} for model {oci_model.id}...")
311
324
  artifact_path = get_artifact_path(oci_model.custom_metadata_list)
312
-
313
325
  if not artifact_path:
314
326
  logger.debug(
315
327
  f"Failed to get artifact path from custom metadata for the model: {model_id}"
316
328
  )
317
- return config
329
+ return ModelConfigResult(config=config, model_details=oci_model)
318
330
 
319
- config_path = f"{os.path.dirname(artifact_path)}/config/"
331
+ config_path = os.path.join(os.path.dirname(artifact_path), config_folder)
320
332
  if not is_path_exists(config_path):
321
- config_path = f"{artifact_path.rstrip('/')}/config/"
322
-
323
- config_file_path = f"{config_path}{config_file_name}"
333
+ config_path = os.path.join(artifact_path.rstrip("/"), config_folder)
334
+ if not is_path_exists(config_path):
335
+ config_path = f"{artifact_path.rstrip('/')}/"
336
+ config_file_path = os.path.join(config_path, config_file_name)
324
337
  if is_path_exists(config_file_path):
325
338
  try:
326
339
  config = load_config(
@@ -338,9 +351,8 @@ class AquaApp:
338
351
  f"{config_file_name} is not available for the model: {model_id}. "
339
352
  f"Check if the custom metadata has the artifact path set."
340
353
  )
341
- return config
342
354
 
343
- return config
355
+ return ModelConfigResult(config=config, model_details=oci_model)
344
356
 
345
357
  @property
346
358
  def telemetry(self):
@@ -362,9 +374,11 @@ class CLIBuilderMixin:
362
374
  """
363
375
  cmd = f"ads aqua {self._command}"
364
376
  params = [
365
- f"--{field.name} {json.dumps(getattr(self, field.name))}"
366
- if isinstance(getattr(self, field.name), dict)
367
- else f"--{field.name} {getattr(self, field.name)}"
377
+ (
378
+ f"--{field.name} {json.dumps(getattr(self, field.name))}"
379
+ if isinstance(getattr(self, field.name), dict)
380
+ else f"--{field.name} {getattr(self, field.name)}"
381
+ )
368
382
  for field in fields(self.__class__)
369
383
  if getattr(self, field.name) is not None
370
384
  ]
ads/aqua/client/client.py CHANGED
@@ -51,7 +51,7 @@ _T = TypeVar("_T", bound="BaseClient")
51
51
  logger = logging.getLogger(__name__)
52
52
 
53
53
 
54
- class OCIAuth(httpx.Auth):
54
+ class HttpxOCIAuth(httpx.Auth):
55
55
  """
56
56
  Custom HTTPX authentication class that uses the OCI Signer for request signing.
57
57
 
@@ -59,14 +59,15 @@ class OCIAuth(httpx.Auth):
59
59
  signer (oci.signer.Signer): The OCI signer used to sign requests.
60
60
  """
61
61
 
62
- def __init__(self, signer: oci.signer.Signer):
62
+ def __init__(self, signer: Optional[oci.signer.Signer] = None):
63
63
  """
64
- Initialize the OCIAuth instance.
64
+ Initialize the HttpxOCIAuth instance.
65
65
 
66
66
  Args:
67
67
  signer (oci.signer.Signer): The OCI signer to use for signing requests.
68
68
  """
69
- self.signer = signer
69
+
70
+ self.signer = signer or authutil.default_signer().get("signer")
70
71
 
71
72
  def auth_flow(self, request: httpx.Request) -> Iterator[httpx.Request]:
72
73
  """
@@ -256,7 +257,7 @@ class BaseClient:
256
257
  auth = auth or authutil.default_signer()
257
258
  if not callable(auth.get("signer")):
258
259
  raise ValueError("Auth object must have a 'signer' callable attribute.")
259
- self.auth = OCIAuth(auth["signer"])
260
+ self.auth = HttpxOCIAuth(auth["signer"])
260
261
 
261
262
  logger.debug(
262
263
  f"Initialized {self.__class__.__name__} with endpoint={self.endpoint}, "
@@ -352,7 +353,7 @@ class Client(BaseClient):
352
353
  **kwargs: Keyword arguments forwarded to BaseClient.
353
354
  """
354
355
  super().__init__(*args, **kwargs)
355
- self._client = httpx.Client(timeout=self.timeout)
356
+ self._client = httpx.Client(timeout=self.timeout, auth=self.auth)
356
357
 
357
358
  def is_closed(self) -> bool:
358
359
  return self._client.is_closed
@@ -400,7 +401,6 @@ class Client(BaseClient):
400
401
  response = self._client.post(
401
402
  self.endpoint,
402
403
  headers=self._prepare_headers(stream=False, headers=headers),
403
- auth=self.auth,
404
404
  json=payload,
405
405
  )
406
406
  logger.debug(f"Received response with status code: {response.status_code}")
@@ -447,7 +447,6 @@ class Client(BaseClient):
447
447
  "POST",
448
448
  self.endpoint,
449
449
  headers=self._prepare_headers(stream=True, headers=headers),
450
- auth=self.auth,
451
450
  json={**payload, "stream": True},
452
451
  ) as response:
453
452
  try:
@@ -581,7 +580,7 @@ class AsyncClient(BaseClient):
581
580
  **kwargs: Keyword arguments forwarded to BaseClient.
582
581
  """
583
582
  super().__init__(*args, **kwargs)
584
- self._client = httpx.AsyncClient(timeout=self.timeout)
583
+ self._client = httpx.AsyncClient(timeout=self.timeout, auth=self.auth)
585
584
 
586
585
  def is_closed(self) -> bool:
587
586
  return self._client.is_closed
@@ -637,7 +636,6 @@ class AsyncClient(BaseClient):
637
636
  response = await self._client.post(
638
637
  self.endpoint,
639
638
  headers=self._prepare_headers(stream=False, headers=headers),
640
- auth=self.auth,
641
639
  json=payload,
642
640
  )
643
641
  logger.debug(f"Received response with status code: {response.status_code}")
@@ -683,7 +681,6 @@ class AsyncClient(BaseClient):
683
681
  "POST",
684
682
  self.endpoint,
685
683
  headers=self._prepare_headers(stream=True, headers=headers),
686
- auth=self.auth,
687
684
  json={**payload, "stream": True},
688
685
  ) as response:
689
686
  try:
@@ -797,3 +794,43 @@ class AsyncClient(BaseClient):
797
794
  logger.debug(f"Generating embeddings with input: {input}, payload: {payload}")
798
795
  payload = {**(payload or {}), "input": input}
799
796
  return await self._request(payload=payload, headers=headers)
797
+
798
+
799
+ def get_httpx_client(**kwargs: Any) -> httpx.Client:
800
+ """
801
+ Creates and returns a synchronous httpx Client configured with OCI authentication signer based
802
+ the authentication type setup using ads.set_auth method or env variable OCI_IAM_TYPE.
803
+ More information - https://accelerated-data-science.readthedocs.io/en/stable/user_guide/cli/authentication.html
804
+
805
+ Parameters
806
+ ----------
807
+ **kwargs : Any
808
+ Keyword arguments supported by httpx.Client
809
+
810
+ Returns
811
+ -------
812
+ Client
813
+ A configured synchronous httpx Client instance.
814
+ """
815
+ kwargs["auth"] = kwargs.get("auth") or HttpxOCIAuth()
816
+ return httpx.Client(**kwargs)
817
+
818
+
819
+ def get_async_httpx_client(**kwargs: Any) -> httpx.AsyncClient:
820
+ """
821
+ Creates and returns a synchronous httpx Client configured with OCI authentication signer based
822
+ the authentication type setup using ads.set_auth method or env variable OCI_IAM_TYPE.
823
+ More information - https://accelerated-data-science.readthedocs.io/en/stable/user_guide/cli/authentication.html
824
+
825
+ Parameters
826
+ ----------
827
+ **kwargs : Any
828
+ Keyword arguments supported by httpx.Client
829
+
830
+ Returns
831
+ -------
832
+ AsyncClient
833
+ A configured asynchronous httpx AsyncClient instance.
834
+ """
835
+ kwargs["auth"] = kwargs.get("auth") or HttpxOCIAuth()
836
+ return httpx.AsyncClient(**kwargs)
@@ -1,7 +1,12 @@
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
+ from typing import Any, Dict, Optional
6
+
7
+ from oci.data_science.models import Model
8
+ from pydantic import BaseModel, Field
9
+
5
10
 
6
11
  class ContainerSpec:
7
12
  """
@@ -15,3 +20,25 @@ class ContainerSpec:
15
20
  ENV_VARS = "envVars"
16
21
  RESTRICTED_PARAMS = "restrictedParams"
17
22
  EVALUATION_CONFIGURATION = "evaluationConfiguration"
23
+
24
+
25
+ class ModelConfigResult(BaseModel):
26
+ """
27
+ Represents the result of getting the AQUA model configuration.
28
+
29
+ Attributes:
30
+ model_details (Dict[str, Any]): A dictionary containing model details extracted from OCI.
31
+ config (Dict[str, Any]): A dictionary of the loaded configuration.
32
+ """
33
+
34
+ config: Optional[Dict[str, Any]] = Field(
35
+ None, description="Loaded configuration dictionary."
36
+ )
37
+ model_details: Optional[Model] = Field(
38
+ None, description="Details of the model from OCI."
39
+ )
40
+
41
+ class Config:
42
+ extra = "ignore"
43
+ arbitrary_types_allowed = True
44
+ protected_namespaces = ()
ads/aqua/common/enums.py CHANGED
@@ -1,22 +1,16 @@
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
- """
6
- aqua.common.enums
7
- ~~~~~~~~~~~~~~
8
- This module contains the set of enums used in AQUA.
9
- """
5
+ from ads.common.extended_enum import ExtendedEnum
10
6
 
11
- from ads.common.extended_enum import ExtendedEnumMeta
12
7
 
13
-
14
- class DataScienceResource(str, metaclass=ExtendedEnumMeta):
8
+ class DataScienceResource(ExtendedEnum):
15
9
  MODEL_DEPLOYMENT = "datasciencemodeldeployment"
16
10
  MODEL = "datasciencemodel"
17
11
 
18
12
 
19
- class Resource(str, metaclass=ExtendedEnumMeta):
13
+ class Resource(ExtendedEnum):
20
14
  JOB = "jobs"
21
15
  JOBRUN = "jobruns"
22
16
  MODEL = "models"
@@ -24,7 +18,7 @@ class Resource(str, metaclass=ExtendedEnumMeta):
24
18
  MODEL_VERSION_SET = "model-version-sets"
25
19
 
26
20
 
27
- class Tags(str, metaclass=ExtendedEnumMeta):
21
+ class Tags(ExtendedEnum):
28
22
  TASK = "task"
29
23
  LICENSE = "license"
30
24
  ORGANIZATION = "organization"
@@ -42,41 +36,41 @@ class Tags(str, metaclass=ExtendedEnumMeta):
42
36
  MODEL_ARTIFACT_FILE = "model_file"
43
37
 
44
38
 
45
- class InferenceContainerType(str, metaclass=ExtendedEnumMeta):
39
+ class InferenceContainerType(ExtendedEnum):
46
40
  CONTAINER_TYPE_VLLM = "vllm"
47
41
  CONTAINER_TYPE_TGI = "tgi"
48
42
  CONTAINER_TYPE_LLAMA_CPP = "llama-cpp"
49
43
 
50
44
 
51
- class InferenceContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
45
+ class InferenceContainerTypeFamily(ExtendedEnum):
52
46
  AQUA_VLLM_CONTAINER_FAMILY = "odsc-vllm-serving"
53
47
  AQUA_TGI_CONTAINER_FAMILY = "odsc-tgi-serving"
54
48
  AQUA_LLAMA_CPP_CONTAINER_FAMILY = "odsc-llama-cpp-serving"
55
49
 
56
50
 
57
- class CustomInferenceContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
51
+ class CustomInferenceContainerTypeFamily(ExtendedEnum):
58
52
  AQUA_TEI_CONTAINER_FAMILY = "odsc-tei-serving"
59
53
 
60
54
 
61
- class InferenceContainerParamType(str, metaclass=ExtendedEnumMeta):
55
+ class InferenceContainerParamType(ExtendedEnum):
62
56
  PARAM_TYPE_VLLM = "VLLM_PARAMS"
63
57
  PARAM_TYPE_TGI = "TGI_PARAMS"
64
58
  PARAM_TYPE_LLAMA_CPP = "LLAMA_CPP_PARAMS"
65
59
 
66
60
 
67
- class EvaluationContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
61
+ class EvaluationContainerTypeFamily(ExtendedEnum):
68
62
  AQUA_EVALUATION_CONTAINER_FAMILY = "odsc-llm-evaluate"
69
63
 
70
64
 
71
- class FineTuningContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
65
+ class FineTuningContainerTypeFamily(ExtendedEnum):
72
66
  AQUA_FINETUNING_CONTAINER_FAMILY = "odsc-llm-fine-tuning"
73
67
 
74
68
 
75
- class HuggingFaceTags(str, metaclass=ExtendedEnumMeta):
69
+ class HuggingFaceTags(ExtendedEnum):
76
70
  TEXT_GENERATION_INFERENCE = "text-generation-inference"
77
71
 
78
72
 
79
- class RqsAdditionalDetails(str, metaclass=ExtendedEnumMeta):
73
+ class RqsAdditionalDetails(ExtendedEnum):
80
74
  METADATA = "metadata"
81
75
  CREATED_BY = "createdBy"
82
76
  DESCRIPTION = "description"
@@ -86,9 +80,26 @@ class RqsAdditionalDetails(str, metaclass=ExtendedEnumMeta):
86
80
  VERSION_LABEL = "versionLabel"
87
81
 
88
82
 
89
- class TextEmbeddingInferenceContainerParams(str, metaclass=ExtendedEnumMeta):
83
+ class TextEmbeddingInferenceContainerParams(ExtendedEnum):
90
84
  """Contains a subset of params that are required for enabling model deployment in OCI Data Science. More options
91
- are available at https://huggingface.co/docs/text-embeddings-inference/en/cli_arguments"""
85
+ are available at https://huggingface.co/docs/text-embeddings-inference/en/cli_arguments
86
+ """
92
87
 
93
88
  MODEL_ID = "model-id"
94
89
  PORT = "port"
90
+
91
+
92
+ class ConfigFolder(ExtendedEnum):
93
+ CONFIG = "config"
94
+ ARTIFACT = "artifact"
95
+
96
+
97
+ class ModelFormat(ExtendedEnum):
98
+ GGUF = "GGUF"
99
+ SAFETENSORS = "SAFETENSORS"
100
+ UNKNOWN = "UNKNOWN"
101
+
102
+
103
+ class Platform(ExtendedEnum):
104
+ ARM_CPU = "ARM_CPU"
105
+ NVIDIA_GPU = "NVIDIA_GPU"
ads/aqua/common/errors.py CHANGED
@@ -1,6 +1,5 @@
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
4
 
6
5
  """
@@ -10,10 +9,10 @@ aqua.exception
10
9
  This module contains the set of Aqua exceptions.
11
10
  """
12
11
 
13
- from ads.common.extended_enum import ExtendedEnumMeta
12
+ from ads.common.extended_enum import ExtendedEnum
14
13
 
15
14
 
16
- class ExitCode(str, metaclass=ExtendedEnumMeta):
15
+ class ExitCode(ExtendedEnum):
17
16
  SUCCESS = 0
18
17
  COMMON_ERROR = 1
19
18
  INVALID_CONFIG = 10
ads/aqua/common/utils.py CHANGED
@@ -19,7 +19,6 @@ from pathlib import Path
19
19
  from string import Template
20
20
  from typing import List, Union
21
21
 
22
- import fsspec
23
22
  import oci
24
23
  from cachetools import TTLCache, cached
25
24
  from huggingface_hub.constants import HF_HUB_CACHE
@@ -58,17 +57,22 @@ from ads.aqua.constants import (
58
57
  SUPPORTED_FILE_FORMATS,
59
58
  TEI_CONTAINER_DEFAULT_HOST,
60
59
  TGI_INFERENCE_RESTRICTED_PARAMS,
61
- UNKNOWN,
62
60
  UNKNOWN_JSON_STR,
63
61
  VLLM_INFERENCE_RESTRICTED_PARAMS,
64
62
  )
65
63
  from ads.aqua.data import AquaResourceIdentifier
66
64
  from ads.common.auth import AuthState, default_signer
67
65
  from ads.common.decorator.threaded import threaded
68
- from ads.common.extended_enum import ExtendedEnumMeta
66
+ from ads.common.extended_enum import ExtendedEnum
69
67
  from ads.common.object_storage_details import ObjectStorageDetails
70
68
  from ads.common.oci_resource import SEARCH_TYPE, OCIResource
71
- from ads.common.utils import copy_file, get_console_link, upload_to_os
69
+ from ads.common.utils import (
70
+ UNKNOWN,
71
+ copy_file,
72
+ get_console_link,
73
+ read_file,
74
+ upload_to_os,
75
+ )
72
76
  from ads.config import (
73
77
  AQUA_MODEL_DEPLOYMENT_FOLDER,
74
78
  AQUA_SERVICE_MODELS_BUCKET,
@@ -80,7 +84,7 @@ from ads.model import DataScienceModel, ModelVersionSet
80
84
  logger = logging.getLogger("ads.aqua")
81
85
 
82
86
 
83
- class LifecycleStatus(str, metaclass=ExtendedEnumMeta):
87
+ class LifecycleStatus(ExtendedEnum):
84
88
  UNKNOWN = ""
85
89
 
86
90
  @property
@@ -228,15 +232,6 @@ def get_artifact_path(custom_metadata_list: List) -> str:
228
232
  return UNKNOWN
229
233
 
230
234
 
231
- def read_file(file_path: str, **kwargs) -> str:
232
- try:
233
- with fsspec.open(file_path, "r", **kwargs.get("auth", {})) as f:
234
- return f.read()
235
- except Exception as e:
236
- logger.debug(f"Failed to read file {file_path}. {e}")
237
- return UNKNOWN
238
-
239
-
240
235
  @threaded()
241
236
  def load_config(file_path: str, config_file_name: str, **kwargs) -> dict:
242
237
  artifact_path = f"{file_path.rstrip('/')}/{config_file_name}"
@@ -553,7 +548,7 @@ def service_config_path():
553
548
  return f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
554
549
 
555
550
 
556
- @cached(cache=TTLCache(maxsize=1, ttl=timedelta(hours=5), timer=datetime.now))
551
+ @cached(cache=TTLCache(maxsize=1, ttl=timedelta(minutes=10), timer=datetime.now))
557
552
  def get_container_config():
558
553
  config = load_config(
559
554
  file_path=service_config_path(),