oracle-ads 2.11.17__py3-none-any.whl → 2.11.19__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 (44) hide show
  1. ads/aqua/common/utils.py +20 -3
  2. ads/aqua/config/__init__.py +4 -0
  3. ads/aqua/config/config.py +28 -0
  4. ads/aqua/config/evaluation/__init__.py +4 -0
  5. ads/aqua/config/evaluation/evaluation_service_config.py +282 -0
  6. ads/aqua/config/evaluation/evaluation_service_model_config.py +8 -0
  7. ads/aqua/config/utils/__init__.py +4 -0
  8. ads/aqua/config/utils/serializer.py +339 -0
  9. ads/aqua/constants.py +1 -1
  10. ads/aqua/evaluation/entities.py +1 -0
  11. ads/aqua/evaluation/evaluation.py +56 -88
  12. ads/aqua/extension/common_handler.py +2 -3
  13. ads/aqua/extension/common_ws_msg_handler.py +2 -2
  14. ads/aqua/extension/evaluation_handler.py +4 -3
  15. ads/aqua/extension/model_handler.py +26 -1
  16. ads/aqua/extension/utils.py +12 -1
  17. ads/aqua/modeldeployment/deployment.py +31 -51
  18. ads/aqua/ui.py +27 -25
  19. ads/common/auth.py +4 -4
  20. ads/jobs/builders/infrastructure/dsc_job.py +11 -5
  21. ads/jobs/builders/infrastructure/dsc_job_runtime.py +12 -25
  22. ads/jobs/builders/runtimes/artifact.py +0 -5
  23. ads/jobs/builders/runtimes/container_runtime.py +26 -3
  24. ads/opctl/conda/cmds.py +100 -42
  25. ads/opctl/conda/pack.py +3 -2
  26. ads/opctl/operator/lowcode/anomaly/const.py +1 -0
  27. ads/opctl/operator/lowcode/anomaly/model/base_model.py +58 -37
  28. ads/opctl/operator/lowcode/anomaly/model/factory.py +2 -0
  29. ads/opctl/operator/lowcode/anomaly/model/randomcutforest.py +116 -0
  30. ads/opctl/operator/lowcode/anomaly/schema.yaml +1 -0
  31. ads/opctl/operator/lowcode/forecast/const.py +1 -1
  32. ads/opctl/operator/lowcode/forecast/model/arima.py +6 -2
  33. ads/opctl/operator/lowcode/forecast/model/automlx.py +6 -1
  34. ads/opctl/operator/lowcode/forecast/model/autots.py +3 -1
  35. ads/opctl/operator/lowcode/forecast/model/factory.py +1 -1
  36. ads/opctl/operator/lowcode/forecast/model/ml_forecast.py +24 -15
  37. ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +6 -1
  38. ads/opctl/operator/lowcode/forecast/model/prophet.py +3 -1
  39. ads/opctl/operator/lowcode/forecast/schema.yaml +1 -1
  40. {oracle_ads-2.11.17.dist-info → oracle_ads-2.11.19.dist-info}/METADATA +5 -1
  41. {oracle_ads-2.11.17.dist-info → oracle_ads-2.11.19.dist-info}/RECORD +44 -37
  42. {oracle_ads-2.11.17.dist-info → oracle_ads-2.11.19.dist-info}/LICENSE.txt +0 -0
  43. {oracle_ads-2.11.17.dist-info → oracle_ads-2.11.19.dist-info}/WHEEL +0 -0
  44. {oracle_ads-2.11.17.dist-info → oracle_ads-2.11.19.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,339 @@
1
+ #!/usr/bin/env python
2
+
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
+ import json
7
+ from typing import Union
8
+ from urllib.parse import urlparse
9
+
10
+ import fsspec
11
+ import yaml
12
+ from pydantic import BaseModel
13
+ from yaml import SafeLoader as Loader
14
+
15
+ from ads.common.auth import default_signer
16
+
17
+
18
+ class Serializable(BaseModel):
19
+ """Base class that represents a serializable item.
20
+
21
+ Methods
22
+ -------
23
+ to_json(self, uri=None, **kwargs)
24
+ Returns object serialized as a JSON string
25
+ from_json(cls, json_string=None, uri=None, **kwargs)
26
+ Creates an object from JSON string provided or from URI location containing JSON string
27
+ to_yaml(self, uri=None, **kwargs)
28
+ Returns object serialized as a YAML string
29
+ from_yaml(cls, yaml_string=None, uri=None, **kwargs)
30
+ Creates an object from YAML string provided or from URI location containing YAML string
31
+ """
32
+
33
+ @staticmethod
34
+ def _write_to_file(s: str, uri: str, **kwargs) -> None:
35
+ """Write string s into location specified by uri.
36
+
37
+ Parameters
38
+ ----------
39
+ s: (string)
40
+ content
41
+ uri: (string)
42
+ URI location to save string s
43
+ kwargs : dict
44
+ keyword arguments to be passed into fsspec.open().
45
+ For OCI object storage, this can be config="path/to/.oci/config".
46
+
47
+ Returns
48
+ -------
49
+ None
50
+ Nothing
51
+ """
52
+
53
+ overwrite = kwargs.pop("overwrite", True)
54
+ if not overwrite:
55
+ dst_path_scheme = urlparse(uri).scheme or "file"
56
+ if fsspec.filesystem(dst_path_scheme, **kwargs).exists(uri):
57
+ raise FileExistsError(
58
+ f"The `{uri}` is already exists. Set `overwrite` to True "
59
+ "if you wish to overwrite."
60
+ )
61
+
62
+ with fsspec.open(uri, "w", **kwargs) as f:
63
+ f.write(s)
64
+
65
+ @staticmethod
66
+ def _read_from_file(uri: str, **kwargs) -> str:
67
+ """Returns contents from location specified by URI
68
+
69
+ Parameters
70
+ ----------
71
+ uri: (string)
72
+ URI location
73
+ kwargs : dict
74
+ keyword arguments to be passed into fsspec.open().
75
+ For OCI object storage, this can be config="path/to/.oci/config".
76
+
77
+ Returns
78
+ -------
79
+ string: Contents in file specified by URI
80
+ """
81
+ # Add default signer if the uri is an object storage uri, and
82
+ # the user does not specify config or signer.
83
+ if (
84
+ uri.startswith("oci://")
85
+ and "config" not in kwargs
86
+ and "signer" not in kwargs
87
+ ):
88
+ kwargs.update(default_signer())
89
+ with fsspec.open(uri, "r", **kwargs) as f:
90
+ return f.read()
91
+
92
+ def to_json(
93
+ self,
94
+ uri: str = None,
95
+ encoder: callable = json.JSONEncoder,
96
+ default: callable = None,
97
+ **kwargs,
98
+ ) -> str:
99
+ """Returns object serialized as a JSON string
100
+
101
+ Parameters
102
+ ----------
103
+ uri: (string, optional)
104
+ URI location to save the JSON string. Defaults to None.
105
+ encoder: (callable, optional)
106
+ Encoder for custom data structures. Defaults to JSONEncoder.
107
+ default: (callable, optional)
108
+ A function that gets called for objects that can't otherwise be serialized.
109
+ It should return JSON-serializable version of the object or original object.
110
+
111
+ kwargs
112
+ ------
113
+ overwrite: (bool, optional). Defaults to True.
114
+ Whether to overwrite existing file or not.
115
+
116
+ keyword arguments to be passed into fsspec.open().
117
+ For OCI object storage, this could be config="path/to/.oci/config".
118
+ For other storage connections consider e.g. host, port, username, password, etc.
119
+
120
+ Returns
121
+ -------
122
+ Union[str, None]
123
+ Serialized version of object.
124
+ `None` in case when `uri` provided.
125
+ """
126
+ json_string = json.dumps(
127
+ self.model_dump(exclude_none=kwargs.pop("exclude_none", False)),
128
+ cls=encoder,
129
+ default=default,
130
+ )
131
+ if uri:
132
+ self._write_to_file(s=json_string, uri=uri, **kwargs)
133
+ return None
134
+ return json_string
135
+
136
+ def to_dict(self) -> dict:
137
+ """Returns object serialized as a dictionary
138
+
139
+ Returns
140
+ -------
141
+ dict
142
+ Serialized version of object
143
+ """
144
+ return json.loads(self.to_json())
145
+
146
+ @classmethod
147
+ def from_json(
148
+ cls,
149
+ json_string: str = None,
150
+ uri: str = None,
151
+ decoder: callable = json.JSONDecoder,
152
+ **kwargs,
153
+ ):
154
+ """Creates an object from JSON string provided or from URI location containing JSON string
155
+
156
+ Parameters
157
+ ----------
158
+ json_string: (string, optional)
159
+ JSON string. Defaults to None.
160
+ uri: (string, optional)
161
+ URI location of file containing JSON string. Defaults to None.
162
+ decoder: (callable, optional)
163
+ Custom decoder. Defaults to simple JSON decoder.
164
+ kwargs
165
+ ------
166
+ keyword arguments to be passed into fsspec.open(). For OCI object storage, this should be config="path/to/.oci/config".
167
+ For other storage connections consider e.g. host, port, username, password, etc.
168
+
169
+ Raises
170
+ ------
171
+ ValueError
172
+ Raised if neither string nor uri is provided
173
+
174
+ Returns
175
+ -------
176
+ cls
177
+ Returns instance of the class
178
+ """
179
+ if json_string:
180
+ return cls(**json.loads(json_string, cls=decoder))
181
+ if uri:
182
+ return cls(**json.loads(cls._read_from_file(uri, **kwargs), cls=decoder))
183
+ raise ValueError("Must provide either JSON string or URI location")
184
+
185
+ def to_yaml(
186
+ self, uri: str = None, dumper: callable = yaml.SafeDumper, **kwargs
187
+ ) -> Union[str, None]:
188
+ """Returns object serialized as a YAML string
189
+
190
+ Parameters
191
+ ----------
192
+ uri : str, optional
193
+ URI location to save the YAML string, by default None
194
+ dumper : callable, optional
195
+ Custom YAML Dumper, by default yaml.SafeDumper
196
+ kwargs : dict
197
+ overwrite: (bool, optional). Defaults to True.
198
+ Whether to overwrite existing file or not.
199
+ note: (str, optional)
200
+ The note that needs to be added in the beginning of the YAML.
201
+ It will be added as is without any formatting.
202
+ side_effect: Optional[SideEffect]
203
+ side effect to take on the dictionary. The side effect can be either
204
+ convert the dictionary keys to "lower" (SideEffect.CONVERT_KEYS_TO_LOWER.value)
205
+ or "upper"(SideEffect.CONVERT_KEYS_TO_UPPER.value) cases.
206
+
207
+ The other keyword arguments to be passed into fsspec.open().
208
+ For OCI object storage, this could be config="path/to/.oci/config".
209
+
210
+ Returns
211
+ -------
212
+ Union[str, None]
213
+ Serialized version of object.
214
+ `None` in case when `uri` provided.
215
+ """
216
+ note = kwargs.pop("note", "")
217
+
218
+ yaml_string = f"{note}\n" + yaml.dump(
219
+ self.model_dump(exclude_none=kwargs.pop("exclude_none", False)),
220
+ Dumper=dumper,
221
+ )
222
+ if uri:
223
+ self._write_to_file(s=yaml_string, uri=uri, **kwargs)
224
+ return None
225
+
226
+ return yaml_string
227
+
228
+ @classmethod
229
+ def from_yaml(
230
+ cls,
231
+ yaml_string: str = None,
232
+ uri: str = None,
233
+ loader: callable = Loader,
234
+ **kwargs,
235
+ ):
236
+ """Creates an object from YAML string provided or from URI location containing YAML string
237
+
238
+ Parameters
239
+ ----------
240
+ yaml_string (string, optional)
241
+ YAML string. Defaults to None.
242
+ uri (string, optional)
243
+ URI location of file containing YAML string. Defaults to None.
244
+ loader (callable, optional)
245
+ Custom YAML loader. Defaults to CLoader/SafeLoader.
246
+ kwargs (dict)
247
+ keyword arguments to be passed into fsspec.open().
248
+ For OCI object storage, this should be config="path/to/.oci/config".
249
+ For other storage connections consider e.g. host, port, username, password, etc.
250
+
251
+ Raises
252
+ ------
253
+ ValueError
254
+ Raised if neither string nor uri is provided
255
+
256
+ Returns
257
+ -------
258
+ cls
259
+ Returns instance of the class
260
+ """
261
+ if yaml_string:
262
+ return cls(**yaml.load(yaml_string, Loader=loader))
263
+ if uri:
264
+ return cls(
265
+ **yaml.load(cls._read_from_file(uri=uri, **kwargs), Loader=loader)
266
+ )
267
+ raise ValueError("Must provide either YAML string or URI location")
268
+
269
+ @classmethod
270
+ def schema_to_yaml(cls, uri: str = None, **kwargs) -> Union[str, None]:
271
+ """Returns the schema serialized as a YAML string
272
+
273
+ Parameters
274
+ ----------
275
+ uri : str, optional
276
+ URI location to save the YAML string, by default None
277
+ dumper : callable, optional
278
+ Custom YAML Dumper, by default yaml.SafeDumper
279
+ kwargs : dict
280
+ overwrite: (bool, optional). Defaults to True.
281
+ Whether to overwrite existing file or not.
282
+ Returns
283
+ -------
284
+ Union[str, None]
285
+ Serialized schema.
286
+ `None` in case when `uri` provided.
287
+ """
288
+ yaml_string = yaml.dump(cls.model_json_schema(), sort_keys=False)
289
+
290
+ if uri:
291
+ cls._write_to_file(s=yaml_string, uri=uri, **kwargs)
292
+ return None
293
+
294
+ return yaml_string
295
+
296
+ @classmethod
297
+ def schema_to_json(
298
+ cls,
299
+ uri: str = None,
300
+ encoder: callable = json.JSONEncoder,
301
+ default: callable = None,
302
+ **kwargs,
303
+ ) -> Union[str, None]:
304
+ """Returns the schema serialized as a JSON string
305
+
306
+ Parameters
307
+ ----------
308
+ uri: (string, optional)
309
+ URI location to save the JSON string. Defaults to None.
310
+ encoder: (callable, optional)
311
+ Encoder for custom data structures. Defaults to JSONEncoder.
312
+ default: (callable, optional)
313
+ A function that gets called for objects that can't otherwise be serialized.
314
+ It should return JSON-serializable version of the object or original object.
315
+
316
+ kwargs
317
+ ------
318
+ overwrite: (bool, optional). Defaults to True.
319
+ Whether to overwrite existing file or not.
320
+
321
+ keyword arguments to be passed into fsspec.open().
322
+ For OCI object storage, this could be config="path/to/.oci/config".
323
+ For other storage connections consider e.g. host, port, username, password, etc.
324
+
325
+ Returns
326
+ -------
327
+ Union[str, None]
328
+ Serialized version of object.
329
+ `None` in case when `uri` provided.
330
+ """
331
+ json_string = json.dumps(
332
+ cls.model_json_schema(),
333
+ cls=encoder,
334
+ default=default,
335
+ )
336
+ if uri:
337
+ cls._write_to_file(s=json_string, uri=uri, **kwargs)
338
+ return None
339
+ return json_string
ads/aqua/constants.py CHANGED
@@ -24,7 +24,7 @@ DEFAULT_FT_VALIDATION_SET_SIZE = 0.1
24
24
  MAXIMUM_ALLOWED_DATASET_IN_BYTE = 52428800 # 1024 x 1024 x 50 = 50MB
25
25
  JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING = "ME_STANDALONE"
26
26
  NB_SESSION_IDENTIFIER = "NB_SESSION_OCID"
27
- LIFECYCLE_DETAILS_MISSING_JOBRUN = "The asscociated JobRun resource has been deleted."
27
+ LIFECYCLE_DETAILS_MISSING_JOBRUN = "The associated JobRun resource has been deleted."
28
28
  READY_TO_DEPLOY_STATUS = "ACTIVE"
29
29
  READY_TO_FINE_TUNE_STATUS = "TRUE"
30
30
  AQUA_GA_LIST = ["id19sfcrra6z"]
@@ -102,6 +102,7 @@ class ModelParams(DataClassSerializable):
102
102
  presence_penalty: Optional[float] = 0.0
103
103
  frequency_penalty: Optional[float] = 0.0
104
104
  stop: Optional[Union[str, List[str]]] = field(default_factory=list)
105
+ model: Optional[str] = "odsc-llm"
105
106
 
106
107
 
107
108
  @dataclass(repr=False)
@@ -11,7 +11,7 @@ from dataclasses import asdict, fields
11
11
  from datetime import datetime, timedelta
12
12
  from pathlib import Path
13
13
  from threading import Lock
14
- from typing import Any, Dict, List, Union
14
+ from typing import Any, Dict, List, Optional, Union
15
15
 
16
16
  import oci
17
17
  from cachetools import TTLCache
@@ -45,6 +45,8 @@ from ads.aqua.common.utils import (
45
45
  is_valid_ocid,
46
46
  upload_local_to_os,
47
47
  )
48
+ from ads.aqua.config.config import get_evaluation_service_config
49
+ from ads.aqua.config.evaluation.evaluation_service_config import EvaluationServiceConfig
48
50
  from ads.aqua.constants import (
49
51
  CONSOLE_LINK_RESOURCE_TYPE_MAPPING,
50
52
  EVALUATION_REPORT,
@@ -170,8 +172,19 @@ class AquaEvaluationApp(AquaApp):
170
172
  f"Invalid evaluation source {create_aqua_evaluation_details.evaluation_source_id}. "
171
173
  "Specify either a model or model deployment id."
172
174
  )
175
+
176
+ # The model to evaluate
173
177
  evaluation_source = None
174
- eval_inference_configuration = None
178
+ # The evaluation service config
179
+ evaluation_config: EvaluationServiceConfig = get_evaluation_service_config()
180
+ # The evaluation inference configuration. The inference configuration will be extracted
181
+ # based on the inferencing container family.
182
+ eval_inference_configuration: Dict = {}
183
+ # The evaluation inference model sampling params. The system parameters that will not be
184
+ # visible for user, but will be applied implicitly for evaluation. The service model params
185
+ # will be extracted based on the container family and version.
186
+ eval_inference_service_model_params: Dict = {}
187
+
175
188
  if (
176
189
  DataScienceResource.MODEL_DEPLOYMENT
177
190
  in create_aqua_evaluation_details.evaluation_source_id
@@ -187,17 +200,32 @@ class AquaEvaluationApp(AquaApp):
187
200
  runtime = ModelDeploymentContainerRuntime.from_dict(
188
201
  evaluation_source.runtime.to_dict()
189
202
  )
190
- inference_config = AquaContainerConfig.from_container_index_json(
203
+ container_config = AquaContainerConfig.from_container_index_json(
191
204
  enable_spec=True
192
- ).inference
193
- for container in inference_config.values():
194
- if container.name == runtime.image[:runtime.image.rfind(":")]:
205
+ )
206
+ for (
207
+ inference_container_family,
208
+ inference_container_info,
209
+ ) in container_config.inference.items():
210
+ if (
211
+ inference_container_info.name
212
+ == runtime.image[: runtime.image.rfind(":")]
213
+ ):
195
214
  eval_inference_configuration = (
196
- container.spec.evaluation_configuration
215
+ evaluation_config.get_merged_inference_params(
216
+ inference_container_family
217
+ ).to_dict()
197
218
  )
219
+ eval_inference_service_model_params = (
220
+ evaluation_config.get_merged_inference_model_params(
221
+ inference_container_family,
222
+ inference_container_info.version,
223
+ )
224
+ )
225
+
198
226
  except Exception:
199
227
  logger.debug(
200
- f"Could not load inference config details for the evaluation id: "
228
+ f"Could not load inference config details for the evaluation source id: "
201
229
  f"{create_aqua_evaluation_details.evaluation_source_id}. Please check if the container"
202
230
  f" runtime has the correct SMC image information."
203
231
  )
@@ -414,11 +442,12 @@ class AquaEvaluationApp(AquaApp):
414
442
  container_image=container_image,
415
443
  dataset_path=evaluation_dataset_path,
416
444
  report_path=create_aqua_evaluation_details.report_path,
417
- model_parameters=create_aqua_evaluation_details.model_parameters,
445
+ model_parameters={
446
+ **eval_inference_service_model_params,
447
+ **create_aqua_evaluation_details.model_parameters,
448
+ },
418
449
  metrics=create_aqua_evaluation_details.metrics,
419
- inference_configuration=eval_inference_configuration.to_filtered_dict()
420
- if eval_inference_configuration
421
- else {},
450
+ inference_configuration=eval_inference_configuration or {},
422
451
  )
423
452
  ).create(**kwargs) ## TODO: decide what parameters will be needed
424
453
  logger.debug(
@@ -901,48 +930,8 @@ class AquaEvaluationApp(AquaApp):
901
930
 
902
931
  def get_supported_metrics(self) -> dict:
903
932
  """Gets a list of supported metrics for evaluation."""
904
- # TODO: implement it when starting to support more metrics.
905
933
  return [
906
- {
907
- "use_case": ["text_generation"],
908
- "key": "bertscore",
909
- "name": "bertscore",
910
- "description": (
911
- "BERT Score is a metric for evaluating the quality of text "
912
- "generation models, such as machine translation or summarization. "
913
- "It utilizes pre-trained BERT contextual embeddings for both the "
914
- "generated and reference texts, and then calculates the cosine "
915
- "similarity between these embeddings."
916
- ),
917
- "args": {},
918
- },
919
- {
920
- "use_case": ["text_generation"],
921
- "key": "rouge",
922
- "name": "rouge",
923
- "description": (
924
- "ROUGE scores compare a candidate document to a collection of "
925
- "reference documents to evaluate the similarity between them. "
926
- "The metrics range from 0 to 1, with higher scores indicating "
927
- "greater similarity. ROUGE is more suitable for models that don't "
928
- "include paraphrasing and do not generate new text units that don't "
929
- "appear in the references."
930
- ),
931
- "args": {},
932
- },
933
- {
934
- "use_case": ["text_generation"],
935
- "key": "bleu",
936
- "name": "bleu",
937
- "description": (
938
- "BLEU (Bilingual Evaluation Understudy) is an algorithm for evaluating the "
939
- "quality of text which has been machine-translated from one natural language to another. "
940
- "Quality is considered to be the correspondence between a machine's output and that of a "
941
- "human: 'the closer a machine translation is to a professional human translation, "
942
- "the better it is'."
943
- ),
944
- "args": {},
945
- },
934
+ item.to_dict() for item in get_evaluation_service_config().ui_config.metrics
946
935
  ]
947
936
 
948
937
  @telemetry(entry_point="plugin=evaluation&action=load_metrics", name="aqua")
@@ -1225,45 +1214,24 @@ class AquaEvaluationApp(AquaApp):
1225
1214
  f"Exception message: {ex}"
1226
1215
  )
1227
1216
 
1228
- def load_evaluation_config(self, eval_id):
1217
+ def load_evaluation_config(self, container: Optional[str] = None) -> Dict:
1229
1218
  """Loads evaluation config."""
1219
+
1220
+ # retrieve the evaluation config by container family name
1221
+ evaluation_config = get_evaluation_service_config(container)
1222
+
1223
+ # convert the new config representation to the old one
1230
1224
  return {
1231
- "model_params": {
1232
- "max_tokens": 500,
1233
- "temperature": 0.7,
1234
- "top_p": 1.0,
1235
- "top_k": 50,
1236
- "presence_penalty": 0.0,
1237
- "frequency_penalty": 0.0,
1238
- "stop": [],
1239
- },
1225
+ "model_params": evaluation_config.ui_config.model_params.default,
1240
1226
  "shape": {
1241
- "VM.Standard.E3.Flex": {
1242
- "ocpu": 8,
1243
- "memory_in_gbs": 128,
1244
- "block_storage_size": 200,
1245
- },
1246
- "VM.Standard.E4.Flex": {
1247
- "ocpu": 8,
1248
- "memory_in_gbs": 128,
1249
- "block_storage_size": 200,
1250
- },
1251
- "VM.Standard3.Flex": {
1252
- "ocpu": 8,
1253
- "memory_in_gbs": 128,
1254
- "block_storage_size": 200,
1255
- },
1256
- "VM.Optimized3.Flex": {
1257
- "ocpu": 8,
1258
- "memory_in_gbs": 128,
1259
- "block_storage_size": 200,
1260
- },
1261
- },
1262
- "default": {
1263
- "ocpu": 8,
1264
- "memory_in_gbs": 128,
1265
- "block_storage_size": 200,
1227
+ shape.name: shape.to_dict()
1228
+ for shape in evaluation_config.ui_config.shapes
1266
1229
  },
1230
+ "default": (
1231
+ evaluation_config.ui_config.shapes[0].to_dict()
1232
+ if len(evaluation_config.ui_config.shapes) > 0
1233
+ else {}
1234
+ ),
1267
1235
  }
1268
1236
 
1269
1237
  def _get_attribute_from_model_metadata(
@@ -11,16 +11,15 @@ from huggingface_hub import HfApi
11
11
  from huggingface_hub.utils import LocalTokenNotFoundError
12
12
  from tornado.web import HTTPError
13
13
 
14
- from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID
15
14
  from ads.aqua.common.decorator import handle_exceptions
16
15
  from ads.aqua.common.errors import AquaResourceAccessError, AquaRuntimeError
17
16
  from ads.aqua.common.utils import (
18
- fetch_service_compartment,
19
17
  get_huggingface_login_timeout,
20
18
  known_realm,
21
19
  )
22
20
  from ads.aqua.extension.base_handler import AquaAPIhandler
23
21
  from ads.aqua.extension.errors import Errors
22
+ from ads.aqua.extension.utils import ui_compatability_check
24
23
 
25
24
 
26
25
  class ADSVersionHandler(AquaAPIhandler):
@@ -51,7 +50,7 @@ class CompatibilityCheckHandler(AquaAPIhandler):
51
50
  AquaResourceAccessError: raised when aqua is not accessible in the given session/region.
52
51
 
53
52
  """
54
- if ODSC_MODEL_COMPARTMENT_OCID or fetch_service_compartment():
53
+ if ui_compatability_check():
55
54
  return self.finish({"status": "ok"})
56
55
  elif known_realm():
57
56
  return self.finish({"status": "compatible"})
@@ -7,7 +7,6 @@ import json
7
7
  from importlib import metadata
8
8
  from typing import List, Union
9
9
 
10
- from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID, fetch_service_compartment
11
10
  from ads.aqua.common.decorator import handle_exceptions
12
11
  from ads.aqua.common.errors import AquaResourceAccessError
13
12
  from ads.aqua.common.utils import known_realm
@@ -17,6 +16,7 @@ from ads.aqua.extension.models.ws_models import (
17
16
  CompatibilityCheckResponse,
18
17
  RequestResponseType,
19
18
  )
19
+ from ads.aqua.extension.utils import ui_compatability_check
20
20
 
21
21
 
22
22
  class AquaCommonWsMsgHandler(AquaWSMsgHandler):
@@ -39,7 +39,7 @@ class AquaCommonWsMsgHandler(AquaWSMsgHandler):
39
39
  )
40
40
  return response
41
41
  if request.get("kind") == "CompatibilityCheck":
42
- if ODSC_MODEL_COMPARTMENT_OCID or fetch_service_compartment():
42
+ if ui_compatability_check():
43
43
  return CompatibilityCheckResponse(
44
44
  message_id=request.get("message_id"),
45
45
  kind=RequestResponseType.CompatibilityCheck,
@@ -2,6 +2,7 @@
2
2
  # Copyright (c) 2024 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 Optional
5
6
  from urllib.parse import urlparse
6
7
 
7
8
  from tornado.web import HTTPError
@@ -30,7 +31,7 @@ class AquaEvaluationHandler(AquaAPIhandler):
30
31
  return self.read(eval_id)
31
32
 
32
33
  @handle_exceptions
33
- def post(self, *args, **kwargs):
34
+ def post(self, *args, **kwargs): # noqa
34
35
  """Handles post request for the evaluation APIs
35
36
 
36
37
  Raises
@@ -117,10 +118,10 @@ class AquaEvaluationConfigHandler(AquaAPIhandler):
117
118
  """Handler for Aqua Evaluation Config REST APIs."""
118
119
 
119
120
  @handle_exceptions
120
- def get(self, model_id):
121
+ def get(self, container: Optional[str] = None, **kwargs): # noqa
121
122
  """Handle GET request."""
122
123
 
123
- return self.finish(AquaEvaluationApp().load_evaluation_config(model_id))
124
+ return self.finish(AquaEvaluationApp().load_evaluation_config(container))
124
125
 
125
126
 
126
127
  __handlers__ = [
@@ -9,7 +9,7 @@ from tornado.web import HTTPError
9
9
 
10
10
  from ads.aqua.common.decorator import handle_exceptions
11
11
  from ads.aqua.common.errors import AquaRuntimeError, AquaValueError
12
- from ads.aqua.common.utils import get_hf_model_info
12
+ from ads.aqua.common.utils import get_hf_model_info, list_hf_models
13
13
  from ads.aqua.extension.base_handler import AquaAPIhandler
14
14
  from ads.aqua.extension.errors import Errors
15
15
  from ads.aqua.model import AquaModelApp
@@ -177,6 +177,31 @@ class AquaHuggingFaceHandler(AquaAPIhandler):
177
177
 
178
178
  return None
179
179
 
180
+
181
+
182
+ @handle_exceptions
183
+ def get(self,*args, **kwargs):
184
+ """
185
+ Finds a list of matching models from hugging face based on query string provided from users.
186
+
187
+ Parameters
188
+ ----------
189
+ query (str): The Hugging Face model name to search for.
190
+
191
+ Returns
192
+ -------
193
+ List[str]
194
+ Returns the matching model ids string
195
+ """
196
+
197
+ query=self.get_argument("query",default=None)
198
+ if not query:
199
+ raise HTTPError(400,Errors.MISSING_REQUIRED_PARAMETER.format("query"))
200
+ models=list_hf_models(query)
201
+ return self.finish({"models":models})
202
+
203
+
204
+
180
205
  @handle_exceptions
181
206
  def post(self, *args, **kwargs):
182
207
  """Handles post request for the HF Models APIs