fsspec / fsspec/sshfs

To be able to use relative (to HOME) path

Open
#55 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

effort-medium enhancement p2-medium
Dominant language
Python
Stars
89
Forks
21
PR merge metrics
No merged PRs in 30d

Description

not yet sure if relates to

but ATM it seems it is impossible to use relative path :-/ Trying with a simple open

and this helper script
#!/usr/bin/env python3

import fsspec
print(f'fsspec {fsspec.__version__}')
from fsspec import open
import sys

url, lines = sys.argv[1:3]
lines = int(lines)
with open(url, 'r') as f:
    for i in range(lines):
        print(f.readline().rstrip())

works for full path:

❯ python ~/.tmp/fsspec_ssh ssh://smaug.datalad.org/home/yoh/.emacs 1
fsspec 2024.12.0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

but that requires then first knowing/discovering the home folder for the user (usually ssh uri is just like hostname:path/relative/to/home) and would require some direct ssh invocation first. Any attempt to make it relative, didn't work:

❯ python ~/.tmp/fsspec_ssh ssh://smaug.datalad.org/~/.emacs 1
...
FileNotFoundError: [Errno 2] No such file or directory

❯ python ~/.tmp/fsspec_ssh ssh://smaug.datalad.org/./.emacs 1
...
FileNotFoundError: [Errno 2] No such file or directory

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Reproduce the examples with the helper script and fsspec.open using both an absolute path and paths relative to HOME. Trace how ssh:// URLs are parsed and passed to the SFTP backend. Done means a path such as ssh://smaug.datalad.org/~/.emacs or ./ .emacs resolves relative to the remote user's home directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.