File tree Expand file tree Collapse file tree 3 files changed +15
-19
lines changed
Expand file tree Collapse file tree 3 files changed +15
-19
lines changed Original file line number Diff line number Diff line change 1818if OCI_RESOURCE_PRINCIPAL_VERSION :
1919 set_auth ("resource_principal" )
2020
21- ODSC_MODEL_COMPARTMENT_OCID = os .environ .get ("ODSC_MODEL_COMPARTMENT_OCID" )
21+ ODSC_MODEL_COMPARTMENT_OCID = (
22+ os .environ .get ("ODSC_MODEL_COMPARTMENT_OCID" ) or fetch_service_compartment ()
23+ )
2224if not ODSC_MODEL_COMPARTMENT_OCID :
23- try :
24- ODSC_MODEL_COMPARTMENT_OCID = fetch_service_compartment ()
25- except :
26- pass
27-
28- if not ODSC_MODEL_COMPARTMENT_OCID :
29- logger .error (
30- f"ODSC_MODEL_COMPARTMENT_OCID environment variable is not set for Aqua."
31- )
3225 if NB_SESSION_OCID :
3326 logger .error (
34- f"Aqua is not available for this notebook session { NB_SESSION_OCID } ."
27+ f"Aqua is not available for the notebook session { NB_SESSION_OCID } ."
3528 )
3629 exit ()
Original file line number Diff line number Diff line change @@ -39,9 +39,7 @@ def get(self):
3939 AquaResourceAccessError: raised when aqua is not accessible in the given session/region.
4040
4141 """
42- if (
43- ODSC_MODEL_COMPARTMENT_OCID or fetch_service_compartment ()
44- ): # TODO replace this with method that does not raise exception
42+ if ODSC_MODEL_COMPARTMENT_OCID or fetch_service_compartment ():
4543 return self .finish (dict (status = "ok" ))
4644 elif known_realm ():
4745 return self .finish (dict (status = "compatible" ))
Original file line number Diff line number Diff line change @@ -584,14 +584,19 @@ def fetch_service_compartment():
584584 f"oci://{ AQUA_SERVICE_MODELS_BUCKET } @{ CONDA_BUCKET_NS } /service_models/config"
585585 )
586586
587- config = load_config (
588- file_path = config_file_name ,
589- config_file_name = CONTAINER_INDEX ,
590- )
587+ try :
588+ config = load_config (
589+ file_path = config_file_name ,
590+ config_file_name = CONTAINER_INDEX ,
591+ )
592+ except AquaFileNotFoundError :
593+ logger .error (
594+ f"ODSC_MODEL_COMPARTMENT_OCID environment variable is not set for Aqua."
595+ )
596+ return
591597 compartment_mapping = config .get (COMPARTMENT_MAPPING_KEY )
592598 if compartment_mapping :
593599 return compartment_mapping .get (CONDA_BUCKET_NS )
594- return None
595600
596601
597602def get_max_version (versions ):
You can’t perform that action at this time.
0 commit comments