Skip to content

Commit

Permalink
Check if downloaded file is empty (#385)
Browse files Browse the repository at this point in the history
* Check if downloaded file is empty

* pathlib
  • Loading branch information
shntnu authored Dec 12, 2024
1 parent 77644aa commit 4f91fb9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pycytominer/cyto_utils/cell_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,14 @@ def _download_s3(self, uri: str):

self.s3.download_file(bucket, key, tmp_file.name)

return tmp_file.name
# Check if the downloaded file exists and has a size greater than 0
tmp_file_path = pathlib.Path(tmp_file.name)
if tmp_file_path.exists() and tmp_file_path.stat().st_size > 0:
return tmp_file.name
else:
raise ValueError(
f"Downloaded file '{tmp_file.name}' is empty or does not exist."
)

def _load_metadata(self):
"""Load the metadata into a Pandas DataFrame
Expand Down

0 comments on commit 4f91fb9

Please sign in to comment.