Skip to content

Commit 93609fa

Browse files
committed
Fix UTs and add supported arm shape sizes
1 parent f302387 commit 93609fa

File tree

11 files changed

+158
-63
lines changed

11 files changed

+158
-63
lines changed

ads/aqua/config/deployment_config_defaults.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
"configs": [
77
{
88
"memory_in_gbs": 128,
9-
"ocpu": 32
9+
"ocpu": 20
1010
},
1111
{
1212
"memory_in_gbs": 256,
13-
"ocpu": 64
13+
"ocpu": 40
1414
},
1515
{
16-
"memory_in_gbs": 512,
17-
"ocpu": 128
16+
"memory_in_gbs": 384,
17+
"ocpu": 60
1818
},
1919
{
20-
"memory_in_gbs": 1024,
21-
"ocpu": 256
20+
"memory_in_gbs": 512,
21+
"ocpu": 80
2222
}
2323
],
2424
"type": "CPU"

ads/aqua/ui.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class Platform(Enum):
5151
def to_dict(self):
5252
return self.value
5353

54+
def __repr__(self):
55+
return repr(self.value)
56+
5457
name: str = None
5558
version: str = None
5659
display_name: str = None

ads/common/object_storage_details.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*--
32

43
# Copyright (c) 2021, 2024 Oracle and/or its affiliates.
54
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
65

76
import json
87
import os
98
import re
9+
from concurrent.futures import ThreadPoolExecutor, as_completed
1010
from dataclasses import dataclass
1111
from typing import Dict, List
1212
from urllib.parse import urlparse
1313

14-
1514
import oci
1615
from ads.common import auth as authutil
1716
from ads.common import oci_client
1817
from ads.dataset.progress import TqdmProgressBar
19-
from concurrent.futures import ThreadPoolExecutor, as_completed
2018

2119
THREAD_POOL_MAX_WORKERS = 10
2220

@@ -169,8 +167,7 @@ def is_bucket_versioned(self) -> bool:
169167

170168
def list_objects(self, **kwargs):
171169
"""Lists objects in a given oss path
172-
173-
Parameters
170+
Parameters
174171
-------
175172
**kwargs:
176173
namespace, bucket, filepath are set by the class. By default, fields gets all values. For other supported

ads/common/serializer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8; -*-
32

43
# Copyright (c) 2021, 2024 Oracle and/or its affiliates.
54
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
@@ -25,10 +24,8 @@
2524
from ads.common.auth import default_signer
2625

2726
try:
28-
from yaml import CSafeDumper as dumper
2927
from yaml import CSafeLoader as loader
3028
except:
31-
from yaml import SafeDumper as dumper
3229
from yaml import SafeLoader as loader
3330

3431

@@ -99,6 +96,8 @@ def serialize(obj):
9996
"""JSON serializer for objects not serializable by default json code."""
10097
if isinstance(obj, datetime):
10198
return obj.isoformat()
99+
if hasattr(obj, "to_dict"):
100+
return obj.to_dict()
102101
raise TypeError(f"Type {type(obj)} not serializable.")
103102

104103
@staticmethod

tests/unitary/with_extras/aqua/test_data/ui/container_index.json

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,44 +63,56 @@
6363
},
6464
"odsc-llama-cpp-serving": [
6565
{
66-
"displayName": "llama.cpp",
67-
"name": "dsmc://odsc-llama-cpp-serving",
66+
"displayName": "LLAMA-CPP:0.2.75",
67+
"modelFormats": [
68+
"GGUF"
69+
],
70+
"name": "iad.ocir.io/ociodscdev/odsc-llama-cpp-python-aio-linux_arm64_v8",
71+
"platforms": [
72+
"ARM_CPU"
73+
],
6874
"type": "inference",
69-
"version": "0.2.75.2"
75+
"version": "0.2.75.5"
7076
}
7177
],
7278
"odsc-llm-evaluate": [
7379
{
7480
"name": "dsmc://odsc-llm-evaluate",
75-
"version": "0.1.2.0"
81+
"version": "0.1.2.1"
7682
}
7783
],
7884
"odsc-llm-fine-tuning": [
7985
{
8086
"name": "dsmc://odsc-llm-fine-tuning",
81-
"version": "1.1.33.34"
87+
"version": "1.1.37.37"
8288
}
8389
],
8490
"odsc-tgi-serving": [
8591
{
86-
"displayName": "TGI:1.4.5",
87-
"name": "dsmc://odsc-tgi-serving",
88-
"type": "inference",
89-
"version": "1.4.5"
90-
},
91-
{
92-
"displayName": "TGI:2.0.2",
93-
"name": "dsmc://odsc-tgi-serving",
92+
"displayName": "TGI:2.0.1",
93+
"modelFormats": [
94+
"SAFETENSORS"
95+
],
96+
"name": "dsmc://odsc-text-generation-inference",
97+
"platforms": [
98+
"NVIDIA_GPU"
99+
],
94100
"type": "inference",
95-
"version": "2.0.2"
101+
"version": "2.0.1.4"
96102
}
97103
],
98104
"odsc-vllm-serving": [
99105
{
100-
"displayName": "VLLM:0.3.0",
106+
"displayName": "VLLM:0.4.1",
107+
"modelFormats": [
108+
"SAFETENSORS"
109+
],
101110
"name": "dsmc://odsc-vllm-serving",
111+
"platforms": [
112+
"NVIDIA_GPU"
113+
],
102114
"type": "inference",
103-
"version": "0.3.0.7"
115+
"version": "0.4.1.3"
104116
}
105117
]
106118
}

tests/unitary/with_extras/aqua/test_decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def setUp(self, ipython_init_mock) -> None:
126126
"status": 500,
127127
"message": "Internal Server Error",
128128
"service_payload": {},
129-
"reason": f"MultipartUploadError: MultipartUploadError exception has occured. {UPLOAD_MANAGER_DEBUG_INFORMATION_LOG}",
129+
"reason": f"MultipartUploadError: MultipartUploadError exception has occurred. {UPLOAD_MANAGER_DEBUG_INFORMATION_LOG}",
130130
"request_id": TestDataset.mock_request_id,
131131
},
132132
],

tests/unitary/with_extras/aqua/test_handlers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def tearDownClass(cls):
211211
"load_evaluation_config",
212212
TestDataset.MOCK_OCID,
213213
TestDataset.MOCK_OCID,
214+
"/evaluation/config",
214215
),
215216
(
216217
"AquaEvaluationMetricsHandler",
@@ -219,6 +220,7 @@ def tearDownClass(cls):
219220
"load_metrics",
220221
TestDataset().mock_url("metrics"),
221222
TestDataset.MOCK_OCID,
223+
f"/evaluation/{TestDataset.MOCK_OCID}/metrics",
222224
),
223225
(
224226
"AquaEvaluationReportHandler",
@@ -227,6 +229,7 @@ def tearDownClass(cls):
227229
"download_report",
228230
TestDataset().mock_url("report"),
229231
TestDataset.MOCK_OCID,
232+
f"/evaluation/{TestDataset.MOCK_OCID}/report",
230233
),
231234
(
232235
"AquaEvaluationStatusHandler",
@@ -235,6 +238,7 @@ def tearDownClass(cls):
235238
"get_status",
236239
TestDataset().mock_url("status"),
237240
TestDataset.MOCK_OCID,
241+
f"/aqua/evaluation/{TestDataset.MOCK_OCID}/status",
238242
),
239243
(
240244
"ADSVersionHandler",
@@ -243,6 +247,7 @@ def tearDownClass(cls):
243247
None,
244248
None,
245249
{"data": metadata.version("oracle_ads")},
250+
f"/aqua/ads_version",
246251
),
247252
(
248253
"CompatibilityCheckHandler",
@@ -251,6 +256,7 @@ def tearDownClass(cls):
251256
None,
252257
None,
253258
dict(status="ok"),
259+
"/aqua/hello",
254260
),
255261
(
256262
"AquaModelLicenseHandler",
@@ -259,6 +265,7 @@ def tearDownClass(cls):
259265
"load_license",
260266
TestDataset().mock_url("license"),
261267
TestDataset.MOCK_OCID,
268+
f"/aqua/model/{TestDataset.MOCK_OCID}/license",
262269
),
263270
(
264271
"AquaModelHandler",
@@ -267,6 +274,7 @@ def tearDownClass(cls):
267274
"get",
268275
TestDataset.MOCK_OCID,
269276
TestDataset.MOCK_OCID,
277+
f"/aqua/model/{TestDataset.MOCK_OCID}",
270278
),
271279
(
272280
"AquaModelHandler_list",
@@ -275,6 +283,7 @@ def tearDownClass(cls):
275283
"list",
276284
"",
277285
(None, None),
286+
f"/aqua/model",
278287
),
279288
]
280289
)
@@ -287,6 +296,7 @@ def test_get(
287296
associated_api,
288297
url,
289298
expected_call,
299+
path,
290300
ipython_init_mock,
291301
):
292302
"""Tests invoking GET method successfully."""
@@ -295,6 +305,7 @@ def test_get(
295305
test_instance = target_handler(MagicMock(), MagicMock())
296306
test_instance.finish = MagicMock()
297307
test_instance.request = MagicMock()
308+
test_instance.request.path = path
298309

299310
if associated_api:
300311
with patch.object(target_app, associated_api) as mock_api:

tests/unitary/with_extras/aqua/test_model.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import oci
1313
import pytest
14+
from ads.aqua.ui import ModelFormat
1415
from parameterized import parameterized
1516

1617
import ads.aqua.model
@@ -323,16 +324,17 @@ def test_get_foundation_models(
323324
)
324325

325326
assert asdict(aqua_model) == {
327+
"arm_cpu_supported": False,
326328
"compartment_id": f"{ds_model.compartment_id}",
327-
"console_link": (
328-
f"https://cloud.oracle.com/data-science/models/{ds_model.id}?region={self.app.region}",
329-
),
329+
"console_link": f"https://cloud.oracle.com/data-science/models/{ds_model.id}?region={self.app.region}",
330330
"icon": "",
331331
"id": f"{ds_model.id}",
332332
"is_fine_tuned_model": False,
333333
"license": f'{ds_model.freeform_tags["license"]}',
334334
"model_card": f"{mock_read_file.return_value}",
335+
"model_format": ModelFormat.SAFETENSORS,
335336
"name": f"{ds_model.display_name}",
337+
"nvidia_gpu_supported": False,
336338
"organization": f'{ds_model.freeform_tags["organization"]}',
337339
"project_id": f"{ds_model.project_id}",
338340
"ready_to_deploy": False if foundation_model_type == "verified" else True,
@@ -464,10 +466,9 @@ def test_get_model_fine_tuned(
464466
mock_query_resource.assert_called()
465467

466468
assert asdict(model) == {
469+
"arm_cpu_supported": False,
467470
"compartment_id": f"{ds_model.compartment_id}",
468-
"console_link": (
469-
f"https://cloud.oracle.com/data-science/models/{ds_model.id}?region={self.app.region}",
470-
),
471+
"console_link": f"https://cloud.oracle.com/data-science/models/{ds_model.id}?region={self.app.region}",
471472
"dataset": "test_training_data",
472473
"experiment": {"id": "", "name": "", "url": ""},
473474
"icon": "",
@@ -504,7 +505,9 @@ def test_get_model_fine_tuned(
504505
},
505506
],
506507
"model_card": f"{mock_read_file.return_value}",
508+
"model_format": ModelFormat.SAFETENSORS,
507509
"name": f"{ds_model.display_name}",
510+
"nvidia_gpu_supported": False,
508511
"organization": "test_organization",
509512
"project_id": f"{ds_model.project_id}",
510513
"ready_to_deploy": True,
@@ -564,6 +567,7 @@ def test_import_verified_model(
564567
ds_freeform_tags = {
565568
"OCI_AQUA": "ACTIVE",
566569
"license": "aqua-license",
570+
"model_format": "SAFETENSORS",
567571
"organization": "oracle",
568572
"task": "text-generation",
569573
"ready_to_import": "true",
@@ -762,6 +766,7 @@ def test_import_any_model_smc_container(
762766
)
763767
assert model.tags == {
764768
"aqua_custom_base_model": "true",
769+
"model_format": "SAFETENSORS",
765770
"ready_to_fine_tune": "true",
766771
**ds_freeform_tags,
767772
}

tests/unitary/with_extras/aqua/test_model_handler.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*--
3-
3+
import json
4+
import os
45
# Copyright (c) 2024 Oracle and/or its affiliates.
56
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
67

@@ -23,13 +24,19 @@ def setUp(self, ipython_init_mock) -> None:
2324
self.model_handler = AquaModelHandler(MagicMock(), MagicMock())
2425
self.model_handler.request = MagicMock()
2526

27+
@patch("ads.aqua.extension.model_handler.urlparse")
2628
@patch.object(AquaModelHandler, "list")
27-
def test_get_no_id(self, mock_list):
29+
def test_get_no_id(self, mock_list, mock_urlparse):
30+
request_path = MagicMock(path="aqua/model")
31+
mock_urlparse.return_value = request_path
2832
self.model_handler.get()
2933
mock_list.assert_called()
3034

35+
@patch("ads.aqua.extension.model_handler.urlparse")
3136
@patch.object(AquaModelHandler, "read")
32-
def test_get_with_id(self, mock_read):
37+
def test_get_with_id(self, mock_read, mock_urlparse):
38+
request_path = MagicMock(path="aqua/model/test_model_id")
39+
mock_urlparse.return_value = request_path
3340
self.model_handler.get(model_id="test_model_id")
3441
mock_read.assert_called_with("test_model_id")
3542

@@ -99,6 +106,7 @@ def test_register(self, mock_register, mock_finish):
99106
finetuning_container=None,
100107
compartment_id=None,
101108
project_id=None,
109+
model_file=None,
102110
)
103111
assert result["id"] == "test_id"
104112
assert result["inference_container"] == "odsc-tgi-serving"

0 commit comments

Comments
 (0)