Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data filter in tar extract #2084

Merged
merged 6 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/anomalib/data/utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ def safe_extract(tar_file: TarFile, root: Path, members: list[TarInfo]) -> None:

"""
for member in members:
tar_file.extract(member, root)
# check if the file already exists
if not (root / member.name).exists():
tar_file.extract(member, root, filter="data")


def generate_hash(file_path: str | Path, algorithm: str = "sha256") -> str:
Expand Down Expand Up @@ -288,7 +290,7 @@ def extract(file_name: Path, root: Path) -> None:
root (Path): Root directory where the dataset will be stored.

"""
logger.info("Extracting dataset into root folder.")
logger.info(f"Extracting dataset into {root} folder.")

# Safely extract zip files
if file_name.suffix == ".zip":
Expand Down
Loading