improve robustness of remote dataset retrieval#381
Merged
sophiamaedler merged 4 commits intomainfrom Mar 1, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens scportrait.data._datasets._get_remote_dataset(...) against incomplete prior downloads by re-triggering downloads when the dataset directory exists but the expected target file is missing, and adds unit tests to prevent regressions.
Changes:
- Add missing-expected-file detection to
_get_remote_dataset(...)and route download decisions through a singleshould_downloadflag. - Pass an
overwriteflag into_download(...)when forcing downloads or recovering from an incomplete dataset state. - Add unit tests covering download/redownload/skip behaviors for
_get_remote_dataset(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/scportrait/data/_datasets.py |
Adds expected-file checks and consolidated download/overwrite decision logic to make remote dataset retrieval self-healing. |
tests/unit_tests/data/test_datasets.py |
Adds regression tests validating download invocation behavior under directory/file-present/missing scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
This PR improves robustness of remote dataset retrieval by handling incomplete prior downloads more safely, and adds regression coverage. Fixes #364
What changed
src/scportrait/data/_datasets.py_get_remote_dataset(...)logic to detect incomplete dataset states:name) is missing, it now re-downloads automatically.force_downloadoverwrite=Trueto recover from stale/incomplete artifacts.Tests added
tests/unit_tests/data/test_datasets.pyAdded new unit tests for
_get_remote_dataset(...):These tests mock
_downloadandget_data_dirso behavior is deterministic and isolated from network dependencies.Why
Previously, an interrupted or failed download could leave behind a dataset directory without the expected file. In that state, the loader could incorrectly skip download and later fail with confusing file-not-found errors.
This change makes the retrieval path self-healing for that common partial-download scenario.