Skip to content

Commit 64818bf

Browse files
sasha-gitgcopybara-github
authored andcommitted
chore: Reduce google.auth.default invocations
PiperOrigin-RevId: 535420578
1 parent f16f56d commit 64818bf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

google/cloud/aiplatform/initializer.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from concurrent import futures
2020
import logging
21-
import pkg_resources
21+
import pkg_resources # Note this is used after copybara replacement
2222
import os
2323
from typing import List, Optional, Type, Union
2424

@@ -72,14 +72,14 @@ def _set_project_as_env_var_or_google_auth_default(self):
7272
credentials=self._credentials,
7373
)
7474
self._project = project_id
75-
return project_id
7675
except Exception:
7776
logging.getLogger(__name__).warning(
7877
"Failed to convert project number to project ID.", exc_info=True
7978
)
80-
return project_number
79+
self._project = project_number
8180
else:
82-
_, project = google.auth.default()
81+
credentials, project = google.auth.default()
82+
self._credentials = self._credentials or credentials
8383
self._project = project
8484

8585
if not self._credentials:

0 commit comments

Comments
 (0)