Skip to content

Commit

Permalink
fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
echarlaix committed Feb 12, 2025
1 parent 23d5910 commit cfb3aa3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions optimum/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,12 @@ 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)
if os.path.isdir(model_path):
pattern = re.compile(f"{subfolder}{os.sep}{pattern}" if subfolder != "" else pattern)
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) { Path(model_path).glob(glob_pattern)}, pattern {pattern}")
else:
pattern = re.compile(f"{subfolder}/{pattern}" if subfolder != "" else pattern)
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)]

Expand Down

0 comments on commit cfb3aa3

Please sign in to comment.