Skip to content

Commit 41c6236

Browse files
authored
[binaries] metadata lambda to delete existing metadata (#7359)
Delete previous metadata when new wheel is uploaded This way, if the lambda fails, there will not be stale data Testing: checked on something that doesn't have a metadata file already checked on something that does have metadata file already I think it might be better if the metadata is uploaded with the binary, maybe add some s3 metadata to the binary and whl to show theyre in sync, then the lambda deletes metadata whose sync tag doesn't match the binary's If the binary is uploaded manually, then it there won't be metadata, but I'm not sure how often this happens. Also domains that do custom stuff? but idk how often this happens either. Also additional packages that get uploaded to the index?
1 parent 6e3763d commit 41c6236

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

aws/lambda/whl_metadata_upload_pep658/lambda_function.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ def upload_s3(bucket: str, key: str, filename: str, dry_run: bool) -> None:
2727
)
2828

2929

30+
def delete_s3(bucket: str, key: str, dry_run: bool) -> None:
31+
print(f"Deleting {bucket}/{key}")
32+
if not dry_run:
33+
get_client(False).delete_object(Bucket=bucket, Key=key)
34+
35+
3036
def lambda_handler(event: Any, context: Any, dry_run: bool = False) -> None:
3137
zip_location = "/tmp/wheel.zip"
3238
metadata_location = "/tmp/METADATA"
@@ -38,6 +44,10 @@ def lambda_handler(event: Any, context: Any, dry_run: bool = False) -> None:
3844
continue
3945
print(f"Processing {bucket}/{key}")
4046

47+
# Delete existing metadata file if it exists. If we fail to extract a
48+
# new one, we don't want to leave the old one around.
49+
delete_s3(bucket, f"{key}.metadata", dry_run)
50+
4151
if os.path.exists(zip_location):
4252
os.remove(zip_location)
4353

0 commit comments

Comments
 (0)