From 9295bbd16059ffddba4abe60610bddfc60682397 Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Wed, 4 Sep 2019 15:13:26 -0500 Subject: [PATCH] ssh: support opening files for writing --- dvc/remote/ssh/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dvc/remote/ssh/__init__.py b/dvc/remote/ssh/__init__.py index d0082d0e6..4cc76d972 100644 --- a/dvc/remote/ssh/__init__.py +++ b/dvc/remote/ssh/__init__.py @@ -251,12 +251,14 @@ class RemoteSSH(RemoteBASE): @contextmanager def open(self, path_info, mode="r", encoding=None): with self.ssh(path_info) as ssh, closing( - ssh.sftp.file(path_info.path, mode="r") + ssh.sftp.open(path_info.path, mode) ) as fd: - if mode == "rb": + if "b" in mode: yield fd else: - yield io.TextIOWrapper(fd, encoding=encoding) + yield io.TextIOWrapper( + fd, encoding=encoding, write_through=True + ) def list_cache_paths(self): with self.ssh(self.path_info) as ssh: