oracle-ads 2.11.8__py3-none-any.whl → 2.11.10__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 (87) hide show
  1. ads/aqua/__init__.py +1 -1
  2. ads/aqua/{base.py → app.py} +27 -7
  3. ads/aqua/cli.py +59 -17
  4. ads/aqua/common/__init__.py +5 -0
  5. ads/aqua/{decorator.py → common/decorator.py} +14 -8
  6. ads/aqua/common/enums.py +69 -0
  7. ads/aqua/{exception.py → common/errors.py} +28 -0
  8. ads/aqua/{utils.py → common/utils.py} +171 -79
  9. ads/aqua/config/config.py +18 -0
  10. ads/aqua/constants.py +51 -33
  11. ads/aqua/data.py +15 -26
  12. ads/aqua/evaluation/__init__.py +8 -0
  13. ads/aqua/evaluation/constants.py +53 -0
  14. ads/aqua/evaluation/entities.py +170 -0
  15. ads/aqua/evaluation/errors.py +71 -0
  16. ads/aqua/{evaluation.py → evaluation/evaluation.py} +122 -370
  17. ads/aqua/extension/__init__.py +2 -0
  18. ads/aqua/extension/aqua_ws_msg_handler.py +97 -0
  19. ads/aqua/extension/base_handler.py +0 -7
  20. ads/aqua/extension/common_handler.py +12 -6
  21. ads/aqua/extension/deployment_handler.py +70 -4
  22. ads/aqua/extension/errors.py +10 -0
  23. ads/aqua/extension/evaluation_handler.py +5 -3
  24. ads/aqua/extension/evaluation_ws_msg_handler.py +43 -0
  25. ads/aqua/extension/finetune_handler.py +41 -3
  26. ads/aqua/extension/model_handler.py +56 -4
  27. ads/aqua/extension/models/__init__.py +0 -0
  28. ads/aqua/extension/models/ws_models.py +69 -0
  29. ads/aqua/extension/ui_handler.py +65 -4
  30. ads/aqua/extension/ui_websocket_handler.py +124 -0
  31. ads/aqua/extension/utils.py +1 -1
  32. ads/aqua/finetuning/__init__.py +7 -0
  33. ads/aqua/finetuning/constants.py +17 -0
  34. ads/aqua/finetuning/entities.py +102 -0
  35. ads/aqua/{finetune.py → finetuning/finetuning.py} +162 -136
  36. ads/aqua/model/__init__.py +8 -0
  37. ads/aqua/model/constants.py +46 -0
  38. ads/aqua/model/entities.py +266 -0
  39. ads/aqua/model/enums.py +26 -0
  40. ads/aqua/{model.py → model/model.py} +401 -309
  41. ads/aqua/modeldeployment/__init__.py +8 -0
  42. ads/aqua/modeldeployment/constants.py +26 -0
  43. ads/aqua/{deployment.py → modeldeployment/deployment.py} +288 -227
  44. ads/aqua/modeldeployment/entities.py +142 -0
  45. ads/aqua/modeldeployment/inference.py +75 -0
  46. ads/aqua/ui.py +88 -8
  47. ads/cli.py +55 -7
  48. ads/common/serializer.py +2 -2
  49. ads/config.py +2 -1
  50. ads/jobs/builders/infrastructure/dsc_job.py +49 -6
  51. ads/model/datascience_model.py +21 -1
  52. ads/model/deployment/model_deployment.py +11 -0
  53. ads/model/model_metadata.py +17 -6
  54. ads/opctl/operator/lowcode/anomaly/README.md +0 -2
  55. ads/opctl/operator/lowcode/anomaly/__main__.py +3 -3
  56. ads/opctl/operator/lowcode/anomaly/environment.yaml +0 -2
  57. ads/opctl/operator/lowcode/anomaly/model/automlx.py +2 -2
  58. ads/opctl/operator/lowcode/anomaly/model/autots.py +1 -1
  59. ads/opctl/operator/lowcode/anomaly/model/base_model.py +13 -17
  60. ads/opctl/operator/lowcode/anomaly/operator_config.py +2 -0
  61. ads/opctl/operator/lowcode/anomaly/schema.yaml +1 -2
  62. ads/opctl/operator/lowcode/anomaly/utils.py +3 -2
  63. ads/opctl/operator/lowcode/common/transformations.py +2 -1
  64. ads/opctl/operator/lowcode/common/utils.py +1 -1
  65. ads/opctl/operator/lowcode/forecast/README.md +1 -3
  66. ads/opctl/operator/lowcode/forecast/__main__.py +3 -18
  67. ads/opctl/operator/lowcode/forecast/const.py +2 -0
  68. ads/opctl/operator/lowcode/forecast/environment.yaml +1 -2
  69. ads/opctl/operator/lowcode/forecast/model/arima.py +1 -0
  70. ads/opctl/operator/lowcode/forecast/model/automlx.py +7 -4
  71. ads/opctl/operator/lowcode/forecast/model/autots.py +1 -0
  72. ads/opctl/operator/lowcode/forecast/model/base_model.py +38 -22
  73. ads/opctl/operator/lowcode/forecast/model/factory.py +33 -4
  74. ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py +15 -1
  75. ads/opctl/operator/lowcode/forecast/model/ml_forecast.py +234 -0
  76. ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +9 -1
  77. ads/opctl/operator/lowcode/forecast/model/prophet.py +1 -0
  78. ads/opctl/operator/lowcode/forecast/model_evaluator.py +147 -0
  79. ads/opctl/operator/lowcode/forecast/operator_config.py +2 -1
  80. ads/opctl/operator/lowcode/forecast/schema.yaml +7 -2
  81. ads/opctl/operator/lowcode/forecast/utils.py +18 -44
  82. {oracle_ads-2.11.8.dist-info → oracle_ads-2.11.10.dist-info}/METADATA +9 -12
  83. {oracle_ads-2.11.8.dist-info → oracle_ads-2.11.10.dist-info}/RECORD +86 -61
  84. ads/aqua/job.py +0 -29
  85. {oracle_ads-2.11.8.dist-info → oracle_ads-2.11.10.dist-info}/LICENSE.txt +0 -0
  86. {oracle_ads-2.11.8.dist-info → oracle_ads-2.11.10.dist-info}/WHEEL +0 -0
  87. {oracle_ads-2.11.8.dist-info → oracle_ads-2.11.10.dist-info}/entry_points.txt +0 -0
ads/aqua/__init__.py CHANGED
@@ -7,7 +7,7 @@
7
7
  import os
8
8
 
9
9
  from ads import logger, set_auth
10
- from ads.aqua.utils import fetch_service_compartment
10
+ from ads.aqua.common.utils import fetch_service_compartment
11
11
  from ads.config import OCI_RESOURCE_PRINCIPAL_VERSION
12
12
 
13
13
  ENV_VAR_LOG_LEVEL = "ADS_AQUA_LOG_LEVEL"
@@ -4,6 +4,7 @@
4
4
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
5
 
6
6
  import os
7
+ from dataclasses import fields
7
8
  from typing import Dict, Union
8
9
 
9
10
  import oci
@@ -11,15 +12,15 @@ from oci.data_science.models import UpdateModelDetails, UpdateModelProvenanceDet
11
12
 
12
13
  from ads import set_auth
13
14
  from ads.aqua import logger
14
- from ads.aqua.data import Tags
15
- from ads.aqua.exception import AquaRuntimeError, AquaValueError
16
- from ads.aqua.utils import (
17
- UNKNOWN,
15
+ from ads.aqua.common.enums import Tags
16
+ from ads.aqua.common.errors import AquaRuntimeError, AquaValueError
17
+ from ads.aqua.common.utils import (
18
18
  _is_valid_mvs,
19
19
  get_artifact_path,
20
20
  is_valid_ocid,
21
21
  load_config,
22
22
  )
23
+ from ads.aqua.constants import UNKNOWN
23
24
  from ads.common import oci_client as oc
24
25
  from ads.common.auth import default_signer
25
26
  from ads.common.utils import extract_region
@@ -160,7 +161,7 @@ class AquaApp:
160
161
  """
161
162
  # TODO: tag should be selected based on which operation (eval/FT) invoke this method
162
163
  # currently only used by fine-tuning flow.
163
- tag = Tags.AQUA_FINE_TUNING.value
164
+ tag = Tags.AQUA_FINE_TUNING
164
165
 
165
166
  if not model_version_set_id:
166
167
  try:
@@ -277,8 +278,8 @@ class AquaApp:
277
278
  oci_model = self.ds_client.get_model(model_id).data
278
279
  oci_aqua = (
279
280
  (
280
- Tags.AQUA_TAG.value in oci_model.freeform_tags
281
- or Tags.AQUA_TAG.value.lower() in oci_model.freeform_tags
281
+ Tags.AQUA_TAG in oci_model.freeform_tags
282
+ or Tags.AQUA_TAG.lower() in oci_model.freeform_tags
282
283
  )
283
284
  if oci_model.freeform_tags
284
285
  else False
@@ -319,3 +320,22 @@ class AquaApp:
319
320
  bucket=AQUA_TELEMETRY_BUCKET, namespace=AQUA_TELEMETRY_BUCKET_NS
320
321
  )
321
322
  return self._telemetry
323
+
324
+
325
+ class CLIBuilderMixin:
326
+ """
327
+ CLI builder from API interface. To be used with the DataClass only.
328
+ """
329
+
330
+ def build_cli(self) -> str:
331
+ """
332
+ Method to turn the dataclass attributes to CLI
333
+ """
334
+ cmd = f"ads aqua {self._command}"
335
+ params = [
336
+ f"--{field.name} {getattr(self,field.name)}"
337
+ for field in fields(self.__class__)
338
+ if getattr(self, field.name)
339
+ ]
340
+ cmd = f"{cmd} {' '.join(params)}"
341
+ return cmd
ads/aqua/cli.py CHANGED
@@ -4,20 +4,20 @@
4
4
  # Copyright (c) 2024 Oracle and/or its affiliates.
5
5
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6
6
  import os
7
- import sys
8
7
 
9
8
  from ads.aqua import (
10
9
  ENV_VAR_LOG_LEVEL,
11
- set_log_level,
12
10
  ODSC_MODEL_COMPARTMENT_OCID,
13
11
  logger,
12
+ set_log_level,
14
13
  )
15
- from ads.aqua.deployment import AquaDeploymentApp
14
+ from ads.aqua.common.errors import AquaCLIError, AquaConfigError
16
15
  from ads.aqua.evaluation import AquaEvaluationApp
17
- from ads.aqua.finetune import AquaFineTuningApp
16
+ from ads.aqua.finetuning import AquaFineTuningApp
18
17
  from ads.aqua.model import AquaModelApp
19
- from ads.config import NB_SESSION_OCID
18
+ from ads.aqua.modeldeployment import AquaDeploymentApp
20
19
  from ads.common.utils import LOG_LEVELS
20
+ from ads.config import NB_SESSION_OCID
21
21
 
22
22
 
23
23
  class AquaCommand:
@@ -35,6 +35,8 @@ class AquaCommand:
35
35
 
36
36
  def __init__(
37
37
  self,
38
+ debug: bool = None,
39
+ verbose: bool = None,
38
40
  log_level: str = os.environ.get(ENV_VAR_LOG_LEVEL, "ERROR").upper(),
39
41
  ):
40
42
  """
@@ -44,24 +46,64 @@ class AquaCommand:
44
46
  -----
45
47
  log_level (str):
46
48
  Sets the logging level for the application.
47
- Default is retrieved from environment variable `LOG_LEVEL`,
49
+ Default is retrieved from environment variable `ADS_AQUA_LOG_LEVEL`,
48
50
  or 'ERROR' if not set. Example values include 'DEBUG', 'INFO',
49
51
  'WARNING', 'ERROR', and 'CRITICAL'.
52
+ debug (bool):
53
+ Sets the logging level for the application to `DEBUG`.
54
+ verbose (bool):
55
+ Sets the logging level for the application to `INFO`.
56
+
57
+ Raises
58
+ ------
59
+ AquaCLIError:
60
+ When `--verbose` and `--debug` being used together.
61
+ When missing required `ODSC_MODEL_COMPARTMENT_OCID` env var.
50
62
  """
51
- if log_level.upper() not in LOG_LEVELS:
52
- logger.error(
53
- f"Log level should be one of {LOG_LEVELS}. Setting default to ERROR."
63
+ if verbose is not None and debug is not None:
64
+ raise AquaCLIError(
65
+ "Cannot use `--debug` and `--verbose` at the same time. "
66
+ "Please select either `--debug` for `DEBUG` level logging or "
67
+ "`--verbose` for `INFO` level logging."
54
68
  )
55
- log_level = "ERROR"
56
- set_log_level(log_level)
57
- # gracefully exit if env var is not set
69
+ elif verbose is not None:
70
+ self._validate_value("--verbose", verbose)
71
+ aqua_log_level = "INFO"
72
+ elif debug is not None:
73
+ self._validate_value("--debug", debug)
74
+ aqua_log_level = "DEBUG"
75
+ else:
76
+ if log_level.upper() not in LOG_LEVELS:
77
+ logger.warning(
78
+ f"Log level should be one of {LOG_LEVELS}. Setting default to ERROR."
79
+ )
80
+ log_level = "ERROR"
81
+ aqua_log_level = log_level.upper()
82
+
83
+ set_log_level(aqua_log_level)
84
+
58
85
  if not ODSC_MODEL_COMPARTMENT_OCID:
59
- logger.debug(
60
- "ODSC_MODEL_COMPARTMENT_OCID environment variable is not set for Aqua."
61
- )
62
86
  if NB_SESSION_OCID:
63
- logger.error(
87
+ raise AquaConfigError(
64
88
  f"Aqua is not available for the notebook session {NB_SESSION_OCID}. For more information, "
65
89
  f"please refer to the documentation."
66
90
  )
67
- sys.exit(1)
91
+ raise AquaConfigError(
92
+ "ODSC_MODEL_COMPARTMENT_OCID environment variable is not set for Aqua."
93
+ )
94
+
95
+ @staticmethod
96
+ def _validate_value(flag, value):
97
+ """Check if the given value for bool flag is valid.
98
+
99
+ Raises
100
+ ------
101
+ AquaCLIError:
102
+ When the given value for bool flag is invalid.
103
+ """
104
+ if value not in [True, False]:
105
+ raise AquaCLIError(
106
+ f"Invalid input `{value}` for flag: {flag}, a boolean value is required. "
107
+ "If you intend to chain a function call to the result, please separate the "
108
+ "flag and the subsequent function call with separator `-`."
109
+ )
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*--
3
+
4
+ # Copyright (c) 2024 Oracle and/or its affiliates.
5
+ # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
@@ -7,6 +7,7 @@
7
7
 
8
8
  import sys
9
9
  from functools import wraps
10
+ from typing import TYPE_CHECKING, Union
10
11
 
11
12
  from oci.exceptions import (
12
13
  ClientError,
@@ -19,9 +20,12 @@ from oci.exceptions import (
19
20
  )
20
21
  from tornado.web import HTTPError
21
22
 
22
- from ads.aqua.exception import AquaError
23
+ from ads.aqua.common.errors import AquaError
23
24
  from ads.aqua.extension.base_handler import AquaAPIhandler
24
25
 
26
+ if TYPE_CHECKING:
27
+ from ads.aqua.extension.aqua_ws_msg_handler import AquaWSMsgHandler
28
+
25
29
 
26
30
  def handle_exceptions(func):
27
31
  """Writes errors raised during call to JSON.
@@ -53,11 +57,13 @@ def handle_exceptions(func):
53
57
  """
54
58
 
55
59
  @wraps(func)
56
- def inner_function(self: AquaAPIhandler, *args, **kwargs):
60
+ def inner_function(
61
+ self: Union[AquaAPIhandler, "AquaWSMsgHandler"], *args, **kwargs
62
+ ):
57
63
  try:
58
64
  return func(self, *args, **kwargs)
59
65
  except ServiceError as error:
60
- self.write_error(
66
+ return self.write_error(
61
67
  status_code=error.status or 500,
62
68
  message=error.message,
63
69
  reason=error.message,
@@ -69,25 +75,25 @@ def handle_exceptions(func):
69
75
  MissingEndpointForNonRegionalServiceClientError,
70
76
  RequestException,
71
77
  ) as error:
72
- self.write_error(
78
+ return self.write_error(
73
79
  status_code=400,
74
80
  reason=f"{type(error).__name__}: {str(error)}",
75
81
  exc_info=sys.exc_info(),
76
82
  )
77
83
  except ConnectTimeout as error:
78
- self.write_error(
84
+ return self.write_error(
79
85
  status_code=408,
80
86
  reason=f"{type(error).__name__}: {str(error)}",
81
87
  exc_info=sys.exc_info(),
82
88
  )
83
89
  except (MultipartUploadError, CompositeOperationError) as error:
84
- self.write_error(
90
+ return self.write_error(
85
91
  status_code=500,
86
92
  reason=f"{type(error).__name__}: {str(error)}",
87
93
  exc_info=sys.exc_info(),
88
94
  )
89
95
  except AquaError as error:
90
- self.write_error(
96
+ return self.write_error(
91
97
  status_code=error.status,
92
98
  reason=error.reason,
93
99
  service_payload=error.service_payload,
@@ -100,7 +106,7 @@ def handle_exceptions(func):
100
106
  exc_info=sys.exc_info(),
101
107
  )
102
108
  except Exception as ex:
103
- self.write_error(
109
+ return self.write_error(
104
110
  status_code=500,
105
111
  reason=f"{type(ex).__name__}: {str(ex)}",
106
112
  exc_info=sys.exc_info(),
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2024 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
+ """
7
+ aqua.common.enums
8
+ ~~~~~~~~~~~~~~
9
+ This module contains the set of enums used in AQUA.
10
+ """
11
+ from ads.common.extended_enum import ExtendedEnumMeta
12
+
13
+
14
+ class DataScienceResource(str, metaclass=ExtendedEnumMeta):
15
+ MODEL_DEPLOYMENT = "datasciencemodeldeployment"
16
+ MODEL = "datasciencemodel"
17
+
18
+
19
+ class Resource(str, metaclass=ExtendedEnumMeta):
20
+ JOB = "jobs"
21
+ JOBRUN = "jobruns"
22
+ MODEL = "models"
23
+ MODEL_DEPLOYMENT = "modeldeployments"
24
+ MODEL_VERSION_SET = "model-version-sets"
25
+
26
+
27
+ class Tags(str, metaclass=ExtendedEnumMeta):
28
+ TASK = "task"
29
+ LICENSE = "license"
30
+ ORGANIZATION = "organization"
31
+ AQUA_TAG = "OCI_AQUA"
32
+ AQUA_SERVICE_MODEL_TAG = "aqua_service_model"
33
+ AQUA_FINE_TUNED_MODEL_TAG = "aqua_fine_tuned_model"
34
+ AQUA_MODEL_NAME_TAG = "aqua_model_name"
35
+ AQUA_EVALUATION = "aqua_evaluation"
36
+ AQUA_FINE_TUNING = "aqua_finetuning"
37
+ READY_TO_FINE_TUNE = "ready_to_fine_tune"
38
+ READY_TO_IMPORT = "ready_to_import"
39
+ BASE_MODEL_CUSTOM = "aqua_custom_base_model"
40
+ AQUA_EVALUATION_MODEL_ID = "evaluation_model_id"
41
+
42
+
43
+ class InferenceContainerType(str, metaclass=ExtendedEnumMeta):
44
+ CONTAINER_TYPE_VLLM = "vllm"
45
+ CONTAINER_TYPE_TGI = "tgi"
46
+
47
+
48
+ class InferenceContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
49
+ AQUA_VLLM_CONTAINER_FAMILY = "odsc-vllm-serving"
50
+ AQUA_TGI_CONTAINER_FAMILY = "odsc-tgi-serving"
51
+
52
+
53
+ class InferenceContainerParamType(str, metaclass=ExtendedEnumMeta):
54
+ PARAM_TYPE_VLLM = "VLLM_PARAMS"
55
+ PARAM_TYPE_TGI = "TGI_PARAMS"
56
+
57
+
58
+ class HuggingFaceTags(str, metaclass=ExtendedEnumMeta):
59
+ TEXT_GENERATION_INFERENCE = "text-generation-inference"
60
+
61
+
62
+ class RqsAdditionalDetails(str, metaclass=ExtendedEnumMeta):
63
+ METADATA = "metadata"
64
+ CREATED_BY = "createdBy"
65
+ DESCRIPTION = "description"
66
+ MODEL_VERSION_SET_ID = "modelVersionSetId"
67
+ MODEL_VERSION_SET_NAME = "modelVersionSetName"
68
+ PROJECT_ID = "projectId"
69
+ VERSION_LABEL = "versionLabel"
@@ -10,6 +10,14 @@ aqua.exception
10
10
  This module contains the set of Aqua exceptions.
11
11
  """
12
12
 
13
+ from ads.common.extended_enum import ExtendedEnumMeta
14
+
15
+
16
+ class ExitCode(str, metaclass=ExtendedEnumMeta):
17
+ SUCCESS = 0
18
+ COMMON_ERROR = 1
19
+ INVALID_CONFIG = 10
20
+
13
21
 
14
22
  class AquaError(Exception):
15
23
  """AquaError
@@ -18,6 +26,8 @@ class AquaError(Exception):
18
26
  will inherit.
19
27
  """
20
28
 
29
+ exit_code = 1
30
+
21
31
  def __init__(
22
32
  self,
23
33
  reason: str,
@@ -80,3 +90,21 @@ class AquaResourceAccessError(AquaError):
80
90
 
81
91
  def __init__(self, reason, status=404, service_payload=None):
82
92
  super().__init__(reason, status, service_payload)
93
+
94
+
95
+ class AquaConfigError(AquaError):
96
+ """Exception raised when config for AQUA is invalid."""
97
+
98
+ exit_code = ExitCode.INVALID_CONFIG
99
+
100
+ def __init__(self, reason, status=404, service_payload=None):
101
+ super().__init__(reason, status, service_payload)
102
+
103
+
104
+ class AquaCLIError(AquaError):
105
+ """Exception raised when AQUA CLI encounter error."""
106
+
107
+ exit_code = ExitCode.COMMON_ERROR
108
+
109
+ def __init__(self, reason, status=None, service_payload=None):
110
+ super().__init__(reason, status, service_payload)