From e19ff4774d2d6526255f1f85f1b44c9b66b3d404 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Thu, 26 Mar 2020 16:12:56 -0400 Subject: [PATCH 1/4] Only catch FileNotFound in mapping get --- fsspec/implementations/memory.py | 7 +++++-- fsspec/mapping.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fsspec/implementations/memory.py b/fsspec/implementations/memory.py index 001b6a31e..088c71a54 100644 --- a/fsspec/implementations/memory.py +++ b/fsspec/implementations/memory.py @@ -15,7 +15,7 @@ class MemoryFileSystem(AbstractFileSystem): protocol = "memory" root_marker = "" - def ls(self, path, detail=False): + def ls(self, path, detail=False, **kwargs): if path in self.store: # there is a key with this exact name, but could also be directory out = [ @@ -127,7 +127,10 @@ def copy(self, path1, path2, **kwargs): self.store[path2] = MemoryFile(self, path2, self.store[path1].getbuffer()) def cat(self, path): - return self.store[path].getvalue() + try: + self.store[path].getvalue() + except KeyError: + raise FileNotFoundError(path) def _rm(self, path): del self.store[path] diff --git a/fsspec/mapping.py b/fsspec/mapping.py index e8b45e62f..c04a31a3b 100644 --- a/fsspec/mapping.py +++ b/fsspec/mapping.py @@ -74,7 +74,7 @@ def __getitem__(self, key, default=None): key = self._key_to_str(key) try: result = self.fs.cat(key) - except: # noqa: E722 + except FileNotFoundError: if default is not None: return default raise KeyError(key) From 2b6f29bfcb7c879fc892fbe6d26296576011f11b Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Thu, 26 Mar 2020 16:23:12 -0400 Subject: [PATCH 2/4] oops --- fsspec/implementations/memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsspec/implementations/memory.py b/fsspec/implementations/memory.py index 088c71a54..f003a7db6 100644 --- a/fsspec/implementations/memory.py +++ b/fsspec/implementations/memory.py @@ -128,7 +128,7 @@ def copy(self, path1, path2, **kwargs): def cat(self, path): try: - self.store[path].getvalue() + return self.store[path].getvalue() except KeyError: raise FileNotFoundError(path) From 268178978ba932e8e4362c6e68bec2686af9edd0 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Fri, 27 Mar 2020 11:14:36 -0400 Subject: [PATCH 3/4] old msgpack for test --- fsspec/mapping.py | 4 ++-- tox.ini | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fsspec/mapping.py b/fsspec/mapping.py index c04a31a3b..2f27454da 100644 --- a/fsspec/mapping.py +++ b/fsspec/mapping.py @@ -71,9 +71,9 @@ def _str_to_key(self, s): def __getitem__(self, key, default=None): """Retrieve data""" - key = self._key_to_str(key) + k = self._key_to_str(key) try: - result = self.fs.cat(key) + result = self.fs.cat(k) except FileNotFoundError: if default is not None: return default diff --git a/tox.ini b/tox.ini index 63dfc2449..2e546f9e2 100644 --- a/tox.ini +++ b/tox.ini @@ -21,6 +21,7 @@ conda_deps= pytest pytest-cov fusepy==3.0.1 + msgpack<1.0.0 deps= hadoop-test-cluster==0.1.0 From 9f52132a6e2cbb6d4aebf6c90353cc1029f665ab Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Fri, 27 Mar 2020 11:55:54 -0400 Subject: [PATCH 4/4] longer msgpack name --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 2e546f9e2..e11080134 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ conda_deps= pytest pytest-cov fusepy==3.0.1 - msgpack<1.0.0 + msgpack-python<1.0.0 deps= hadoop-test-cluster==0.1.0