[Feature Request] fsspec/universal_pathlib integration

Open
#60 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start with the MemFS and AbstractFileSystem integration shown in the issue, then inspect fsspec and universal_pathlib registration APIs. Add coverage based on the provided UPath read/write example, and consider the work done when the relevant morefs filesystem subclasses can be created through UPath and registered with both systems.

Written by the indexing model from the issue text.

Description

As far as I understand it, this package cannot be used with universal pathlib right away, but all the building block are already there. All that's missing is registering the AbstractFileSystem subclasses with fsspec and creating fsspec/universal_pathlib subclasses and registering them with their registry.

This seems simple enough and seems to work in my testing:

from fsspec import AbstractFileSystem
from upath import UPath
from upath.registry import register_implementation

from morefs.memory import MemFS

# local instance for inspectability during testing
mem_fs = MemFS()


class MorefsMemPath(UPath):
    @classmethod
    def _fs_factory(
        cls, urlpath: str, protocol: str, storage_options: dict
    ) -> AbstractFileSystem:
        return mem_fs  # this should be MemFS(...)


fsname = "customfs"
register_implementation(fsname, MorefsMemPath)


def test_upath():
    testtext = "Hello from MemFS!"
    testfile = "/example.txt"
    p = UPath(f"{fsname}:///{testfile}")
    p.write_text(testtext)
    assert testtext == p.read_text()
    assert mem_fs.ls("/") == [testfile]
Dominant language
Python
Stars
18
Forks
3
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from iterative/morefs

All issues in iterative/morefs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.