Skip to content

Retry dataset extraction after a failed fetch - #131

Open
vishesh9131 wants to merge 1 commit into
prabhuomkar:masterfrom
vishesh9131:fix/dataset-extraction-retry
Open

vishesh9131 wants to merge 1 commit into
prabhuomkar:masterfrom
vishesh9131:fix/dataset-extraction-retry

Conversation

@vishesh9131

Copy link
Copy Markdown

Description of the change

cmake/fetch_imagenette.cmake and cmake/fetch_flickr8k.cmake run cmake -E tar without checking its result, and decide whether to fetch only by checking whether the dataset directory exists. If extraction is interrupted (I hit this with a full disk: cmake -E tar: error: No space left on device), the script still deletes the archive and prints "done", and every later build skips the fetch because the partial directory exists. I ended up with 12,234 of 13,394 Imagenette files, and the CNN tutorial would silently train on that.

MNIST and CIFAR-10 are not affected, since they verify the extracted files' MD5s via check_files.

Fix

  • Extract into the download directory and fail on extraction errors (COMMAND_ERROR_IS_FATAL ANY, available since CMake 3.19; the project requires 3.28.6).
  • Move the extracted directory into place with file(RENAME) only after extraction succeeded, then remove the download directory.
  • Flickr8k: remove any partial source directories before refetching, since the fetch triggers when either one is missing.

The resulting layout of data/ is unchanged.

Testing

CI builds with DOWNLOAD_DATASETS=OFF, so I tested the scripts in script mode (cmake -P) against small local archives served via file:// URLs (URL and MD5 substituted), including truncated archives:

Check Before After
imagenette: corrupt archive fails the fetch FAIL PASS
imagenette: corrupt archive leaves no dataset dir FAIL PASS
imagenette: retry fetches complete dataset FAIL PASS
imagenette: download dir cleaned up PASS PASS
flickr8k: corrupt archive fails the fetch FAIL PASS
flickr8k: corrupt archive leaves no dataset dir FAIL PASS
flickr8k: retry fetches complete dataset FAIL PASS
flickr8k: download dir cleaned up PASS PASS

I also ran a full build with DOWNLOAD_DATASETS=ON (real downloads, CMake 4.4, Ubuntu 22.04): Imagenette and Flickr8k were fetched and extracted into the same layout as before, the download directories were removed, and all 17 tutorials built.

Type Of Change

  • Bug Fix (non-breaking change that fixes an issue)
  • New Feature
  • New PyTorch tutorial
  • Breaking Change (cmake changes, fix or feature that would cause existing functionality to not work as expected)

Related Issues

None; found while building the tutorials locally (no existing issue).

Development & Code Review

  • cpplint rules passes locally (run cmake -P cpplint.cmake)
  • CI is passing
  • Changes have been reviewed by at least one of the maintainers

fetch_imagenette and fetch_flickr8k ignored tar extraction errors and only
check whether the dataset directory exists, so an interrupted extraction
(e.g. disk full) left a partial dataset that was never fetched again.
Extract into the download directory, fail on extraction errors, and move
the result into place only on success.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant