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

Remove dataloader close #2589

Merged
merged 3 commits into from
Sep 8, 2023
Merged
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
8 changes: 7 additions & 1 deletion deeplake/enterprise/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,9 @@ def sample_by(

def close(self):
"""Shuts down the workers and releases the resources."""
if self._internal_iterator is not None:
self._internal_iterator = None
if self._dataloader is not None:
self._dataloader.close()
self._dataloader = None

def pytorch(
Expand Down Expand Up @@ -781,8 +782,10 @@ def __iter__(self):

dataset_read(self._orig_dataset)


if self._internal_iterator is not None:
self._internal_iterator = iter(self._internal_iterator)

return self

def __next__(self):
Expand All @@ -792,6 +795,9 @@ def __next__(self):
self._internal_iterator = iter(self._dataloader)
return next(self._internal_iterator)

def __del__(self):
self.close()


def dataloader(dataset, ignore_errors: bool = False) -> DeepLakeDataLoader:
"""Returns a :class:`~deeplake.enterprise.dataloader.DeepLakeDataLoader` object which can be transformed to either pytorch dataloader or numpy.
Expand Down
Loading