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 hang when compression is used but compressed files are not retained #26

Merged
merged 1 commit into from
Oct 4, 2022
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
16 changes: 11 additions & 5 deletions streaming/base/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,20 +399,26 @@ def _download_shard_part(self,

# Is compression used?
if zip_info:
# Download the compressed form if missing (or wait on download).
# Download the compressed form if missing (or wait on its download).
zip_filename = os.path.join(self.local, self.split, zip_info.basename)
if not os.path.isfile(zip_filename):
self._download_file(zip_info.basename, wait)
# Waiter or doer?
if wait:
# If waiter: wait for *raw* version to exist (as the zip may be ephemeral).
wait_for_download(raw_filename, self.timeout)
else:
# If doer: download the zip version.
self._download_file(zip_info.basename)

# Validate and decompress (or wait on that).
self._decompress_shard_part(zip_info, zip_filename, raw_filename, compression, wait)
else:
# Download the raw version.
# Download the raw form (or wait on its download).
self._download_file(raw_info.basename, wait)

# Doer or waiter?
# Waiter or doer?
if not wait:
# If doer: load raw, validate.
# If doer: validate if requested.
if self.hash:
data = open(raw_filename, 'rb').read()
assert get_hash(self.hash, data) == raw_info.hashes[self.hash]
Expand Down