-
-
Notifications
You must be signed in to change notification settings - Fork 308
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
Update RemoteStore.__str__
and add UPath tests
#1964
Changes from all commits
68f9d2c
8fa06e1
b73f5e9
6da5ecf
1f57e31
de334ac
0d1b6e7
77f675a
bc3f62c
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ class RemoteStore(Store): | |
supports_listing: bool = True | ||
|
||
_fs: AsyncFileSystem | ||
_url: str | ||
path: str | ||
allowed_exceptions: tuple[type[Exception], ...] | ||
|
||
|
@@ -51,18 +52,22 @@ def __init__( | |
""" | ||
|
||
super().__init__(mode=mode) | ||
|
||
if isinstance(url, str): | ||
self._fs, self.path = fsspec.url_to_fs(url, **storage_options) | ||
self._url = url.rstrip("/") | ||
self._fs, _path = fsspec.url_to_fs(url, **storage_options) | ||
self.path = _path.rstrip("/") | ||
elif hasattr(url, "protocol") and hasattr(url, "fs"): | ||
# is UPath-like - but without importing | ||
if storage_options: | ||
raise ValueError( | ||
"If constructed with a UPath object, no additional " | ||
"storage_options are allowed" | ||
) | ||
self.path = url.path | ||
self._fs = url._fs | ||
# n.b. UPath returns the url and path attributes with a trailing /, at least for s3 | ||
# that trailing / must be removed to compose with the store interface | ||
self._url = str(url).rstrip("/") | ||
self.path = url.path.rstrip("/") | ||
self._fs = url.fs | ||
else: | ||
raise ValueError("URL not understood, %s", url) | ||
self.allowed_exceptions = allowed_exceptions | ||
|
@@ -71,10 +76,10 @@ def __init__( | |
raise TypeError("FileSystem needs to support async operations") | ||
|
||
def __str__(self) -> str: | ||
return f"Remote fsspec store: {type(self._fs).__name__} , {self.path}" | ||
return f"{self._url}" | ||
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. We are implying that this store is the only way to access the URL displayed here 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, but this is consistent with our current practice for memory store and local store. Yes, this practice does mean that |
||
|
||
def __repr__(self) -> str: | ||
return f"<RemoteStore({type(self._fs).__name__} , {self.path})>" | ||
return f"<RemoteStore({type(self._fs).__name__}, {self.path})>" | ||
|
||
async def get( | ||
self, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case where url has no trailing "/", but the return fom url_to_fs does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not aware of any, but I wanted to ensure that the UPath and non-UPath code paths do the exact same thing to the url string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be misunderstanding the question...