Skip to content

Commit 179bb2a

Browse files
authored
https access fix (#196)
* https access fix * update https reader option * update test for https check
1 parent 10bd53d commit 179bb2a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

virtualizarr/tests/test_xarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def test_read_from_url(self, filetype, url):
376376
with pytest.raises(NotImplementedError):
377377
vds = open_virtual_dataset(url, reader_options={}, indexes={})
378378
else:
379-
vds = open_virtual_dataset(url, reader_options={}, indexes={})
379+
vds = open_virtual_dataset(url, indexes={})
380380
assert isinstance(vds, xr.Dataset)
381381

382382

virtualizarr/xarray.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import ujson # type: ignore
1212
import xarray as xr
13+
from upath import UPath
1314
from xarray import register_dataset_accessor
1415
from xarray.backends import BackendArray
1516
from xarray.coding.times import CFDatetimeCoder
@@ -125,9 +126,14 @@ def open_virtual_dataset(
125126
)
126127
else:
127128
if reader_options is None:
128-
reader_options = {
129-
"storage_options": {"key": "", "secret": "", "anon": True}
130-
}
129+
universal_filepath = UPath(filepath)
130+
protocol = universal_filepath.protocol
131+
if protocol == "s3":
132+
reader_options = {
133+
"storage_options": {"key": "", "secret": "", "anon": True}
134+
}
135+
else:
136+
reader_options = {}
131137

132138
# this is the only place we actually always need to use kerchunk directly
133139
# TODO avoid even reading byte ranges for variables that will be dropped later anyway?

0 commit comments

Comments
 (0)