Skip to content

Commit

Permalink
fix _json_credential not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
drf7 committed Aug 8, 2024
1 parent 8a60dd4 commit 2f36615
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions nucliadb/src/nucliadb/writer/tus/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class GCloudBlobStore(BlobStore):
loop = None
upload_url: str
object_base_url: str
json_credentials: str
json_credentials: Optional[str]
bucket: str
location: str
project: str
Expand Down Expand Up @@ -112,21 +112,16 @@ async def initialize(
self.bucket_labels = bucket_labels
self.object_base_url = object_base_url + "/storage/v1/b"
self.upload_url = object_base_url + "/upload/storage/v1/b/{bucket}/o?uploadType=resumable" # noqa

self.json_credentials = json_credentials
self._credentials = None

if json_credentials is None:
self._json_credentials = None
elif isinstance(json_credentials, str) and json_credentials.strip() == "":
self._json_credentials = None

if json_credentials is not None:
if self.json_credentials is not None and self.json_credentials.strip() != "":
self._credentials = service_account.Credentials.from_service_account_info(
self._json_credentials, scopes=SCOPES
self.json_credentials, scopes=SCOPES
)
else:
try:
self._credentials, _ = google.auth.default()
self._credentials, self.project = google.auth.default()
except DefaultCredentialsError:
logger.warning("Setting up without credentials as couldn't find workload identity")
self._credentials = None
Expand Down

0 comments on commit 2f36615

Please sign in to comment.