Make Geant4 dataset downloads resumable and fail loudly - #97
Open
kavyawadhwa134 wants to merge 2 commits into
Open
Make Geant4 dataset downloads resumable and fail loudly#97kavyawadhwa134 wants to merge 2 commits into
kavyawadhwa134 wants to merge 2 commits into
Conversation
A failed dataset download was silently swallowed: concurrent.futures.wait() never inspects future results, so install_datasets() reported success and printed the on-disk size even when a dataset was missing. Observed live with G4NDL (1.06 GB) — the install claimed success, the data was absent, and the whole 1.06 GB had to be re-fetched from scratch on the next run. - surface worker exceptions via as_completed()/result() instead of wait() - retry with HTTP Range resume so a dropped connection continues from the last received byte rather than restarting a multi-GB transfer - read in 1 MiB chunks instead of 1 KiB, cutting ~1.1M loop iterations and tqdm updates per GB down to ~1k - count len(chunk) rather than the nominal chunk size, which over-reported progress on every final short chunk Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes four defects in
files/datasets.pythat made the Geant4 dataset install slow and unreliable.The headline bug: a failed download was silently reported as success.
concurrent.futures.wait()never inspects future results, so an exception inside_download_extract_dataset(a dropped connection, an HTTP error) was discarded.install_datasets()then returned normally and even printedGeant4 datasets size on disk after extraction: ..., despite a dataset being absent. The failure only resurfaced much later as an opaque Geant4 runtime error when the data couldn't be found.I hit this for real while verifying the branch:
G4NDL(1.06 GB, over half the entire bundle) failed mid-download, the install reported success with only 10 of 11 datasets present, and the full 1.06 GB had to be re-fetched from scratch on the next run — turning a ~45 min install into ~90 min.Changes
as_completed()and call.result()instead of barewait(), so a failed dataset raises rather than masquerading as a complete install.pbar.update()calls per GB down to ~1k. At 1 KiB,G4NDLalone drove over a million tqdm updates.len(chunk), not the nominal chunk size — the old code over-reported progress on every final short chunk.Test plan
Verified against the live
cern.ch/geant4-dataserver on macOS (Geant4 11.2.2):206with the exact byte countRange: bytes=106496-and resumed exactly there. Final size matchedcontent-lengthexactly — no gap, no double-count.290745== servercontent-length290745install_datasets()now raisesHTTPErrorinstead of returning "success"['run', 'id', 'primaries', 'track'], ids 0→99Not addressed here
Found while testing, left out to keep this focused — happy to open separate issues/PRs:
app.run(n_events=100), but the method signature isrun(self, primaries)— the documented example raisesTypeError.CMakeLists.txtsets noINSTALL_RPATH, so against a shared-library Geant4 the built extension has noLC_RPATHentries andimportfails withLibrary not loaded: @rpath/libG4Tree.dylibunlessDYLD_LIBRARY_PATHis set manually.data_directory()appends the app name toapplication_directory(), which already ends in it (viaplatformdirs), yielding.../geant4_python_application/geant4_python_application/geant4/<version>/data.dataset1.py,alt_datasets.py,old_datasets.pyand2datasets.pyare unused drafts shipped inside the package.datasets.py; downloads are no longer integrity-checked.🤖 Generated with Claude Code