Skip to content

Commit f62eb5d

Browse files
Removing oss bucket config
1 parent 642e8f9 commit f62eb5d

File tree

4 files changed

+15
-50
lines changed

4 files changed

+15
-50
lines changed

ads/aqua/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
get_async_httpx_client,
1515
get_httpx_client,
1616
)
17-
from ads.aqua.common.utils import fetch_service_compartment
1817
from ads.config import OCI_RESOURCE_PRINCIPAL_VERSION
1918

2019
ENV_VAR_LOG_LEVEL = "ADS_AQUA_LOG_LEVEL"
@@ -41,5 +40,5 @@ def set_log_level(log_level: str):
4140
set_auth("resource_principal")
4241

4342
ODSC_MODEL_COMPARTMENT_OCID = (
44-
os.environ.get("ODSC_MODEL_COMPARTMENT_OCID") or fetch_service_compartment()
43+
os.environ.get("ODSC_MODEL_COMPARTMENT_OCID") or "ODSC_MODEL_COMPARTMENT_OCID"
4544
)

ads/aqua/common/utils.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
)
5050
from ads.aqua.constants import (
5151
AQUA_GA_LIST,
52-
COMPARTMENT_MAPPING_KEY,
5352
CONSOLE_LINK_RESOURCE_TYPE_MAPPING,
54-
CONTAINER_INDEX,
5553
DEPLOYMENT_CONFIG,
5654
FINE_TUNING_CONFIG,
5755
HF_LOGIN_DEFAULT_TIMEOUT,
@@ -560,36 +558,6 @@ def _build_job_identifier(
560558
return AquaResourceIdentifier()
561559

562560

563-
def service_config_path():
564-
return f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
565-
566-
567-
def fetch_service_compartment() -> Union[str, None]:
568-
"""
569-
Loads the compartment mapping json from service bucket.
570-
This json file has a service-model-compartment key which contains a dictionary of namespaces
571-
and the compartment OCID of the service models in that namespace.
572-
"""
573-
config_file_name = (
574-
f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
575-
)
576-
577-
try:
578-
config = load_config(
579-
file_path=config_file_name,
580-
config_file_name=CONTAINER_INDEX,
581-
)
582-
except Exception as e:
583-
logger.debug(
584-
f"Config file {config_file_name}/{CONTAINER_INDEX} to fetch service compartment OCID "
585-
f"could not be found. \n{str(e)}."
586-
)
587-
return
588-
compartment_mapping = config.get(COMPARTMENT_MAPPING_KEY)
589-
if compartment_mapping:
590-
return compartment_mapping.get(CONDA_BUCKET_NS)
591-
592-
593561
def get_max_version(versions):
594562
"""Takes in a list of versions and returns the higher version."""
595563
if not versions:

ads/aqua/extension/utils.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (c) 2024 Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44

55
import re
@@ -14,7 +14,6 @@
1414
from tornado.web import HTTPError
1515

1616
from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID, logger
17-
from ads.aqua.common.utils import fetch_service_compartment
1817
from ads.aqua.constants import (
1918
AQUA_TROUBLESHOOTING_LINK,
2019
OCI_OPERATION_FAILURES,
@@ -41,14 +40,14 @@ def ui_compatability_check():
4140
"""This method caches the service compartment OCID details that is set by either the environment variable or if
4241
fetched from the configuration. The cached result is returned when multiple calls are made in quick succession
4342
from the UI to avoid multiple config file loads."""
44-
return ODSC_MODEL_COMPARTMENT_OCID or fetch_service_compartment()
43+
return ODSC_MODEL_COMPARTMENT_OCID
4544

4645

4746
def get_default_error_messages(
4847
service_payload: dict,
4948
status_code: str,
5049
default_msg: str = "Unknown HTTP Error.",
51-
)-> str:
50+
) -> str:
5251
"""Method that maps the error messages based on the operation performed or the status codes encountered."""
5352

5453
if service_payload and "operation_name" in service_payload:
@@ -66,14 +65,13 @@ def get_documentation_link(key: str) -> str:
6665
return f"{AQUA_TROUBLESHOOTING_LINK}#{github_header}"
6766

6867

69-
def get_troubleshooting_tips(service_payload: dict,
70-
status_code: str) -> str:
68+
def get_troubleshooting_tips(service_payload: dict, status_code: str) -> str:
7169
"""Maps authorization errors to potential solutions on Troubleshooting Page per Aqua Documentation on oci-data-science-ai-samples"""
7270

7371
tip = f"For general tips on troubleshooting: {AQUA_TROUBLESHOOTING_LINK}"
7472

7573
if status_code in (404, 400):
76-
failed_operation = service_payload.get('operation_name')
74+
failed_operation = service_payload.get("operation_name")
7775

7876
if failed_operation in OCI_OPERATION_FAILURES:
7977
link = get_documentation_link(failed_operation)
@@ -118,14 +116,13 @@ def construct_error(status_code: int, **kwargs) -> ReplyDetails:
118116

119117
tips = get_troubleshooting_tips(service_payload, status_code)
120118

121-
122119
reply = ReplyDetails(
123-
status = status_code,
124-
troubleshooting_tips = tips,
125-
message = message,
126-
service_payload = service_payload,
127-
reason = reason,
128-
request_id = str(uuid.uuid4()),
120+
status=status_code,
121+
troubleshooting_tips=tips,
122+
message=message,
123+
service_payload=service_payload,
124+
reason=reason,
125+
request_id=str(uuid.uuid4()),
129126
)
130127

131128
exc_info = kwargs.get("exc_info")

ads/aqua/model/model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ def list(
933933
"""
934934

935935
models = []
936-
category = kwargs.get("category", USER)
936+
category = kwargs.pop("category", USER)
937937
if compartment_id and category != SERVICE:
938938
# tracks number of times custom model listing was called
939939
self.telemetry.record_event_async(
@@ -961,8 +961,9 @@ def list(
961961

962962
models = self.list_resource(
963963
self.ds_client.list_models,
964-
compartment_id=ODSC_MODEL_COMPARTMENT_OCID,
964+
compartment_id=compartment_id or COMPARTMENT_OCID,
965965
lifecycle_state=lifecycle_state,
966+
category=category,
966967
**kwargs,
967968
)
968969

0 commit comments

Comments
 (0)