-
Notifications
You must be signed in to change notification settings - Fork 376
Allow setting the root of a filesystem #395
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
Comments
This is an interesting idea. pyfilesystem2 has something similar. |
On the other hand, we already have |
I do like the Did you think a |
Based on what I read on this post, I changed LocalFileSystem and it seems to be working fine based on a few tests. import os
from fsspec.implementations.local import LocalFileSystem, stringify_path, make_path_posix
class PrefixFileSystem(LocalFileSystem):
def __init__(self, root_path='/', *args, **kwargs):
self.root_path = stringify_path(root_path)
super().__init__(*args, **kwargs)
def _strip_protocol(self, path):
path = stringify_path(path)
if path.startswith("file://"):
path = path[7:]
return os.path.join(self.root_path, path).rstrip("/") |
@brunorpinho , I don't think so, because the output of In any case, it would be a shame to provide something like this to the local files only. |
@martindurant yep, I see. |
This would be extremely useful with |
Perhaps you could make another implementation that wraps an arbitrary backend filesystem and does all the path manipulations? That's the kind of thing going on with the caching filesystems and ReferenceFileSystem, so there are precedents. Also, universal_path's implementation might be useful using Path-like objects. |
I see thanks for the suggestions! |
See https://github.com/Quansight/universal_pathlib , and feel free to ask further questions there. |
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative the its `prefix`. After performing the necessary paths operation it delegates everything to the wrapped prefix. Resolves fsspec#395
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves fsspec#395
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves fsspec#395
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves fsspec#395
A bit unrelated, but my 2c about Path-like objects: we need to be careful with those, as things might get really slow if you create lots of them. We have this problem with PathInfo's in dvc right now and working on getting rid of those in favor of using strings. It is also easy for anyone writing a new filesystem to accidentally hinder the performance when working with batches of files. |
Can you link to an issue? It's unclear if creating |
@ahirner It is creating |
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves fsspec#395
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves fsspec#395
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves fsspec#395
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves fsspec#395
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves fsspec#395
The PrefixFileSystem is a filesystem-wrapper. It assumes every path it is dealing with is relative to the `prefix`. After performing the necessary paths operation it delegates everything to the wrapped filesystem. Resolves #395 Co-authored-by: Ruslan Kuprieiev <[email protected]>
It would be useful to be able to specify a filesystem with an arbitrary root - e.g.
All operations would then be performed relative to this root - e.g.
fs.ls('/')
would then list the contents ofC:/temp
The text was updated successfully, but these errors were encountered: