diff --git a/dask_expr/_core.py b/dask_expr/_core.py index ed9b8c41f..b8db367d6 100644 --- a/dask_expr/_core.py +++ b/dask_expr/_core.py @@ -507,8 +507,6 @@ def __getattr__(self, key): if key in _parameters: idx = _parameters.index(key) return self.operands[idx] - if is_dataframe_like(self._meta) and key in self._meta.columns: - return self[key] link = "https://github.com/dask-contrib/dask-expr/blob/main/README.md#api-coverage" raise AttributeError( diff --git a/dask_expr/tests/a.zip b/dask_expr/tests/a.zip new file mode 100644 index 000000000..11b96a7f5 Binary files /dev/null and b/dask_expr/tests/a.zip differ diff --git a/dask_expr/tests/test_meta.py b/dask_expr/tests/test_meta.py new file mode 100644 index 000000000..3ef2d13e7 --- /dev/null +++ b/dask_expr/tests/test_meta.py @@ -0,0 +1,49 @@ +import zipfile + +import dask.dataframe as dd +import fsspec +from fsspec.archive import AbstractArchiveFileSystem + + +class ZipFileSystem(AbstractArchiveFileSystem): + protocol = "tzip" + + def __init__( + self, + fo="", + **kwargs, + ): + super().__init__(self, **kwargs) + fo = fsspec.open(fo, mode="rb") + self.of = fo + self.fo = fo.__enter__() + self.zip = zipfile.ZipFile(self.fo, mode="r") + self.dir_cache = None + + @classmethod + def _strip_protocol(cls, path): + return super()._strip_protocol(path).lstrip("/") + + def __del__(self): + if hasattr(self, "zip"): + self.close() + del self.zip + + def close(self): + self.zip.close() + + def _open( + self, + path, + **kwargs, + ): + path = self._strip_protocol(path) + out = self.zip.open(path, "r") + return out + + +fsspec.register_implementation("tzip", ZipFileSystem) +with fsspec.open("tzip://a.csv", fo="a.zip") as f: + print(f.read(1)) +df = dd.read_csv("tzip://a.csv", storage_options={"fo": "a.zip"}) +print(df.head())