Skip to content

Commit 05127ca

Browse files
committed
Gracefully handle GCS default client error
GCS default client setup can error out if dependencies is not available. This is currently only true because b2t can be installed with only the s3 dependency. S3 dependencies are always guranteed if s3 or cloud dependencies are installed
1 parent 7b7da28 commit 05127ca

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

bids2table/_pathlib.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
from pathlib import Path
22

33
try:
4-
from cloudpathlib import AnyPath, CloudPath, GSClient, S3Client
4+
from cloudpathlib import AnyPath, CloudPath, S3Client
55

66
_CLOUDPATHLIB_AVAILABLE = True
7-
8-
# Set default clients for cloud paths
97
S3Client(no_sign_request=True).set_as_default_client()
10-
GSClient().set_as_default_client()
8+
9+
# Necessary while s3 dependencies can be installed without gcs dependencies
10+
try:
11+
from cloudpathlib import GSClient
12+
13+
GSClient().set_as_default_client()
14+
# Using generalized Exception here, as DefaultCredentialsError is not available for
15+
# import if GSClient is not available
16+
except Exception:
17+
pass
1118

1219
except ImportError:
1320
AnyPath = CloudPath = Path

0 commit comments

Comments
 (0)