Skip to content

Commit 05e40bc

Browse files
Merge branch 'main' into ODSC-55804/show_in_notebook_fix
2 parents 81c857f + d687593 commit 05e40bc

File tree

5 files changed

+182
-2
lines changed

5 files changed

+182
-2
lines changed

ads/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import fire
1111
from ads.common import logger
12-
from ads.aqua.cli import AquaCommand
1312

1413
try:
1514
import click
@@ -73,6 +72,8 @@ def _SeparateFlagArgs(args):
7372

7473
def cli():
7574
if len(sys.argv) > 1 and sys.argv[1] == "aqua":
75+
from ads.aqua.cli import AquaCommand
76+
7677
fire.Fire(AquaCommand, command=sys.argv[2:], name="ads aqua")
7778
else:
7879
click_cli()

docs/source/release_notes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Release Notes
33
=============
44

5+
2.11.7
6+
------
7+
Release date: April 8, 2024
8+
9+
* Fixed bugs and introduced enhancements following our recent release, which included internal adjustments for future features and updates for the Jupyter Lab 3 upgrade.
10+
11+
512
2.11.6
613
------
714
Release date: April 3, 2024

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ build-backend = "flit_core.buildapi"
2121

2222
# Required
2323
name = "oracle_ads" # the install (PyPI) name; name for local build in [tool.flit.module] section below
24-
version = "2.11.6"
24+
version = "2.11.7"
2525

2626
# Optional
2727
description = "Oracle Accelerated Data Science SDK"
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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/
6+
7+
from unittest import TestCase
8+
from unittest.mock import MagicMock
9+
from mock import patch
10+
11+
from notebook.base.handlers import IPythonHandler
12+
from ads.aqua.extension.finetune_handler import AquaFineTuneHandler
13+
from ads.aqua.finetune import AquaFineTuningApp, CreateFineTuningDetails
14+
15+
16+
class TestDataset:
17+
mock_valid_input = dict(
18+
ft_source_id="ocid1.datasciencemodel.oc1.iad.<OCID>",
19+
ft_name="test_ft_name",
20+
dataset_path="oci://ds_bucket@namespace/prefix/dataset.jsonl",
21+
report_path="oci://report_bucket@namespace/prefix/",
22+
ft_parameters={
23+
"epochs":1,
24+
"learning_rate":0.02
25+
},
26+
shape_name="VM.GPU.A10.1",
27+
replica=1,
28+
validation_set_size=0.2,
29+
block_storage_size=1,
30+
experiment_name="test_experiment_name",
31+
)
32+
33+
mock_finetuning_config = {
34+
"shape": {
35+
"VM.GPU.A10.1": {
36+
"batch_size": 1,
37+
"replica": 1
38+
},
39+
}
40+
}
41+
42+
43+
class FineTuningHandlerTestCase(TestCase):
44+
45+
@patch.object(IPythonHandler, "__init__")
46+
def setUp(self, ipython_init_mock) -> None:
47+
ipython_init_mock.return_value = None
48+
self.test_instance = AquaFineTuneHandler(MagicMock(), MagicMock())
49+
self.test_instance.request = MagicMock()
50+
self.test_instance.finish = MagicMock()
51+
52+
@patch.object(AquaFineTuneHandler, "get_finetuning_config")
53+
@patch("ads.aqua.extension.finetune_handler.urlparse")
54+
def test_get(self, mock_urlparse, mock_get_finetuning_config):
55+
request_path = MagicMock(path="aqua/finetuning/config")
56+
mock_urlparse.return_value = request_path
57+
58+
mock_get_finetuning_config.return_value = TestDataset.mock_finetuning_config
59+
60+
fineruning_config = self.test_instance.get(id="test_model_id")
61+
mock_urlparse.assert_called()
62+
mock_get_finetuning_config.assert_called_with("test_model_id")
63+
assert fineruning_config == TestDataset.mock_finetuning_config
64+
65+
@patch.object(AquaFineTuningApp, "create")
66+
def test_post(self, mock_create):
67+
self.test_instance.get_json_body = MagicMock(
68+
return_value = TestDataset.mock_valid_input
69+
)
70+
self.test_instance.post()
71+
72+
self.test_instance.finish.assert_called_with(
73+
mock_create.return_value
74+
)
75+
mock_create.assert_called_with(
76+
CreateFineTuningDetails(**TestDataset.mock_valid_input)
77+
)
78+
79+
@patch.object(AquaFineTuningApp, "get_finetuning_config")
80+
def test_get_finetuning_config(self, mock_get_finetuning_config):
81+
mock_get_finetuning_config.return_value = TestDataset.mock_finetuning_config
82+
83+
self.test_instance.get_finetuning_config(model_id="test_model_id")
84+
85+
self.test_instance.finish.assert_called_with(
86+
TestDataset.mock_finetuning_config
87+
)
88+
mock_get_finetuning_config.assert_called_with(
89+
model_id="test_model_id"
90+
)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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/
6+
7+
from unittest import TestCase
8+
from unittest.mock import MagicMock
9+
10+
from mock import patch
11+
from notebook.base.handlers import IPythonHandler
12+
13+
from ads.aqua.extension.model_handler import AquaModelHandler, AquaModelLicenseHandler
14+
from ads.aqua.model import AquaModelApp
15+
16+
17+
class ModelHandlerTestCase(TestCase):
18+
19+
@patch.object(IPythonHandler, "__init__")
20+
def setUp(self, ipython_init_mock) -> None:
21+
ipython_init_mock.return_value = None
22+
self.model_handler = AquaModelHandler(MagicMock(), MagicMock())
23+
self.model_handler.request = MagicMock()
24+
self.model_handler.finish = MagicMock()
25+
26+
@patch.object(AquaModelHandler, "list")
27+
def test_get_no_id(self, mock_list):
28+
self.model_handler.get()
29+
mock_list.assert_called()
30+
31+
@patch.object(AquaModelHandler, "read")
32+
def test_get_with_id(self, mock_read):
33+
self.model_handler.get(model_id="test_model_id")
34+
mock_read.assert_called_with("test_model_id")
35+
36+
@patch.object(AquaModelApp, "get")
37+
def test_read(self, mock_get):
38+
self.model_handler.read(model_id="test_model_id")
39+
self.model_handler.finish.assert_called_with(
40+
mock_get.return_value
41+
)
42+
mock_get.assert_called_with("test_model_id")
43+
44+
@patch.object(AquaModelApp, "clear_model_list_cache")
45+
@patch("ads.aqua.extension.model_handler.urlparse")
46+
def test_delete(self, mock_urlparse, mock_clear_model_list_cache):
47+
request_path = MagicMock(path="aqua/model/cache")
48+
mock_urlparse.return_value = request_path
49+
50+
self.model_handler.delete()
51+
self.model_handler.finish.assert_called_with(
52+
mock_clear_model_list_cache.return_value
53+
)
54+
55+
mock_urlparse.assert_called()
56+
mock_clear_model_list_cache.assert_called()
57+
58+
@patch.object(AquaModelApp, "list")
59+
def test_list(self, mock_list):
60+
self.model_handler.list()
61+
62+
self.model_handler.finish.assert_called_with(
63+
mock_list.return_value
64+
)
65+
mock_list.assert_called_with(None, None)
66+
67+
class ModelLicenseHandlerTestCase(TestCase):
68+
69+
@patch.object(IPythonHandler, "__init__")
70+
def setUp(self, ipython_init_mock) -> None:
71+
ipython_init_mock.return_value = None
72+
self.model_license_handler = AquaModelLicenseHandler(MagicMock(), MagicMock())
73+
self.model_license_handler.finish = MagicMock()
74+
75+
@patch.object(AquaModelApp, "load_license")
76+
def test_get(self, mock_load_license):
77+
self.model_license_handler.get(model_id="test_model_id")
78+
79+
self.model_license_handler.finish.assert_called_with(
80+
mock_load_license.return_value
81+
)
82+
mock_load_license.assert_called_with("test_model_id")

0 commit comments

Comments
 (0)