Skip to content
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

Merged
merged 2 commits into from
Nov 12, 2024
Merged

bulk delete using STS #799

merged 2 commits into from
Nov 12, 2024

Conversation

dlwh
Copy link
Member

@dlwh dlwh commented Nov 12, 2024

No description provided.

@dlwh
Copy link
Member Author

dlwh commented Nov 12, 2024

pre-commit unrelated

client = storage_transfer_v1.StorageTransferServiceClient()

# Define the transfer job
transfer_job = storage_transfer_v1.types.TransferJob(

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?

Copy link
Contributor

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

Copy link
Contributor

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. "

Copy link
Member Author

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

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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Contributor

@abhinavg4 abhinavg4 Nov 12, 2024

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)

@dlwh dlwh merged commit cfa4fd0 into main Nov 12, 2024
7 of 8 checks passed
@dlwh dlwh deleted the gcs_bulk_delete branch November 12, 2024 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants