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

Enable sftp registry with fsspec #35

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ pywin32 = asyncssh[pywin32]
[options.entry_points]
fsspec.specs =
ssh = sshfs.spec:SSHFileSystem
sftp = sshfs.spec:SSHFileSystem
42 changes: 22 additions & 20 deletions tests/test_sshfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import tempfile
import warnings
from concurrent import futures
from datetime import datetime, timedelta
from pathlib import Path

import fsspec
import pkg_resources
import pytest
from asyncssh.sftp import SFTPFailure

Expand Down Expand Up @@ -73,28 +73,30 @@ def strip_keys(info):


def test_fsspec_registration(ssh_server):
fs = fsspec.filesystem(
"ssh",
host=ssh_server.host,
port=ssh_server.port,
username="user",
client_keys=[USERS["user"]],
)
assert isinstance(fs, SSHFileSystem)
for ep in pkg_resources.iter_entry_points(group="fsspec.specs"):
fs = fsspec.filesystem(
ep.name,
host=ssh_server.host,
port=ssh_server.port,
username="user",
client_keys=[USERS["user"]],
)
assert isinstance(fs, SSHFileSystem)


def test_fsspec_url_parsing(ssh_server, remote_dir, user="user"):
url = f"ssh://{user}@{ssh_server.host}:{ssh_server.port}/{remote_dir}/file"
with fsspec.open(url, "w", client_keys=[USERS[user]]) as file:
# Check the underlying file system.
file_fs = file.buffer.fs
assert isinstance(file_fs, SSHFileSystem)
assert file_fs.storage_options == {
"host": ssh_server.host,
"port": ssh_server.port,
"username": user,
"client_keys": [USERS[user]],
}
for ep in pkg_resources.iter_entry_points(group="fsspec.specs"):
url = f"{ep.name}://{user}@{ssh_server.host}:{ssh_server.port}/{remote_dir}/file"
with fsspec.open(url, "w", client_keys=[USERS[user]]) as file:
# Check the underlying file system.
file_fs = file.buffer.fs
assert isinstance(file_fs, SSHFileSystem)
assert file_fs.storage_options == {
"host": ssh_server.host,
"port": ssh_server.port,
"username": user,
"client_keys": [USERS[user]],
}


def test_info(fs, remote_dir):
Expand Down
Loading