diff --git a/ads/aqua/__init__.py b/ads/aqua/__init__.py index eed99b3e6..78b21a695 100644 --- a/ads/aqua/__init__.py +++ b/ads/aqua/__init__.py @@ -1,12 +1,12 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2024 Oracle and/or its affiliates. +# Copyright (c) 2024, 2025 Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ import os +from logging import getLogger -from ads import logger, set_auth +from ads import set_auth from ads.aqua.common.utils import fetch_service_compartment from ads.config import OCI_RESOURCE_PRINCIPAL_VERSION @@ -19,6 +19,7 @@ def get_logger_level(): return level +logger = getLogger(__name__) logger.setLevel(get_logger_level()) @@ -27,7 +28,6 @@ def set_log_level(log_level: str): log_level = log_level.upper() logger.setLevel(log_level.upper()) - logger.handlers[0].setLevel(log_level) if OCI_RESOURCE_PRINCIPAL_VERSION: diff --git a/ads/common/auth.py b/ads/common/auth.py index a91581a65..4bf1d11ec 100644 --- a/ads/common/auth.py +++ b/ads/common/auth.py @@ -424,7 +424,7 @@ def create_signer( "signer": signer, "client_kwargs": client_kwargs, } - logger.info(f"Using authentication signer type {type(signer)}.") + logger.debug(f"Using authentication signer type {type(signer)}.") return signer_dict else: signer_args = dict( @@ -492,7 +492,7 @@ def default_signer(client_kwargs: Optional[Dict] = None) -> Dict: **(client_kwargs or {}), }, } - logger.info(f"Using authentication signer type {type(signer)}.") + logger.debug(f"Using authentication signer type {type(signer)}.") return signer_dict else: signer_args = dict( @@ -621,7 +621,7 @@ def create_signer(self) -> Dict: ) oci.config.validate_config(configuration) - logger.info(f"Using 'api_key' authentication.") + logger.debug(f"Using 'api_key' authentication.") return { "config": configuration, "signer": oci.signer.Signer( @@ -684,7 +684,7 @@ def create_signer(self) -> Dict: "signer": oci.auth.signers.get_resource_principals_signer(), "client_kwargs": self.client_kwargs, } - logger.info(f"Using 'resource_principal' authentication.") + logger.debug(f"Using 'resource_principal' authentication.") return signer_dict @staticmethod @@ -747,7 +747,7 @@ def create_signer(self) -> Dict: ), "client_kwargs": self.client_kwargs, } - logger.info(f"Using 'instance_principal' authentication.") + logger.debug(f"Using 'instance_principal' authentication.") return signer_dict @@ -814,7 +814,7 @@ def create_signer(self) -> Dict: oci.config.from_file(self.oci_config_location, self.oci_key_profile) ) - logger.info(f"Using 'security_token' authentication.") + logger.debug(f"Using 'security_token' authentication.") for parameter in self.SECURITY_TOKEN_REQUIRED: if parameter not in configuration: @@ -883,7 +883,7 @@ def _validate_and_refresh_token(self, configuration: Dict[str, Any]): ) date_time = datetime.fromtimestamp(time_expired).strftime("%Y-%m-%d %H:%M:%S") - logger.info(f"Session is valid until {date_time}.") + logger.debug(f"Session is valid until {date_time}.") def _read_security_token_file(self, security_token_file: str) -> str: """Reads security token from file. @@ -1020,10 +1020,10 @@ def __enter__(self): """ if self.profile: ads.set_auth(auth=AuthType.API_KEY, profile=self.profile) - logger.info(f"OCI profile set to {self.profile}") + logger.debug(f"OCI profile set to {self.profile}") else: ads.set_auth(auth=AuthType.RESOURCE_PRINCIPAL) - logger.info(f"OCI auth set to resource principal") + logger.debug(f"OCI auth set to resource principal") return self def __exit__(self, exc_type, exc_val, exc_tb):