Skip to content

Commit

Permalink
Update on "Adding lock mechanism to prevent on_disk_cache downloading…
Browse files Browse the repository at this point in the history
… twice"


Fixes #144

[ghstack-poisoned]
  • Loading branch information
VitalyFedyunin committed May 17, 2022
1 parent 1e588b8 commit 25df48b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/test_remote_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import torchdata

from _utils._common_utils_for_test import check_hash_fn, create_temp_dir
from _utils._common_utils_for_test import check_hash_fn, create_temp_dir, IS_WINDOWS
from torch.utils.data import DataLoader

from torchdata.datapipes.iter import (
Expand Down Expand Up @@ -180,9 +180,10 @@ def _read_and_decode(x):
self.assertTrue(os.path.exists(expected_csv_path))
self.assertEqual(expected_csv_path, csv_path)

dl = DataLoader(file_cache_dp, num_workers=3, multiprocessing_context="fork", batch_size=1)
expected = [[os.path.join(self.temp_dir.name, root_dir, f"{i}.csv")] for i in range(3)] * 3
self.assertEqual(sorted(expected), sorted(list(dl)))
if not IS_WINDOWS:
dl = DataLoader(file_cache_dp, num_workers=3, multiprocessing_context="fork", batch_size=1)
expected = [[os.path.join(self.temp_dir.name, root_dir, f"{i}.csv")] for i in range(3)] * 3
self.assertEqual(sorted(expected), sorted(list(dl)))

def test_s3_io_iterdatapipe(self):
# sanity test
Expand Down
2 changes: 2 additions & 0 deletions torchdata/datapipes/iter/util/cacheholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ def __iter__(self):
old_promise_filename = None
old_filename = None
first_entry = True
# TODO(VitalyFedyunin): Limit buffer size here. It is only contains file names from archive,
# but better be save than sorry.
buffer = []
for filename in self.source_datapipe:
promise_filename = _find_promise_file(filename)
Expand Down

0 comments on commit 25df48b

Please sign in to comment.