-
Notifications
You must be signed in to change notification settings - Fork 43
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
Custom subclasses now require a fsspec
filesystem
#197
Comments
fsspec
fsspec
filesystem
Yes, this is intentional, because we can't really predict what a filesystem class could extract from the uri as storage_options. There are multiple ways to achieve what you want, including the one you suggest. Could you describe your intention behind creating a |
The protocol I'm creating a new subclass for is actually When communicating with a LSP server, you use the file URI to signal which file you are referring to. Typically you use It doesn't really matter, since as you say above it's very easy to work around. I just wasn't sure if this was a deliberate change or not. Feel free to close this |
Interesting! Thanks for sharing the use case. cross-referencing: neovim/neovim#21276 because there are quite a few useful links to more context. So if the "untitled" protocol is supposed to be a placeholder for in-memory files not written to disk, wouldn't the "memory" filesystem be an ideal candidate for it? from fsspec.registry import register_implementation as fsspec_register_implementation
from fsspec.implementations.memory import MemoryFileSystem
class UntitledFileSystem(MemoryFileSystem):
store = {}
pseudo_dirs = [""]
protocol = "untitled"
root_marker = "/"
@classmethod
def _strip_protocol(cls, path):
if path.startswith("untitled://"):
path = path[len("untitled://") :]
return super()._strip_protocol(path)
fsspec_register_implementation("untitled", UntitledFileSystem)
from upath import UPath
from upath.registry import register_implementation as upath_register_implementation
from upath.implementations.memory import MemoryPath
class UntitledPath(MemoryPath):
pass
upath_register_implementation("untitled", UntitledPath)
u = UPath("untitled:///abc/file.txt")
print(repr(u)) |
Previously it used to be possible to create arbitrary
UPath
subclasses like this:However,
UPath
now checks for and requires a correspondingfsspec
filesystem in theUPath._parse_storage_options
method, raising aValueError
if one is not found:Would you consider handling this case and returning an empty storage options dictionary if no fsspec filesystem is found?
Thanks,
Josiah
The text was updated successfully, but these errors were encountered: