-
-
Notifications
You must be signed in to change notification settings - Fork 366
fix(remotestore): raise error if path includes scheme #2348
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e06e7f1
fix(remotestore): raise error if path includes scheme
jhamman fddba26
fixup
jhamman 8a0a380
fixup
jhamman d0ef793
strip scheme in from_url in case fsspec fails to
jhamman 56b28f7
Merge branch 'v3' into fix/remote-store-path
jhamman ee1db65
style: pre-commit fixes
pre-commit-ci[bot] 1eebd89
Merge branch 'v3' into fix/remote-store-path
jhamman fd088e0
disable cache in listing ops
jhamman 9281304
update docs
jhamman d0e1928
use listings cache again
jhamman 0b585df
Merge branch 'main' into fix/remote-store-path
jhamman 5a262e0
Merge branch 'main' into fix/remote-store-path
jhamman d1d271e
Merge branch 'main' of https://github.com/zarr-developers/zarr-python…
jhamman c094891
no refresh
jhamman b977cff
Merge branch 'main' into fix/remote-store-path
jhamman b56c6c1
style: pre-commit fixes
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import warnings | ||
| from typing import TYPE_CHECKING, Any, Self | ||
|
|
||
| from zarr.abc.store import ByteRangeRequest, Store | ||
|
|
@@ -32,7 +33,8 @@ class RemoteStore(Store): | |
| mode : AccessModeLiteral | ||
| The access mode to use. | ||
| path : str | ||
| The root path of the store. | ||
| The root path of the store. This should be a relative path and must not include the | ||
| filesystem scheme. | ||
| allowed_exceptions : tuple[type[Exception], ...] | ||
| When fetching data, these cases will be deemed to correspond to missing keys. | ||
|
|
||
|
|
@@ -44,6 +46,23 @@ class RemoteStore(Store): | |
| supports_deletes | ||
| supports_partial_writes | ||
| supports_listing | ||
|
|
||
| Raises | ||
| ------ | ||
| TypeError | ||
| If the Filesystem does not support async operations. | ||
| ValueError | ||
| If the path argument includes a scheme. | ||
|
|
||
| Warns | ||
| ----- | ||
| UserWarning | ||
| If the file system (fs) was not created with `asynchronous=True`. | ||
|
|
||
| See Also | ||
| -------- | ||
| RemoteStore.from_upath | ||
| RemoteStore.from_url | ||
| """ | ||
|
|
||
| # based on FSSpec | ||
|
|
@@ -69,6 +88,15 @@ def __init__( | |
|
|
||
| if not self.fs.async_impl: | ||
| raise TypeError("Filesystem needs to support async operations.") | ||
| if not self.fs.asynchronous: | ||
| warnings.warn( | ||
| f"fs ({fs}) was not created with `asynchronous=True`, this may lead to surprising behavior", | ||
| stacklevel=2, | ||
| ) | ||
| if "://" in path and not path.startswith("http"): | ||
|
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 consider also "::", since that is used in chained fsspec URLs, but should not normally end up passed to the FS. However, it is not as special as "://", so I'm ok not to make a special case for it. |
||
| # `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯) | ||
| scheme, _ = path.split("://", maxsplit=1) | ||
| raise ValueError(f"path argument to RemoteStore must not include scheme ({scheme}://)") | ||
|
|
||
| @classmethod | ||
| def from_upath( | ||
|
|
@@ -134,7 +162,17 @@ def from_url( | |
| # before fsspec==2024.3.1 | ||
| from fsspec.core import url_to_fs | ||
|
|
||
| fs, path = url_to_fs(url, **storage_options) | ||
| opts = storage_options or {} | ||
| opts = {"asynchronous": True, **opts} | ||
|
|
||
| fs, path = url_to_fs(url, **opts) | ||
|
|
||
| # fsspec is not consistent about removing the scheme from the path, so check and strip it here | ||
| # https://github.com/fsspec/filesystem_spec/issues/1722 | ||
| if "://" in path and not path.startswith("http"): | ||
| # `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯) | ||
| path = fs._strip_protocol(path) | ||
|
|
||
| return cls(fs=fs, path=path, mode=mode, allowed_exceptions=allowed_exceptions) | ||
|
|
||
| async def clear(self) -> None: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.