Repository navigation
Localserver for elephant-dataset - #721
Open
CozySocksAlways wants to merge 6 commits into
Open
CozySocksAlways wants to merge 6 commits into
CozySocksAlways wants to merge 6 commits into
Conversation
Introduce ELEPHANT_DATA_ROOT_URL constant for the default dataset URL Use it in download_datasets to allow test‑time patching Add tests with a local HTTP server covering versioned dataset download, integrity checks and fallback warning behavior
Collaborator
Closed
3 tasks done
CozySocksAlways
marked this pull request as ready for review
October 21, 2026 10:14
Contributor
Author
|
Contributor
Author
|
Dataset download now only falls back to the master branch when a 404 (missing version) occurs. Other HTTP errors such as 403 are re‑raised, preventing silent fallback. Added tests to verify the behavior and ensure no files are downloaded when a forbidden version is encountered.
kohlerca
reviewed
Oct 28, 2026
kohlerca
reviewed
Oct 28, 2026
kohlerca
requested changes
Oct 28, 2026
kohlerca
left a comment
Contributor
There was a problem hiding this comment.
In general, the additions look good and improved greatly the robustness or our data downloading API and GIN integration. I made some comments, especially how to address a more hard checking for the case where we are actually testing the connectivity and data in GIN.
| self.fail(f"GET {url} failed with HTTP {error.code}: {error}") | ||
|
|
||
| def test_root_url_redirects_to_gin(self): | ||
| """ |
Contributor
There was a problem hiding this comment.
We have a mixture of comments with #s and docstrings to detail each unit test throughout Elephant. I like the structure of this. However, it introduces a new style. Is this the best practice we should keep? If so, I suggest also documenting this (ADR) so that we have this in mind and can already adopt it in the WIP PRs.
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.
Desc
TestDownloadDatasetsinelephant/test/test_datasets.pydownloadeddataset-1/dataset-1.h5from GIN on every test run. On GitHub runners GIN often answers withHTTP Error 403: Forbidden(likely rate limiting / blocking of runner IPs),so the 5test_valid_data*tests failAdditionally, these tests used
patch.dict(os.environ, {...}, clear=True). On Windows, clearing the environment also removesSystemRoot, which is needed for networking. When such a test is the first one in the process to open a connection, it fails with[Errno 11001] getaddrinfo failedinstead of reaching the server. This has been hidden so far because other test modules happened to open a connection first.All HTTP errors on the versioned fetch fallback to trying to retrieve from master in datasets.py, only a 404 [not found] should fallback to master
Changes
elephant/datasets.py: the default root URL is now a module constantELEPHANT_DATA_ROOT_URL, read at call time, so tests can patch it.TestDownloadDatasetsserves a minimal mockelephant-datafrom a localhttp.serveron127.0.0.1and patchesELEPHANT_DATA_ROOT_URLto it, so no test in the class contacts GIN.The mock serves
raw/master/...and one fake versionraw/v9.9.9/...(withREADME.md), with different content, so tests can tell which one was downloaded.clear=Truefrom allpatch.dict(os.environ, ...)calls; only `ELEPHANT_DATA_ patched now.download_datasets:test_valid_data_versioned: version exists, so no warningtest_valid_data_version_fallback: version missing (404), soUserWarning, falls back to mastertest_valid_data_version_forbidden: access forbidden, raise exception. doesn't fall back to masterTestGinConnectivity(skipped unlessELEPHANT_NETWORK_TESTS=1), so the real GIN connectivity is still covered end to end, this will be run only oncanary_ci.ymland not on regular CI. These tests also only warn instead of failing the CI.To-Do