Skip to content

Commit

Permalink
handle missing s3 objects
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 committed Aug 30, 2023
1 parent 64b5064 commit 7cbf7d1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hub_utils/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def upload(self, bucket, prefix, local_file_path):
self._client.upload_file(local_file_path, bucket, prefix)

def download_latest(self, bucket, prefix, local_file_path):
objs = self._client.list_objects_v2(Bucket=bucket, Prefix=prefix)["Contents"]
objs = self._client.list_objects_v2(Bucket=bucket, Prefix=prefix).get("Contents")
if not objs:
return
latest = sorted(
[
os.path.basename(obj["Key"]).replace(".json", "").split("--")[1]
Expand Down

0 comments on commit 7cbf7d1

Please sign in to comment.