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
55import re
1414from tornado .web import HTTPError
1515
1616from ads .aqua import ODSC_MODEL_COMPARTMENT_OCID , logger
17- from ads .aqua .common .utils import fetch_service_compartment
1817from 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
4746def 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" )
0 commit comments