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,46 @@ 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_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
+
31
75
class CompatibilityCheckHandler (AquaAPIhandler ):
32
76
"""The handler to check if the extension is compatible."""
33
77
@@ -118,4 +162,5 @@ def get(self):
118
162
("network_status" , NetworkStatusHandler ),
119
163
("hf_login" , HFLoginHandler ),
120
164
("hf_logged_in" , HFUserStatusHandler ),
165
+ ("aqua_version" , AquaVersionHandler ),
121
166
]
0 commit comments