fsspec / fsspec/filesystem_spec
Ability to check if a filesystem implements an interface
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 490
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 38
Description
Apologies if this is currently possible, I couldn't find a clean way to achieve this.
I think it would be useful to have a way to check if a given filesystem implements a given interface (e.g. is cat_file implemented for the ssh protocol?).
Currently, when calling an interface that is not implemented, a NotImplementedError will be thrown since this method is defined in the base class. Checking if a method with the requested name is present in the class will always return True since it's defined in the base class (but not implemented). I guess there are some workarounds such as using the inspect module but
My use case is a library that uses fsspec for file access and relies on specific interfaces. If the interface is not present for the filesystem it would be nice to throw an exception pointing the user to the specific fsspec protocol and method that needs to be implemented (so they can open an issue to request it, if it makes sense).
This can currently be achieved wrapping the code in a try/except block and checking for NotImplementedError but personally I don't find this solution very clean. In order to avoid wrapping the code one could also add this try/except block on initialization to check if the method is implemented (by calling it with trivial arguments) but this may introduce some delay in the case the method is implemented, which would be most cases so I also don't like this.
There already exists a nice way to check if a protocol is available in fsspec using the registry, I guess this could be an extension to this feature, where the individual filesystems register what interfaces they support.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No concrete file or test is named. Start by tracing the filesystem base class, protocol registry, and existing NotImplementedError behavior; determine the API and registration model needed to report supported interfaces, then verify that callers can distinguish implemented and unavailable methods without invoking filesystem operations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100