Skip to content

Commit ad4da77

Browse files
update hello reload pr
1 parent 5de5653 commit ad4da77

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

ads/aqua/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,12 @@
1818
if 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+
)
2224
if 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()

ads/aqua/extension/common_handler.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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"))

ads/aqua/utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff 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

597602
def get_max_version(versions):

0 commit comments

Comments
 (0)