diff --git a/pycytominer/cyto_utils/cell_locations.py b/pycytominer/cyto_utils/cell_locations.py index 5c4edeb7..9906317c 100644 --- a/pycytominer/cyto_utils/cell_locations.py +++ b/pycytominer/cyto_utils/cell_locations.py @@ -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