in src/local_gpu_verifier/src/verifier/cc_admin_utils.py [0:0]
def fetch_rim_file(rim_id, max_retries=BaseSettings.RIM_SERVICE_RETRY_COUNT):
"""A static method to fetch the RIM file with the given file id from the RIM service.
It tries to fetch the RIM file from provided RIM service, and fallback to the Nvidia RIM service if the fetch fails.
Args:
rim_id (str): the RIM file id which need to be fetched from the RIM service.
Raises:
RIMFetchError: it is raised in case the RIM fetch is failed.
Returns:
[str]: the content of the required RIM file as a string.
"""
# Fetching the RIM file from the provided RIM service
try:
rim_result = function_wrapper_with_timeout(
[
CcAdminUtils.fetch_rim_file_from_url,
rim_id,
BaseSettings.RIM_SERVICE_BASE_URL,
max_retries,
"fetch_rim_file_from_url",
],
BaseSettings.MAX_RIM_REQUEST_TIME_DELAY * max_retries,
)
except Exception as e:
event_log.error(f"Exception occurred while fetching RIM {rim_id} from provided RIM service: {str(e)}")
rim_result = None
# RIM is successfully fetched from the provided RIM service
if rim_result is not None:
return rim_result
# Log error if RIM file is not fetched from the provided RIM service
event_log.error(f"Failed to fetch RIM {rim_id} from provided RIM service: {BaseSettings.RIM_SERVICE_BASE_URL}")
# Fallback to the Nvidia RIM service if the fetch fails
if BaseSettings.RIM_SERVICE_BASE_URL_NVIDIA != BaseSettings.RIM_SERVICE_BASE_URL:
event_log.info(f"Falling back to Nvidia RIM service {BaseSettings.RIM_SERVICE_BASE_URL_NVIDIA}")
try:
rim_result = function_wrapper_with_timeout(
[
CcAdminUtils.fetch_rim_file_from_url,
rim_id,
BaseSettings.RIM_SERVICE_BASE_URL_NVIDIA,
max_retries,
"fetch_rim_file_from_url",
],
BaseSettings.MAX_RIM_REQUEST_TIME_DELAY * max_retries,
)
except Exception as e:
event_log.error(f"Exception occurred while fetching RIM {rim_id} from Nvidia RIM service: {str(e)}")
rim_result = None
# RIM is successfully fetched from the Nvidia RIM service
if rim_result is not None:
return rim_result
# Log error if RIM file is not fetched from the Nvidia RIM service
event_log.error(f"Failed to fetch RIM {rim_id} from Nvidia RIM service: {BaseSettings.RIM_SERVICE_BASE_URL_NVIDIA}")
# Raise error if RIM file is not fetched from both the RIM services
raise RIMFetchError(f"Could not fetch the required RIM file : {rim_id} from the RIM service.")