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

Free disk size (todo) #172

Closed
wants to merge 8 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions tensorflow_datasets/core/dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,24 @@ def _log_download_bytes(self):
# Print is intentional: we want this to always go to stdout so user has
# information needed to cancel download/preparation if needed.
# This comes right before the progress bar.

stat = os.statvfs('/')
us marked this conversation as resolved.
Show resolved Hide resolved
free_disk_size = (stat.f_bavail * stat.f_frsize) / 1024
dataset_size = self.info.size_in_bytes
def _check_disk_size():
if (dataset_size > free_disk_size ) :
raise IOError("Not enough disk space!!\nDataset size : {dataset_size} \nFree size : {free_disk_size} \nYou need to extra {needed_disk_size} to download."
.format(dataset_size=units.size_str(dataset_size),
free_disk_size=units.size_str(free_disk_size),
needed_disk_size=units.size_str(dataset_size-free_disk_size)))

_check_disk_size()

size_text = units.size_str(self.info.size_in_bytes)
termcolor.cprint(
"Downloading / extracting dataset %s (%s) to %s..." %
(self.name, size_text, self._data_dir),
attrs=["bold"])
# TODO(tfds): Should try to estimate the available free disk space (if
# possible) and raise an error if not.

@abc.abstractmethod
def _info(self):
Expand Down