Skip to content

Commit

Permalink
fix: ub.loads: tempfile naming error on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
trojblue committed Jul 18, 2024
1 parent 3dcdaca commit 1d454d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion noteooks/test_general.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"2024-06-13 08:02:25,062 [INFO] UniLogger: UniLoader.loads: .jpg LOADED from \"/tmp/tmpe133vzrb.jpg\" in 0.00s\n"
"2024-07-18 10:40:58,906 [INFO] UniLogger: UniLoader.loads: .jpg LOADED from \"/tmp/tmprso5usv1.jpg\" in 0.00s\n"
]
},
{
Expand Down
7 changes: 6 additions & 1 deletion unibox/utils/uni_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ def _load_from_s3(self, s3_uri: str):
try:
with tempfile.TemporaryDirectory() as tmp_dir:
local_path = Path(s3_client.download(s3_uri, tmp_dir))
return self.loads(local_path)
if local_path.exists() and local_path.is_file():
return self.loads(local_path)
else:
self.logger.error(f'File was not found at the downloaded path: "{local_path}"')
return None
except Exception as e:
self.logger.error(f'Error loading from S3 at "{s3_uri}": {e}')
return None


def _load_from_url(self, url: str):
"""Download a file from a URL and load its content."""
response = requests.get(url)
Expand Down

0 comments on commit 1d454d5

Please sign in to comment.