question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ssh filesystem and put_file are incompatible

See original GitHub issue

Using a ssh filesystem and put_files gives an error

import fsspec
import sshfs
fs = fsspec.filesystem("ssh", host='xx.xx.xx.xx', username='eouser') 
fs.put_file(lpath="t", rpath="/home/me/t")

I receive an exception:

File "/home/me/miniconda3/envs/olci/lib/python3.9/site-packages/fsspec/callbacks.py", line 66, in relative_update
    self.value += inc
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

The reason is because the ‘write’ method in paramiko does not return the length of written data. https://github.com/jbouse-debian/paramiko/blob/master/paramiko/file.py#L385

Unless paramiko changes their function, the method ‘put_file’ in spec.py should test segment_len to be None and skip the update… or use len(data) as a default as follows:

                    segment_len = f2.write(data)
                    if segment_len is None:
                          segment_len = len(data)
                    callback.relative_update(segment_len)

I’m not sure if this is a good solution…

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
martindurantcommented, Oct 11, 2022

In https://github.com/conda-forge/sshfs-feedstock/blob/main/recipe/meta.yaml , missing noarch: python in the build section.

1reaction
ghislainpcommented, Oct 11, 2022

I suppose you could try temporarily with

import fsspec
import sshfs
fsspec.register_implementation("ssh", sshfs.SSHFileSystem)

This does not work well with prefect for two reasons:

1- it seems that prefect uses the full uri for the destination path in put_file, I don’t know if it is valid but anyway the SFTP implementation was able to remove the protocle and host part. The SSHFileSystem implementation does not remove it and it fails. I don’t have a direct way to change this in prefect.

2- The SFTP implementation automatically create the required directory (e.g. uri ssh://host/directory/subdirectory/file.txt works even if directory does not exist yet). The SSHFileSystem does not create these directories. Prefect relies on the first behavior.

Let me know if these problemes are considered as bugs in the SSHFileSystem or if I should report the issue to prefect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use SSHFS to Mount Remote File Systems Over SSH
Whenever you are mounting a remote filesystem in a Linux environment, you first need an empty directory to mount it in. Most Linux...
Read more >
connection — Fabric documentation
A connection to an SSH daemon, with methods for commands and file transfer. ... with Connection('host') as c: c.run('command') c.put('file'). Warning.
Read more >
Why am I suddenly unable to write to this sshfs volume?
I do a lot of editing of files on the server, so I use sshfs to do so. I mount the directory with...
Read more >
Can't put file into ram with secure ftp - Stack Overflow
I'm using coldfusion 9 and I'm trying to grab a file from an ftp site and load it into ram instead of the...
Read more >
How Do I Resolve Error "Incompatible file system of the source ...
After the migration feasibility check is complete, you receive error message "SMS.6509 Incompatible file system of the source server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found