-
Notifications
You must be signed in to change notification settings - Fork 26
Update Downloader Hash #1279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Update Downloader Hash #1279
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c991a22
proceed with download on hash mismatch, with warning.
j-c-c 2cc6eb8
update hash in registry
j-c-c b58cada
stack_level. unused variable
j-c-c 23a8b1e
add scheduled_workflow and scheduled downloader test.
j-c-c cb237b7
same py version
j-c-c fa1b431
Use logger warning. Update test to fail on hash mismatch warning.
j-c-c 6cbbf33
Workflow updates: Run on develop, remove check, remove fail on warnings.
j-c-c c48ad9f
Workflow updates: Checkout develop, set cron off-hour, remove needs f…
j-c-c 679b2bf
test hash mismatch warning works
j-c-c 77c9ad7
checkout on develop. mark test as scheduled.
j-c-c 363f02e
remove manual run-workflow button
j-c-c File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: ASPIRE Python Scheduled Workflow | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '15 0 * * 0' # Every Sunday at 00:15 UTC | ||
|
|
||
|
|
||
| jobs: | ||
| scheduled-tests: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: develop | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.10' | ||
| - name: Install Dependencies | ||
| run: | | ||
| pip install -e ".[dev]" | ||
| - name: Scheduled Tests | ||
| run: pytest -m scheduled | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from aspire.downloader import download_all | ||
| from aspire.downloader.data_fetcher import _data_fetcher, fetch_data | ||
|
|
||
|
|
||
| @pytest.mark.scheduled | ||
| def test_download_all(caplog): | ||
| """Fail if a hash mismatch warning is logged during download.""" | ||
| caplog.clear() | ||
| with caplog.at_level("WARNING"): | ||
| _ = download_all() | ||
|
|
||
| if "Hash mismatch" in caplog.text: | ||
| pytest.fail(f"Hash mismatch warning was logged.\nCaptured logs:\n{caplog.text}") | ||
|
|
||
|
|
||
| @pytest.mark.scheduled | ||
| def test_fetch_data_warning(caplog): | ||
| """Test that we get expected warning on hash mismatch.""" | ||
| # Use the smallest dataset in the registry | ||
| dataset_name = "emdb_3645.map" | ||
|
|
||
| # Remove file from cache if it exists | ||
| cached_path = Path(_data_fetcher.path) / dataset_name | ||
| if cached_path.exists(): | ||
| cached_path.unlink() | ||
|
|
||
| # Save original hash from the registry | ||
| original_hash = _data_fetcher.registry.get(dataset_name) | ||
| assert original_hash is not None | ||
|
|
||
| # Temporarily override the hash to simulate a mismatch | ||
| _data_fetcher.registry[dataset_name] = "md5:invalidhash123" | ||
|
|
||
| try: | ||
| caplog.clear() | ||
| with caplog.at_level("WARNING"): | ||
| path = fetch_data(dataset_name) | ||
| assert path # Should return the path to the downloaded file | ||
| assert f"Hash mismatch for {dataset_name}" in caplog.text | ||
| finally: | ||
| # Restore original hash | ||
| _data_fetcher.registry[dataset_name] = original_hash |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.