Avoid rate-limiting when a dataset is already downloaded#112
Merged
Conversation
moz-johanndiedrick
approved these changes
Jul 7, 2026
moz-johanndiedrick
left a comment
Collaborator
There was a problem hiding this comment.
This looks good to me! Nice improvements :)
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.
Problem
download_datasetandload_datasetalways called_get_download_plan, which hits the rate-limitedPOST /datasets/{id}/download endpoint, in order to obtain the archivefilenameandchecksum. This happened even when no download was necessary (e.g. the archive was already present on disk). As a result, users re-running loads/downloads on cached datasets were getting rate-limited despite no data transfer taking place.See #102
Solution
Source the
filename,id, andchecksumfromGET /datasets/{id}(get_dataset_details) instead of from the download-session endpoint, and only create a download session when a download will actually happen. The existence check now runs before any call to the rate-limited endpoint.Core changes
_download_datasetorchestrator (replaces old_resolve_and_execute_download_planfunction) that owns the full flow:_get_download_planis now only called when there is no cached downloaded dataset available. Its signature takes a resolvedtarget_filepathinstead of adownload_directory, and it no longer returnsfilename(dropped fromDownloadPlan), since the filename now comes from dataset details.get_dataset_detailsis the single source of dataset metadata: it validates thatfilename/idare presentresolve_dataset_idwas removed.How the flow changed
Before: resolve ID (GET) → always create download session (POST, rate-limited) → decide whether to download.
After: get details (GET, provides id + filename + checksum) → check if archive already exists → skip entirely if cached, otherwise create the download session (POST) and download.
Implications for users
load_dataset/download_datasetcalls on already-downloaded archives no longer touch the rate-limited endpoint.get_dataset_details,download_dataset,load_dataset, andsave_dataset_to_diskkeep identical signatures