Skip to content

Commit

Permalink
https access fix (#196)
Browse files Browse the repository at this point in the history
* https access fix

* update https reader option

* update test for https check
  • Loading branch information
ayushnag authored Jul 23, 2024
1 parent 10bd53d commit 179bb2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion virtualizarr/tests/test_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def test_read_from_url(self, filetype, url):
with pytest.raises(NotImplementedError):
vds = open_virtual_dataset(url, reader_options={}, indexes={})
else:
vds = open_virtual_dataset(url, reader_options={}, indexes={})
vds = open_virtual_dataset(url, indexes={})
assert isinstance(vds, xr.Dataset)


Expand Down
12 changes: 9 additions & 3 deletions virtualizarr/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import ujson # type: ignore
import xarray as xr
from upath import UPath
from xarray import register_dataset_accessor
from xarray.backends import BackendArray
from xarray.coding.times import CFDatetimeCoder
Expand Down Expand Up @@ -125,9 +126,14 @@ def open_virtual_dataset(
)
else:
if reader_options is None:
reader_options = {
"storage_options": {"key": "", "secret": "", "anon": True}
}
universal_filepath = UPath(filepath)
protocol = universal_filepath.protocol
if protocol == "s3":
reader_options = {
"storage_options": {"key": "", "secret": "", "anon": True}
}
else:
reader_options = {}

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

0 comments on commit 179bb2a

Please sign in to comment.