Skip to content

Commit ee3c9d0

Browse files
authored
Merge branch 'main' into track_md_logs_for_error_logging
2 parents 83dc9fc + e16414b commit ee3c9d0

File tree

3 files changed

+79
-5
lines changed

3 files changed

+79
-5
lines changed

ads/aqua/extension/common_handler.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python
22
# Copyright (c) 2025 Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4-
5-
4+
import json
5+
import os
66
from importlib import metadata
77

88
import huggingface_hub
@@ -18,6 +18,10 @@
1818
)
1919
from ads.aqua.extension.base_handler import AquaAPIhandler
2020
from ads.aqua.extension.errors import Errors
21+
from ads.common.object_storage_details import ObjectStorageDetails
22+
from ads.common.utils import read_file
23+
from ads.config import CONDA_BUCKET_NAME, CONDA_BUCKET_NS
24+
from ads.opctl.operator.common.utils import default_signer
2125

2226

2327
class ADSVersionHandler(AquaAPIhandler):
@@ -28,6 +32,46 @@ def get(self):
2832
self.finish({"data": metadata.version("oracle_ads")})
2933

3034

35+
class AquaVersionHandler(AquaAPIhandler):
36+
@handle_exceptions
37+
def get(self):
38+
"""
39+
Returns the current and latest deployed version of AQUA
40+
41+
{
42+
"installed": {
43+
"aqua": "0.1.3.0",
44+
"ads": "2.14.2"
45+
},
46+
"latest": {
47+
"aqua": "0.1.4.0",
48+
"ads": "2.14.4"
49+
}
50+
}
51+
52+
"""
53+
54+
current_aqua_version_path = os.path.join(
55+
os.path.dirname(os.path.abspath(__file__)), "..", "version.json"
56+
)
57+
current_aqua_version = json.loads(read_file(current_aqua_version_path))
58+
current_ads_version = {"ads": metadata.version("oracle_ads")}
59+
current_version = {"installed": {**current_aqua_version, **current_ads_version}}
60+
try:
61+
latest_version_artifact_path = ObjectStorageDetails(
62+
CONDA_BUCKET_NAME,
63+
CONDA_BUCKET_NS,
64+
"service_pack/aqua_latest_version.json",
65+
).path
66+
latest_version = json.loads(
67+
read_file(latest_version_artifact_path, auth=default_signer())
68+
)
69+
except Exception:
70+
latest_version = {"latest": current_version["installed"]}
71+
response = {**current_version, **latest_version}
72+
return self.finish(response)
73+
74+
3175
class CompatibilityCheckHandler(AquaAPIhandler):
3276
"""The handler to check if the extension is compatible."""
3377

@@ -118,4 +162,5 @@ def get(self):
118162
("network_status", NetworkStatusHandler),
119163
("hf_login", HFLoginHandler),
120164
("hf_logged_in", HFUserStatusHandler),
165+
("aqua_version", AquaVersionHandler),
121166
]

ads/aqua/version.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"aqua": "1.0.7"
3+
}

tests/unitary/with_extras/aqua/test_common_handler.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,25 @@
1414
import ads.aqua
1515
import ads.config
1616

17-
from ads.aqua.extension.common_handler import CompatibilityCheckHandler
17+
from ads.aqua.extension.common_handler import (
18+
CompatibilityCheckHandler,
19+
AquaVersionHandler,
20+
)
1821

1922

2023
class TestDataset:
2124
SERVICE_COMPARTMENT_ID = "ocid1.compartment.oc1..<OCID>"
2225

2326

24-
class TestEvaluationHandler(unittest.TestCase):
27+
class TestCompatibilityCheckHandler(unittest.TestCase):
2528
@patch.object(IPythonHandler, "__init__")
2629
def setUp(self, ipython_init_mock) -> None:
2730
ipython_init_mock.return_value = None
2831
self.common_handler = CompatibilityCheckHandler(MagicMock(), MagicMock())
2932
self.common_handler.request = MagicMock()
3033

3134
def test_get_ok(self):
32-
"""Test to check if ok is returned when ODSC_MODEL_COMPARTMENT_OCID is set."""
35+
"""Test to check if ok is returned."""
3336
reload(ads.config)
3437
reload(ads.aqua)
3538
reload(ads.aqua.extension.utils)
@@ -42,3 +45,26 @@ def test_get_ok(self):
4245
self.common_handler.request.path = "aqua/hello"
4346
result = self.common_handler.get()
4447
assert result["status"] == "ok"
48+
49+
50+
class TestAquaVersionHandler(unittest.TestCase):
51+
@patch.object(IPythonHandler, "__init__")
52+
def setUp(self, ipython_init_mock) -> None:
53+
ipython_init_mock.return_value = None
54+
self.version_handler = AquaVersionHandler(MagicMock(), MagicMock())
55+
self.version_handler.request = MagicMock()
56+
57+
@patch("ads.common.utils.read_file")
58+
def test_get(self, mock_read_file):
59+
reload(ads.config)
60+
reload(ads.aqua)
61+
reload(ads.aqua.extension.utils)
62+
reload(ads.aqua.extension.common_handler)
63+
mock_read_file.return_value = '{"installed":{"aqua":"1.0.4","ads":"2.13.12"}}'
64+
with patch(
65+
"ads.aqua.extension.base_handler.AquaAPIhandler.finish"
66+
) as mock_finish:
67+
mock_finish.side_effect = lambda x: x
68+
self.version_handler.request.path = "aqua/aqua_version"
69+
result = self.version_handler.get()
70+
assert result == {"installed": {"aqua": "1.0.4", "ads": "2.13.12"}}

0 commit comments

Comments
 (0)