oracle-ads 2.10.0__py3-none-any.whl → 2.11.0__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 (117) hide show
  1. ads/aqua/__init__.py +12 -0
  2. ads/aqua/base.py +324 -0
  3. ads/aqua/cli.py +19 -0
  4. ads/aqua/config/deployment_config_defaults.json +9 -0
  5. ads/aqua/config/resource_limit_names.json +7 -0
  6. ads/aqua/constants.py +45 -0
  7. ads/aqua/data.py +40 -0
  8. ads/aqua/decorator.py +101 -0
  9. ads/aqua/deployment.py +643 -0
  10. ads/aqua/dummy_data/icon.txt +1 -0
  11. ads/aqua/dummy_data/oci_model_deployments.json +56 -0
  12. ads/aqua/dummy_data/oci_models.json +1 -0
  13. ads/aqua/dummy_data/readme.md +26 -0
  14. ads/aqua/evaluation.py +1751 -0
  15. ads/aqua/exception.py +82 -0
  16. ads/aqua/extension/__init__.py +40 -0
  17. ads/aqua/extension/base_handler.py +138 -0
  18. ads/aqua/extension/common_handler.py +21 -0
  19. ads/aqua/extension/deployment_handler.py +202 -0
  20. ads/aqua/extension/evaluation_handler.py +135 -0
  21. ads/aqua/extension/finetune_handler.py +66 -0
  22. ads/aqua/extension/model_handler.py +59 -0
  23. ads/aqua/extension/ui_handler.py +201 -0
  24. ads/aqua/extension/utils.py +23 -0
  25. ads/aqua/finetune.py +579 -0
  26. ads/aqua/job.py +29 -0
  27. ads/aqua/model.py +819 -0
  28. ads/aqua/training/__init__.py +4 -0
  29. ads/aqua/training/exceptions.py +459 -0
  30. ads/aqua/ui.py +453 -0
  31. ads/aqua/utils.py +715 -0
  32. ads/cli.py +37 -6
  33. ads/common/auth.py +7 -0
  34. ads/common/decorator/__init__.py +7 -3
  35. ads/common/decorator/require_nonempty_arg.py +65 -0
  36. ads/common/object_storage_details.py +166 -7
  37. ads/common/oci_client.py +18 -1
  38. ads/common/oci_logging.py +2 -2
  39. ads/common/oci_mixin.py +4 -5
  40. ads/common/serializer.py +34 -5
  41. ads/common/utils.py +75 -10
  42. ads/config.py +40 -1
  43. ads/dataset/correlation_plot.py +10 -12
  44. ads/jobs/ads_job.py +43 -25
  45. ads/jobs/builders/infrastructure/base.py +4 -2
  46. ads/jobs/builders/infrastructure/dsc_job.py +49 -39
  47. ads/jobs/builders/runtimes/base.py +71 -1
  48. ads/jobs/builders/runtimes/container_runtime.py +4 -4
  49. ads/jobs/builders/runtimes/pytorch_runtime.py +10 -63
  50. ads/jobs/templates/driver_pytorch.py +27 -10
  51. ads/model/artifact_downloader.py +84 -14
  52. ads/model/artifact_uploader.py +25 -23
  53. ads/model/datascience_model.py +388 -38
  54. ads/model/deployment/model_deployment.py +10 -2
  55. ads/model/generic_model.py +8 -0
  56. ads/model/model_file_description_schema.json +68 -0
  57. ads/model/model_metadata.py +1 -1
  58. ads/model/service/oci_datascience_model.py +34 -5
  59. ads/opctl/config/merger.py +2 -2
  60. ads/opctl/operator/__init__.py +3 -1
  61. ads/opctl/operator/cli.py +7 -1
  62. ads/opctl/operator/cmd.py +3 -3
  63. ads/opctl/operator/common/errors.py +2 -1
  64. ads/opctl/operator/common/operator_config.py +22 -3
  65. ads/opctl/operator/common/utils.py +16 -0
  66. ads/opctl/operator/lowcode/anomaly/MLoperator +15 -0
  67. ads/opctl/operator/lowcode/anomaly/README.md +209 -0
  68. ads/opctl/operator/lowcode/anomaly/__init__.py +5 -0
  69. ads/opctl/operator/lowcode/anomaly/__main__.py +104 -0
  70. ads/opctl/operator/lowcode/anomaly/cmd.py +35 -0
  71. ads/opctl/operator/lowcode/anomaly/const.py +88 -0
  72. ads/opctl/operator/lowcode/anomaly/environment.yaml +12 -0
  73. ads/opctl/operator/lowcode/anomaly/model/__init__.py +5 -0
  74. ads/opctl/operator/lowcode/anomaly/model/anomaly_dataset.py +147 -0
  75. ads/opctl/operator/lowcode/anomaly/model/automlx.py +89 -0
  76. ads/opctl/operator/lowcode/anomaly/model/autots.py +103 -0
  77. ads/opctl/operator/lowcode/anomaly/model/base_model.py +354 -0
  78. ads/opctl/operator/lowcode/anomaly/model/factory.py +67 -0
  79. ads/opctl/operator/lowcode/anomaly/model/tods.py +119 -0
  80. ads/opctl/operator/lowcode/anomaly/operator_config.py +105 -0
  81. ads/opctl/operator/lowcode/anomaly/schema.yaml +359 -0
  82. ads/opctl/operator/lowcode/anomaly/utils.py +81 -0
  83. ads/opctl/operator/lowcode/common/__init__.py +5 -0
  84. ads/opctl/operator/lowcode/common/const.py +10 -0
  85. ads/opctl/operator/lowcode/common/data.py +96 -0
  86. ads/opctl/operator/lowcode/common/errors.py +41 -0
  87. ads/opctl/operator/lowcode/common/transformations.py +191 -0
  88. ads/opctl/operator/lowcode/common/utils.py +250 -0
  89. ads/opctl/operator/lowcode/forecast/README.md +3 -2
  90. ads/opctl/operator/lowcode/forecast/__main__.py +18 -2
  91. ads/opctl/operator/lowcode/forecast/cmd.py +8 -7
  92. ads/opctl/operator/lowcode/forecast/const.py +17 -1
  93. ads/opctl/operator/lowcode/forecast/environment.yaml +3 -2
  94. ads/opctl/operator/lowcode/forecast/model/arima.py +106 -117
  95. ads/opctl/operator/lowcode/forecast/model/automlx.py +204 -180
  96. ads/opctl/operator/lowcode/forecast/model/autots.py +144 -253
  97. ads/opctl/operator/lowcode/forecast/model/base_model.py +326 -259
  98. ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py +325 -176
  99. ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +293 -237
  100. ads/opctl/operator/lowcode/forecast/model/prophet.py +191 -208
  101. ads/opctl/operator/lowcode/forecast/operator_config.py +24 -33
  102. ads/opctl/operator/lowcode/forecast/schema.yaml +116 -29
  103. ads/opctl/operator/lowcode/forecast/utils.py +186 -356
  104. ads/opctl/operator/lowcode/pii/model/guardrails.py +18 -15
  105. ads/opctl/operator/lowcode/pii/model/report.py +7 -7
  106. ads/opctl/operator/lowcode/pii/operator_config.py +1 -8
  107. ads/opctl/operator/lowcode/pii/utils.py +0 -82
  108. ads/opctl/operator/runtime/runtime.py +3 -2
  109. ads/telemetry/base.py +62 -0
  110. ads/telemetry/client.py +105 -0
  111. ads/telemetry/telemetry.py +6 -3
  112. {oracle_ads-2.10.0.dist-info → oracle_ads-2.11.0.dist-info}/METADATA +44 -7
  113. {oracle_ads-2.10.0.dist-info → oracle_ads-2.11.0.dist-info}/RECORD +116 -59
  114. ads/opctl/operator/lowcode/forecast/model/transformations.py +0 -125
  115. {oracle_ads-2.10.0.dist-info → oracle_ads-2.11.0.dist-info}/LICENSE.txt +0 -0
  116. {oracle_ads-2.10.0.dist-info → oracle_ads-2.11.0.dist-info}/WHEEL +0 -0
  117. {oracle_ads-2.10.0.dist-info → oracle_ads-2.11.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,59 @@
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
+ from urllib.parse import urlparse
7
+
8
+ from tornado.web import HTTPError
9
+
10
+ from ads.aqua.decorator import handle_exceptions
11
+ from ads.aqua.extension.base_handler import AquaAPIhandler
12
+ from ads.aqua.model import AquaModelApp
13
+
14
+
15
+ class AquaModelHandler(AquaAPIhandler):
16
+ """Handler for Aqua Model REST APIs."""
17
+
18
+ @handle_exceptions
19
+ def get(self, model_id=""):
20
+ """Handle GET request."""
21
+ if not model_id:
22
+ return self.list()
23
+ return self.read(model_id)
24
+
25
+ def read(self, model_id):
26
+ """Read the information of an Aqua model."""
27
+ return self.finish(AquaModelApp().get(model_id))
28
+
29
+ @handle_exceptions
30
+ def delete(self, id=""):
31
+ """Handles DELETE request for clearing cache"""
32
+ url_parse = urlparse(self.request.path)
33
+ paths = url_parse.path.strip("/")
34
+ if paths.startswith("aqua/model/cache"):
35
+ return self.finish(AquaModelApp().clear_model_list_cache())
36
+ else:
37
+ raise HTTPError(400, f"The request {self.request.path} is invalid.")
38
+
39
+ def list(self):
40
+ """List Aqua models."""
41
+ compartment_id = self.get_argument("compartment_id", default=None)
42
+ # project_id is no needed.
43
+ project_id = self.get_argument("project_id", default=None)
44
+ return self.finish(AquaModelApp().list(compartment_id, project_id))
45
+
46
+ class AquaModelLicenseHandler(AquaAPIhandler):
47
+ """Handler for Aqua Model license REST APIs."""
48
+
49
+ @handle_exceptions
50
+ def get(self, model_id):
51
+ """Handle GET request."""
52
+
53
+ model_id = model_id.split("/")[0]
54
+ return self.finish(AquaModelApp().load_license(model_id))
55
+
56
+ __handlers__ = [
57
+ ("model/?([^/]*)", AquaModelHandler),
58
+ ("model/?([^/]*)/license", AquaModelLicenseHandler),
59
+ ]
@@ -0,0 +1,201 @@
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
+ from urllib.parse import urlparse
7
+
8
+ from tornado.web import HTTPError
9
+
10
+ from ads.aqua.data import Tags
11
+ from ads.aqua.decorator import handle_exceptions
12
+ from ads.aqua.extension.base_handler import AquaAPIhandler
13
+ from ads.aqua.ui import AquaUIApp
14
+ from ads.config import COMPARTMENT_OCID
15
+
16
+
17
+ class AquaUIHandler(AquaAPIhandler):
18
+ """
19
+ Handler for Aqua UI REST APIs.
20
+
21
+ Methods
22
+ -------
23
+ get(self, id="")
24
+ Routes the request to fetch log groups, log ids details or compartments
25
+ list_log_groups(self, id: str)
26
+ Reads the AQUA deployment information.
27
+ list_logs(self, log_group_id: str, **kwargs)
28
+ Lists the specified log group's log objects.
29
+ list_compartments(self, **kwargs)
30
+ Lists the compartments in a compartment specified by ODSC_MODEL_COMPARTMENT_OCID env variable.
31
+
32
+ Raises
33
+ ------
34
+ HTTPError: For various failure scenarios such as invalid input format, missing data, etc.
35
+ """
36
+
37
+ def get(self, id=""):
38
+ """Handle GET request."""
39
+ url_parse = urlparse(self.request.path)
40
+ paths = url_parse.path.strip("/")
41
+ if paths.startswith("aqua/logging"):
42
+ if not id:
43
+ return self.list_log_groups()
44
+ return self.list_logs(id)
45
+ elif paths.startswith("aqua/compartments/default"):
46
+ return self.get_default_compartment()
47
+ elif paths.startswith("aqua/compartments"):
48
+ return self.list_compartments()
49
+ elif paths.startswith("aqua/experiment"):
50
+ return self.list_experiments()
51
+ elif paths.startswith("aqua/versionsets"):
52
+ return self.list_model_version_sets()
53
+ elif paths.startswith("aqua/buckets"):
54
+ return self.list_buckets()
55
+ elif paths.startswith("aqua/job/shapes"):
56
+ return self.list_job_shapes()
57
+ elif paths.startswith("aqua/vcn"):
58
+ return self.list_vcn()
59
+ elif paths.startswith("aqua/subnets"):
60
+ return self.list_subnets()
61
+ elif paths.startswith("aqua/shapes/limit"):
62
+ return self.get_shape_availability()
63
+ elif paths.startswith("aqua/bucket/versioning"):
64
+ return self.is_bucket_versioned()
65
+ else:
66
+ raise HTTPError(400, f"The request {self.request.path} is invalid.")
67
+
68
+ @handle_exceptions
69
+ def delete(self, id=""):
70
+ """Handles DELETE request for clearing cache"""
71
+ # todo: added for dev work, to be deleted if there's no feature to refresh cache in Aqua
72
+ url_parse = urlparse(self.request.path)
73
+ paths = url_parse.path.strip("/")
74
+ if paths.startswith("aqua/compartments/cache"):
75
+ return self.finish(AquaUIApp().clear_compartments_list_cache())
76
+ else:
77
+ raise HTTPError(400, f"The request {self.request.path} is invalid.")
78
+
79
+ @handle_exceptions
80
+ def list_log_groups(self, **kwargs):
81
+ """Lists all log groups for the specified compartment or tenancy."""
82
+ compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
83
+ return self.finish(
84
+ AquaUIApp().list_log_groups(compartment_id=compartment_id, **kwargs)
85
+ )
86
+
87
+ @handle_exceptions
88
+ def list_logs(self, log_group_id: str, **kwargs):
89
+ """Lists the specified log group's log objects."""
90
+ return self.finish(AquaUIApp().list_logs(log_group_id=log_group_id, **kwargs))
91
+
92
+ @handle_exceptions
93
+ def list_compartments(self):
94
+ """Lists the compartments in a compartment specified by ODSC_MODEL_COMPARTMENT_OCID env variable."""
95
+ return self.finish(AquaUIApp().list_compartments())
96
+
97
+ @handle_exceptions
98
+ def get_default_compartment(self):
99
+ """Returns user compartment ocid."""
100
+ return self.finish(AquaUIApp().get_default_compartment())
101
+
102
+ @handle_exceptions
103
+ def list_model_version_sets(self, **kwargs):
104
+ """Lists all model version sets for the specified compartment or tenancy."""
105
+
106
+ compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
107
+ return self.finish(
108
+ AquaUIApp().list_model_version_sets(
109
+ compartment_id=compartment_id,
110
+ target_tag=Tags.AQUA_FINE_TUNING.value,
111
+ **kwargs,
112
+ )
113
+ )
114
+
115
+ @handle_exceptions
116
+ def list_experiments(self, **kwargs):
117
+ """Lists all experiments for the specified compartment or tenancy."""
118
+
119
+ compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
120
+ return self.finish(
121
+ AquaUIApp().list_model_version_sets(
122
+ compartment_id=compartment_id,
123
+ target_tag=Tags.AQUA_EVALUATION.value,
124
+ **kwargs,
125
+ )
126
+ )
127
+
128
+ @handle_exceptions
129
+ def list_buckets(self, **kwargs):
130
+ """Lists all model version sets for the specified compartment or tenancy."""
131
+ compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
132
+ versioned = self.get_argument("versioned", default=None)
133
+ versioned = True if versioned and versioned.lower() == "true" else False
134
+
135
+ return self.finish(
136
+ AquaUIApp().list_buckets(
137
+ compartment_id=compartment_id, versioned=versioned, **kwargs
138
+ )
139
+ )
140
+
141
+ @handle_exceptions
142
+ def list_job_shapes(self, **kwargs):
143
+ """Lists job shapes available in the specified compartment."""
144
+ compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
145
+ return self.finish(
146
+ AquaUIApp().list_job_shapes(compartment_id=compartment_id, **kwargs)
147
+ )
148
+
149
+ @handle_exceptions
150
+ def list_vcn(self, **kwargs):
151
+ """Lists the virtual cloud networks (VCNs) in the specified compartment."""
152
+ compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
153
+ return self.finish(
154
+ AquaUIApp().list_vcn(compartment_id=compartment_id, **kwargs)
155
+ )
156
+
157
+ @handle_exceptions
158
+ def list_subnets(self, **kwargs):
159
+ """Lists the subnets in the specified VCN and the specified compartment."""
160
+ compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
161
+ vcn_id = self.get_argument("vcn_id")
162
+ return self.finish(
163
+ AquaUIApp().list_subnets(
164
+ compartment_id=compartment_id, vcn_id=vcn_id, **kwargs
165
+ )
166
+ )
167
+
168
+ @handle_exceptions
169
+ def get_shape_availability(self, **kwargs):
170
+ """For a given compartmentId, resource limit name, and scope, returns the number of available resources associated
171
+ with the given limit."""
172
+ compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
173
+ instance_shape = self.get_argument("instance_shape")
174
+
175
+ return self.finish(
176
+ AquaUIApp().get_shape_availability(
177
+ compartment_id=compartment_id, instance_shape=instance_shape, **kwargs
178
+ )
179
+ )
180
+
181
+ @handle_exceptions
182
+ def is_bucket_versioned(self):
183
+ """For a given compartmentId, resource limit name, and scope, returns the number of available resources associated
184
+ with the given limit."""
185
+ bucket_uri = self.get_argument("bucket_uri")
186
+ return self.finish(AquaUIApp().is_bucket_versioned(bucket_uri=bucket_uri))
187
+
188
+
189
+ __handlers__ = [
190
+ ("logging/?([^/]*)", AquaUIHandler),
191
+ ("compartments/?([^/]*)", AquaUIHandler),
192
+ # TODO: change url to evaluation/experiements/?([^/]*)
193
+ ("experiment/?([^/]*)", AquaUIHandler),
194
+ ("versionsets/?([^/]*)", AquaUIHandler),
195
+ ("buckets/?([^/]*)", AquaUIHandler),
196
+ ("job/shapes/?([^/]*)", AquaUIHandler),
197
+ ("vcn/?([^/]*)", AquaUIHandler),
198
+ ("subnets/?([^/]*)", AquaUIHandler),
199
+ ("shapes/limit/?([^/]*)", AquaUIHandler),
200
+ ("bucket/versioning/?([^/]*)", AquaUIHandler),
201
+ ]
@@ -0,0 +1,23 @@
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
+ from dataclasses import fields
6
+ from typing import Dict, Optional
7
+ from requests import HTTPError
8
+
9
+ from ads.aqua.extension.base_handler import Errors
10
+
11
+
12
+ def validate_function_parameters(data_class, input_data: Dict):
13
+ """Validates if the required parameters are provided in input data."""
14
+ required_parameters = [
15
+ field.name for field in fields(data_class)
16
+ if field.type != Optional[field.type]
17
+ ]
18
+
19
+ for required_parameter in required_parameters:
20
+ if not input_data.get(required_parameter):
21
+ raise HTTPError(
22
+ 400, Errors.MISSING_REQUIRED_PARAMETER.format(required_parameter)
23
+ )