Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
echarlaix committed Feb 12, 2025
1 parent d73c6a0 commit 26c16fc
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions optimum/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,13 @@ def find_files_matching_pattern(
token = use_auth_token

model_path = str(model_name_or_path) if isinstance(model_name_or_path, Path) else model_name_or_path
pattern = re.compile(f"{subfolder}/{pattern}" if subfolder != "" else pattern)
pattern = re.compile(subfolder + pattern)

if os.path.isdir(model_path):
files = Path(model_path).glob(glob_pattern)
files = [p for p in files if re.search(pattern, str(p))]


if not files:
raise ValueError(f"model_path {model_path}, glob_pattern {glob_pattern}, Path(model_path).glob(glob_pattern) {[str(p) for p in Path(model_path).glob(glob_pattern) ]}, pattern {pattern}, finale {[p for p in Path(model_path).glob(glob_pattern) if re.search(pattern, str(p))]}")
else:
repo_files = huggingface_hub.list_repo_files(model_path, revision=revision, token=token)
files = [Path(p) for p in repo_files if re.match(pattern, p)]


return files

0 comments on commit 26c16fc

Please sign in to comment.