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

How to test a new FileSystem implementation? #117

Open
NotSpecial opened this issue Jul 15, 2023 · 4 comments
Open

How to test a new FileSystem implementation? #117

NotSpecial opened this issue Jul 15, 2023 · 4 comments
Labels
question ❓ Further information is requested

Comments

@NotSpecial
Copy link

Hi, I've been using sshfs recently and it seems to work great with UPath.
However, UPath raises a warning as sshfs has not been tested to work with it.
And I think that's fair. While the basic stuff I've been doing works great, I think it would be good to ensure that all functionality is working.

I'd love to help address this and would appreciate some guidance.
Concretely, I have two questions:

  • Are there instructions anywhere how to set up a file system to be tested?
  • sshfs is an optional dependency. That means I would have to put it into setup.cfg under [options.extras_require] at dev = , is that correct?
@ap--
Copy link
Collaborator

ap-- commented Jul 19, 2023

So the simplest way of getting started is:

Add a simple custom implementation:

# upath/implementations/ssh.py
from upath.core import UPath

class SSHPath(UPath):
    pass

register that implementation:

# add to known_implementations
# https://github.com/fsspec/universal_pathlib/blob/e999d11250942cd7279fe9d699d0afcdba5dd8a6/upath/registry.py#L20

"ssh": "upath.implementations.ssh.SSHPath",

Create upath/tests/implementations/test_ssh.py and add the base tests:

import pytest

from upath import UPath
from upath.implementations.ssh import SSHPath

from ..cases import BaseTests


class TestSSHPath(BaseTests):
    @pytest.fixture(autouse=True)
    def path(self, local_testdir):  # fixme: this might need a fixture to spawn an ssh server for testing
        path = ...  # fixme: create your ssh:// base urlpath for tests
        self.path = UPath(path)
        self.prepare_file_system()

    def test_is_SSHPath(self):
        assert isinstance(self.path, SSHPath)

If tests fail, you can work on fixing them by overriding custom methods in upath.implementations.ssh.SSHPath and/or creating a custom subclassed _FSSpecAccessor in upath.implementations.ssh (see the other implementations on how they do it)

Thanks for wanting to contribute ❤️
And feel free to open a draft PR in case you want me to have a look!

Cheers,
Andreas

@ap--
Copy link
Collaborator

ap-- commented Jul 19, 2023

And forgot:

sshfs is an optional dependency. That means I would have to put it into setup.cfg under [options.extras_require] at dev = , is that correct?

Yes! That's correct

@NotSpecial
Copy link
Author

Thank you for the pointers! I'm unable to work on this for the next 2 or 3 weeks, but I definitely want to give it a go afterwards.

@ap-- ap-- added the question ❓ Further information is requested label Aug 2, 2023
@NotSpecial
Copy link
Author

I've started working on this (link to fork). Seems to (mostly) work out of the box, with only 4 tests failing. I may be able to dedicate some more time to it later this week to fix those and then open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question ❓ Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants