Skip to content

Commit 493e7fe

Browse files
authored
Merge pull request childmindresearch#90 from childmindresearch/maint/cloud-import
Gracefully handle GCS default client error
2 parents 7b7da28 + 05127ca commit 493e7fe

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)