From 3c247f56d4a4b22fc9ffec9ad4882a76ee47237d Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Fri, 24 Nov 2023 10:33:48 -0500 Subject: [PATCH] Allow non-str kwargs to FileSelector (#1437) --- fsspec/gui.py | 2 +- fsspec/implementations/reference.py | 1 + fsspec/tests/test_gui.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fsspec/gui.py b/fsspec/gui.py index c6e9eb9df..efa5b5f86 100644 --- a/fsspec/gui.py +++ b/fsspec/gui.py @@ -242,7 +242,7 @@ def __init__(self, url=None, filters=None, ignore=None, kwargs=None): else: self.init_protocol, url = "file", os.getcwd() self.init_url = url - self.init_kwargs = kwargs or "{}" + self.init_kwargs = (kwargs if isinstance(kwargs, str) else str(kwargs)) or "{}" self.filters = filters self.ignore = [re.compile(i) for i in ignore or []] self._fs = None diff --git a/fsspec/implementations/reference.py b/fsspec/implementations/reference.py index ebd54bc26..3b6752ee1 100644 --- a/fsspec/implementations/reference.py +++ b/fsspec/implementations/reference.py @@ -794,6 +794,7 @@ def cat(self, path, recursive=False, on_error="raise", **kwargs): raise NotImplementedError if isinstance(path, list) and (recursive or any("*" in p for p in path)): raise NotImplementedError + # TODO: if references is lazy, pre-fetch all paths in batch before access proto_dict = _protocol_groups(path, self.references) out = {} for proto, paths in proto_dict.items(): diff --git a/fsspec/tests/test_gui.py b/fsspec/tests/test_gui.py index 00586389f..38b83a2cf 100644 --- a/fsspec/tests/test_gui.py +++ b/fsspec/tests/test_gui.py @@ -17,3 +17,7 @@ def test_kwargs(tmpdir): gui = fsspec.gui.FileSelector(f"file://{tmpdir}", kwargs="{'auto_mkdir': True}") assert gui.fs.auto_mkdir + + gui = fsspec.gui.FileSelector(f"file://{tmpdir}", kwargs={"auto_mkdir": True}) + + assert gui.fs.auto_mkdir