33from shutil import copyfile , make_archive
44from xml .etree import ElementTree as et
55
6- from hyp3lib . aws import upload_file_to_s3
6+ from hyp3lib import aws
77
88import hyp3_opera_rtc
99
@@ -12,6 +12,12 @@ class FailedToFindLineageStatementError(Exception):
1212 pass
1313
1414
15+ def delete_prefix (bucket : str , bucket_prefix : str ) -> None :
16+ response = aws .S3_CLIENT .list_objects_v2 (Bucket = bucket , Prefix = bucket_prefix )
17+ for obj in response .get ('Contents' , []):
18+ aws .S3_CLIENT .delete_object (Bucket = bucket , Key = obj ['Key' ])
19+
20+
1521def upload_rtc (bucket : str , bucket_prefix : str , output_dir : Path ) -> None :
1622 output_files = [f for f in output_dir .iterdir () if not f .is_dir ()]
1723
@@ -20,8 +26,9 @@ def upload_rtc(bucket: str, bucket_prefix: str, output_dir: Path) -> None:
2026 output_zip = make_zip (output_files , output_dir )
2127 output_files .append (output_zip )
2228
29+ delete_prefix (bucket , bucket_prefix )
2330 for output_file in output_files :
24- upload_file_to_s3 (output_file , bucket , bucket_prefix , chunk_size = 100_000_000 )
31+ aws . upload_file_to_s3 (output_file , bucket , bucket_prefix , chunk_size = 100_000_000 )
2532
2633
2734def make_zip (output_files : list [Path ], output_dir : Path ) -> Path :
0 commit comments