Skip to content
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

expose a preconfigured dirfs instance on mapper objects #1302

Merged
merged 3 commits into from
Jul 18, 2023

Conversation

keewis
Copy link
Contributor

@keewis keewis commented Jul 4, 2023

I'm pretty happy with the way dirfs instances help working with mapper objects, but constructing one that uses the same parameters as the mapper is a bit more work than I would wish:

m = fsspec.get_mapper(url, ...)
dirfs = fsspec.filesystem("dirfs", path=url, fs=m.fs)
dirfs.open(...)

As suggested in #1269, this exposes a dirfs instance as a cached property, which means that anyone who doesn't need the dirfs instance doesn't have to wait the (very) little time it takes to construct one. With that, the above snipped would become:

m = fsspec.get_mapper(url, ...)
m.dirfs.open(...)

I'm not particularly attached to the name of the property, so I'm happy to change that.

Also, I didn't discuss this change before implementing it, so feel free to close if you don't think growing the mapper API makes sense in this case.

@martindurant
Copy link
Member

I am happy with this. I only request a short docstring on the attribute explaining what it does, and to include it in the API doc for FSMap.

@martindurant martindurant merged commit 22ede85 into fsspec:master Jul 18, 2023
@keewis keewis deleted the dirfs-mapper branch November 15, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

using filesystem methods with mapper keys
2 participants