Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inifinite loop #1166

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions dask_expr/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Binary file added dask_expr/tests/a.zip
Binary file not shown.
49 changes: 49 additions & 0 deletions dask_expr/tests/test_meta.py
Original file line number Diff line number Diff line change
@@ -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())
Loading