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
SSH / SFTP Implementations #208
Comments
Hi @juftin, thank you for reporting! This is a "bug" in the sense, that even though ssh filesystems are untested, it should be possible to avoid this for all untested filesystems where the netloc would be stripped or end up in the path anchor. Correct behavior can be restored by setting a special internal setting in UPath's flavour implementation. Note that the following code fixes behavior for ssh: import upath
# ------- v0.2.2 specific
# Please don't use these two lines in your code:
from upath._flavour import WrappedFileSystemFlavour
WrappedFileSystemFlavour.protocol_config["netloc_is_anchor"].add("ssh")
# There's going to be a correct fix implemented in `universal_pathlib`
# -------
ssh_path = upath.UPath("ssh://juftin@192.168.1.123:22/var/local")
print(f"{ssh_path.parts=}") # ssh_path.parts=('/', 'var', 'local')
print(f"{ssh_path.root=}") # ssh_path.root='/' For a general fix, I need to check if it's possible to infer the But anyways, it would of course be great to add an SSHPath implementation and thoroughly test all path functionality. Cheers, |
Oh very neat. I saw the SFTPFileSystemFlavour - but wasn't sure what might be needed there. I'd be happy to get a SSHPath implementation going - that would need this upstream |
No, not really. You could add universal_pathlib/upath/_flavour.py Lines 106 to 118 in 380144c
and make a SFTPPath / SSHPath implementation like the others. Most of the work will be to make a test fixture that sets up a local ssh server to test against. https://github.com/fsspec/filesystem_spec/blob/master/fsspec/implementations/tests/test_sftp.py this should be a good source for how to set this up. |
The following script works differently between
0.2.2
and0.0.24
and I'm trying to figure the cleanest way to account for it:(yeah, I know SFTP/SSH isn't a current implementation - I'd be happy to help to implement it, it looks to work pretty seamlessly without any custom functions)
0.0.24
0.2.2
The difference here is that
0.2.2
assumes you are starting from the user's home directory and every path is relative from there, this means paths likessh://juftin@192.168.1.123:22/var/local
are no longer working.In my case the previous way the SFTP/SSH filesystem went to the root of the directory tree was more intuitive. I've been working on getting this to work for browsr / textual-universal-directorytree , the below code works for me:
The text was updated successfully, but these errors were encountered: