Skip to content

Commit 659e675

Browse files
Adding version handler for aqua
1 parent dc1f21b commit 659e675

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

ads/aqua/client/client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,9 @@ def _parse_streaming_line(
314314
try:
315315
json_line = json.loads(line)
316316
logger.debug(f"Parsed JSON line: {json_line}")
317-
except json.JSONDecodeError as e:
317+
except json.JSONDecodeError:
318318
logger.debug(f"Error decoding JSON from line: {line}")
319-
raise json.JSONDecodeError(
320-
f"Error decoding JSON from line: {e!s}", e.doc, e.pos
321-
) from e
319+
return None
322320

323321
if json_line.get("object") == "error":
324322
# Raise an error for error objects in the stream

ads/aqua/extension/common_handler.py

Lines changed: 43 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,42 @@ 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_version_path = os.path.join(
55+
os.path.dirname(os.path.abspath(__file__)), "..", "version.json"
56+
)
57+
latest_version_artifact_path = ObjectStorageDetails(
58+
CONDA_BUCKET_NAME, CONDA_BUCKET_NS, "service_pack/aqua_latest_version.json"
59+
).path
60+
latest_version_content = read_file(
61+
latest_version_artifact_path, auth=default_signer()
62+
)
63+
current_version_content = read_file(current_version_path)
64+
response = {
65+
**json.loads(current_version_content),
66+
**json.loads(latest_version_content),
67+
}
68+
return self.finish(response)
69+
70+
3171
class CompatibilityCheckHandler(AquaAPIhandler):
3272
"""The handler to check if the extension is compatible."""
3373

@@ -118,4 +158,5 @@ def get(self):
118158
("network_status", NetworkStatusHandler),
119159
("hf_login", HFLoginHandler),
120160
("hf_logged_in", HFUserStatusHandler),
161+
("aqua_version", AquaVersionHandler),
121162
]

ads/aqua/version.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"installed": {
3+
"ads": "2.14.2",
4+
"aqua": "0.1.3.0"
5+
}
6+
}

0 commit comments

Comments
 (0)