File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,12 @@ def _find_bucket_region(bucket_name: str) -> str:
131131 import requests
132132
133133 resp = requests .head (f"https://{ bucket_name } .s3.amazonaws.com" )
134- return resp .headers ["x-amz-bucket-region" ]
134+ region = resp .headers .get ("x-amz-bucket-region" )
135+ if not region :
136+ raise ValueError (
137+ f"Unable to automatically determine region for bucket { bucket_name } "
138+ )
139+ return region
135140
136141
137142def default_object_store (filepath : str ) -> ObjectStore :
Original file line number Diff line number Diff line change @@ -161,6 +161,15 @@ def test_default_object_store_local(tmpdir):
161161 assert isinstance (store , LocalStore )
162162
163163
164+ @requires_obstore
165+ def test_default_region_raises ():
166+ file = "s3://cworthy/oae-efficiency-atlas/data/experiments/000/01/alk-forcing.000-1999-01.pop.h.0347-01.nc"
167+ with pytest .raises (
168+ ValueError , match = "Unable to automatically determine region for bucket*"
169+ ):
170+ default_object_store (file )
171+
172+
164173@requires_obstore
165174class TestManifestStore :
166175 def test_manifest_store_properties (self , local_store ):
You can’t perform that action at this time.
0 commit comments