1
1
#!/usr/bin/env python
2
2
# Copyright (c) 2025 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
-
5
-
4
+ import json
5
+ import os
6
6
from importlib import metadata
7
7
8
8
import huggingface_hub
18
18
)
19
19
from ads .aqua .extension .base_handler import AquaAPIhandler
20
20
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
21
25
22
26
23
27
class ADSVersionHandler (AquaAPIhandler ):
@@ -28,6 +32,42 @@ def get(self):
28
32
self .finish ({"data" : metadata .version ("oracle_ads" )})
29
33
30
34
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
+
31
71
class CompatibilityCheckHandler (AquaAPIhandler ):
32
72
"""The handler to check if the extension is compatible."""
33
73
@@ -118,4 +158,5 @@ def get(self):
118
158
("network_status" , NetworkStatusHandler ),
119
159
("hf_login" , HFLoginHandler ),
120
160
("hf_logged_in" , HFUserStatusHandler ),
161
+ ("aqua_version" , AquaVersionHandler ),
121
162
]
0 commit comments