File tree Expand file tree Collapse file tree 3 files changed +19
-19
lines changed
Expand file tree Collapse file tree 3 files changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -53,17 +53,10 @@ def set_log_level(log_level: str):
5353if OCI_RESOURCE_PRINCIPAL_VERSION :
5454 set_auth ("resource_principal" )
5555
56- ODSC_MODEL_COMPARTMENT_OCID = os .environ .get ("ODSC_MODEL_COMPARTMENT_OCID" )
56+ ODSC_MODEL_COMPARTMENT_OCID = (
57+ os .environ .get ("ODSC_MODEL_COMPARTMENT_OCID" ) or fetch_service_compartment ()
58+ )
5759if not ODSC_MODEL_COMPARTMENT_OCID :
58- try :
59- ODSC_MODEL_COMPARTMENT_OCID = fetch_service_compartment ()
60- except :
61- pass
62-
63- if not ODSC_MODEL_COMPARTMENT_OCID :
64- logger .error (
65- f"ODSC_MODEL_COMPARTMENT_OCID environment variable is not set for Aqua."
66- )
6760 if NB_SESSION_OCID :
6861 logger .error (
6962 f"Aqua is not available for this notebook session { NB_SESSION_OCID } ."
Original file line number Diff line number Diff line change 1010from ads .aqua .decorator import handle_exceptions
1111from ads .aqua .exception import AquaResourceAccessError
1212from ads .aqua .extension .base_handler import AquaAPIhandler
13- from ads .aqua .utils import known_realm
13+ from ads .aqua .utils import known_realm , fetch_service_compartment
1414
1515
1616class ADSVersionHandler (AquaAPIhandler ):
@@ -39,7 +39,7 @@ def get(self):
3939 AquaResourceAccessError: raised when aqua is not accessible in the given session/region.
4040
4141 """
42- if ODSC_MODEL_COMPARTMENT_OCID :
42+ if ODSC_MODEL_COMPARTMENT_OCID or fetch_service_compartment () :
4343 return self .finish (dict (status = "ok" ))
4444 elif known_realm ():
4545 return self .finish (dict (status = "compatible" ))
Original file line number Diff line number Diff line change @@ -567,20 +567,27 @@ def get_container_image(
567567 return container_image
568568
569569
570- def fetch_service_compartment ():
571- """Loads the compartment mapping json from service bucket"""
570+ def fetch_service_compartment () -> Union [str , None ]:
571+ """Loads the compartment mapping json from service bucket. This json file has a service-model-compartment key which
572+ contains a dictionary of namespaces and the compartment OCID of the service models in that namespace.
573+ """
572574 config_file_name = (
573575 f"oci://{ AQUA_SERVICE_MODELS_BUCKET } @{ CONDA_BUCKET_NS } /service_models/config"
574576 )
575577
576- config = load_config (
577- file_path = config_file_name ,
578- config_file_name = CONTAINER_INDEX ,
579- )
578+ try :
579+ config = load_config (
580+ file_path = config_file_name ,
581+ config_file_name = CONTAINER_INDEX ,
582+ )
583+ except AquaFileNotFoundError :
584+ logger .error (
585+ f"ODSC_MODEL_COMPARTMENT_OCID environment variable is not set for Aqua."
586+ )
587+ return
580588 compartment_mapping = config .get (COMPARTMENT_MAPPING_KEY )
581589 if compartment_mapping :
582590 return compartment_mapping .get (CONDA_BUCKET_NS )
583- return None
584591
585592
586593def get_max_version (versions ):
You can’t perform that action at this time.
0 commit comments