Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion google/cloud/aiplatform/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ def _instantiate_client(
"""Helper method to instantiate service client for resource noun.

Args:
project (str): Project of the resource noun.
location (str): The location of the resource noun.
credentials (google.auth.credentials.Credentials):
Optional custom credentials to use when accessing interacting with
Expand Down
13 changes: 12 additions & 1 deletion google/cloud/aiplatform/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,20 @@ def staging_bucket(self) -> Optional[str]:

@property
def credentials(self) -> Optional[auth_credentials.Credentials]:
"""Default credentials, if provided."""
"""Default credentials."""
return self._credentials

@credentials.setter
def credentials(self, credentials):
"""Set credentials if provided, or to the default credentials, ."""
if not credentials:
logger = logging.getLogger("google.auth._default")
logging_warning_filter = utils.LoggingWarningFilter()
logger.addFilter(logging_warning_filter)
credentials, _ = google.auth.default()
logger.removeFilter(logging_warning_filter)
self._credentials = credentials

def get_client_options(
self, location_override: Optional[str] = None, prediction_client: bool = False,
) -> client_options.ClientOptions:
Expand Down
6 changes: 6 additions & 0 deletions google/cloud/aiplatform/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


import re
import logging

from typing import Any, Match, Optional, Type, TypeVar, Tuple
from collections import namedtuple
Expand Down Expand Up @@ -308,3 +309,8 @@ def __getattr__(self, name: str) -> Any:
client_info=self._client_info,
)
return getattr(temporary_client, name)


class LoggingWarningFilter(logging.Filter):
def filter(self, record):
return record.levelname == logging.WARNING