Skip to content

Commit

Permalink
refact: move the action that filter file from folder into
Browse files Browse the repository at this point in the history
  • Loading branch information
brosoul committed Dec 10, 2024
1 parent 22e19f8 commit e3e58cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 5 additions & 2 deletions python/aibrix/aibrix/downloader/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ def download_directory(self, local_path: Path):
used to download the directory.
"""
directory_list = self._directory_list(self.bucket_path)
# filter the directory path
files = [file for file in directory_list if not file.endswith("/")]

if self.allow_file_suffix is None:
logger.info(f"All files from {self.bucket_path} will be downloaded.")
filtered_files = directory_list
filtered_files = files
else:
filtered_files = [
file
for file in directory_list
for file in files
if any(file.endswith(suffix) for suffix in self.allow_file_suffix)
]

Expand Down
4 changes: 1 addition & 3 deletions python/aibrix/aibrix/downloader/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ def _directory_list(self, path: str) -> List[str]:
Bucket=self.bucket_name, Delimiter="/", Prefix=path
)
contents = objects_out.get("Contents", [])
files = [content.get("Key") for content in contents]
# filter the directory path
return [file for file in files if not file.endswith("/")]
return [content.get("Key") for content in contents]

def _support_range_download(self) -> bool:
return True
Expand Down

0 comments on commit e3e58cd

Please sign in to comment.