-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add storage_options arg to to_zarr #5615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
fbb4deb
3c0805f
29e58af
9f5e501
a1519c5
753c6d4
77d24de
e0ba649
67ccce2
1584c89
3edd861
53bdec2
9194359
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1310,6 +1310,7 @@ def to_zarr( | |
dataset: Dataset, | ||
store: Union[MutableMapping, str, Path] = None, | ||
chunk_store=None, | ||
storage_options: Dict[str, str] = None, | ||
mode: str = None, | ||
synchronizer=None, | ||
group: str = None, | ||
|
@@ -1330,6 +1331,15 @@ def to_zarr( | |
store = _normalize_path(store) | ||
chunk_store = _normalize_path(chunk_store) | ||
|
||
if storage_options is None: | ||
mapper = store | ||
chunk_mapper = chunk_store | ||
else: | ||
from fsspec import get_mapper | ||
|
||
mapper = get_mapper(store, **storage_options) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we import There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also curious what behavior we should expect if a store (e.g. GCSMapper) is provided along with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Did your suggestion. As it stands if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since fsspec is such a small dep, with no deps of its own, you may wish to add it to xarray's deps for simplicity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not sure. I tend to just use a string e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that the input to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, every implementation takes a string for the "root"; it is not completely inconceivable that some implementation might take something else, but I can't immediately imagine it. |
||
chunk_mapper = get_mapper(chunk_store, **storage_options) | ||
|
||
if encoding is None: | ||
encoding = {} | ||
|
||
|
@@ -1372,13 +1382,13 @@ def to_zarr( | |
already_consolidated = False | ||
consolidate_on_close = consolidated or consolidated is None | ||
zstore = backends.ZarrStore.open_group( | ||
store=store, | ||
store=mapper, | ||
mode=mode, | ||
synchronizer=synchronizer, | ||
group=group, | ||
consolidated=already_consolidated, | ||
consolidate_on_close=consolidate_on_close, | ||
chunk_store=chunk_store, | ||
chunk_store=chunk_mapper, | ||
append_dim=append_dim, | ||
write_region=region, | ||
safe_chunks=safe_chunks, | ||
|
Uh oh!
There was an error while loading. Please reload this page.