-
Notifications
You must be signed in to change notification settings - Fork 4
Clean up AnVIL AWS ODP mirror of HPRC files (#7740) #7972
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
dsotirho-ucsc
merged 5 commits into
develop
from
issues/nadove-ucsc/7740-clean-up-anvil-aws-odp-mirror-hprc-files
May 5, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fdc498b
Improve S3 batch deletion
hannes-ucsc df805e6
[1/4] Add mirror cleanup script (#7740)
nadove-ucsc 37bad1a
[2/4] Add mirror cleanup script (#7740)
hannes-ucsc 0fe4bd9
[3/4] Add mirror cleanup script (#7740)
hannes-ucsc af2ef79
[4/4] Add mirror cleanup script (#7740)
hannes-ucsc 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,66 @@ | ||
| from collections.abc import ( | ||
| Iterable, | ||
| Sequence, | ||
| ) | ||
| import csv | ||
| import logging | ||
| import sys | ||
|
|
||
| from more_itertools import ( | ||
| one, | ||
| ) | ||
|
|
||
| from azul import ( | ||
| CatalogName, | ||
| config, | ||
| ) | ||
| from azul.azulclient import ( | ||
| AzulClient, | ||
| ) | ||
| from azul.indexer.mirror_service import ( | ||
| MirrorService, | ||
| ) | ||
| from azul.lib import ( | ||
| R, | ||
| ) | ||
| from azul.logging import ( | ||
| configure_script_logging, | ||
| ) | ||
| from azul.service.storage_service import ( | ||
| StorageService, | ||
| ) | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def delete_files(catalog: CatalogName, diff: Iterable[tuple[str, str]]): | ||
| assert False | ||
| checksums, sizes = zip(*diff) | ||
| mirror_service: MirrorService = AzulClient().mirror_service(catalog) | ||
| service: StorageService = mirror_service._storage | ||
| keys = set() | ||
| assert config.is_anvil_enabled(catalog) | ||
| for checksum in checksums: | ||
| keys.add(f'file/{checksum}.md5') | ||
| keys.add(f'info/{checksum}.json') | ||
|
|
||
| assert len(keys) == 2 * len(checksums), R('There are duplicate checksums') | ||
| total_size = sum(map(int, sizes)) | ||
| print('This will permanently delete', len(checksums), 'files from', | ||
| service.bucket_name, 'totalling', total_size, 'bytes. Proceed? (y/N)') | ||
| if input() == 'y': | ||
| service.delete_objects(object_keys=keys) | ||
| else: | ||
| print('Cancelled.') | ||
|
|
||
|
|
||
| def main(argv: Sequence[str]): | ||
| path = one(argv) | ||
| with open(path) as f: | ||
| reader = csv.reader(f, delimiter='\t') | ||
| delete_files(config.default_catalog, reader) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| configure_script_logging(log) | ||
| main(sys.argv[1:]) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code of that method, it appears that errors are being ignored. According to a cursory investigation, Boto3'sdelete_objectsdoes not raise an exception if some objects could not be deleted, it simply returns a list of keys for which the objects could not be deleted. I don't expect any deletion failures when I use this script for the purpose of this issue, so in this PR just raise an exception if any of the objects fail to be deleted. Also use quiet mode (explained in the Boto3 docs for delete_objects).Please also create an issue about this so that we can fix this long term on develop.