-
Notifications
You must be signed in to change notification settings - Fork 86
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
bulk delete using STS #799
Conversation
pre-commit unrelated |
client = storage_transfer_v1.StorageTransferServiceClient() | ||
|
||
# Define the transfer job | ||
transfer_job = storage_transfer_v1.types.TransferJob( |
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.
Confused - is this a transfer job or a deletion job?
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.
I think it's a transfer job to an empty bucket
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.
Actually, it's a transfer from the Empty Bucker to the destination bucket, making sure delete_objects_unique_in_sink
is true, which means "Whether objects that exist only in the sink should be deleted. "
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.
yes, it's a dumb trick for STS. I'll add a comment
# List transfer operations for the job | ||
transfer_operations = operations_client.list_operations("transferOperations", filter_string) | ||
|
||
# Get the latest operation |
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.
latest by date - is this list guaranteed to be sorted?
if __name__ == "__main__": | ||
# Check for correct usage | ||
if len(sys.argv) != 2: | ||
print("Usage: python gcs_bulk_delete.py gs://bucket_name/path/to/delete") |
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.
print("Usage: python gcs_bulk_delete.py gs://bucket_name/path/to/delete") | |
print(f"Usage: python {sys.argv[0]} gs://bucket_name/path/to/delete") |
|
||
parser = argparse.ArgumentParser(description="List directories that can be deleted.") | ||
parser.add_argument("base_dir", help="The base directory to clean up.", type=str, nargs="+") | ||
parser.add_argument("--age", help="The age in days of the checkpoints to delete.", type=int, default=30) |
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.
NI (maybe):
The age of the checkpoints to delete (in days)
No description provided.