Skip to content

Commit f4423c1

Browse files
committed
walk path with ignore
Signed-off-by: Kyle Sayers <[email protected]>
1 parent b501462 commit f4423c1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/llmcompressor/entrypoints/weights_ptq/model_utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ def get_checkpoint_files(model_stub: str | os.PathLike) -> list[str]:
2222
# In the future, this function can accept and pass download kwargs to cached_file
2323

2424
if os.path.exists(model_stub):
25-
file_paths = walk_file_paths(model_stub)
25+
file_paths = walk_file_paths(model_stub, ignore=".cache")
2626
else:
2727
file_paths = list_repo_files(model_stub)
2828

2929
return [(file_path, cached_file(model_stub, file_path)) for file_path in file_paths]
3030

3131

32-
def walk_file_paths(root_dir: str) -> list[str]:
32+
def walk_file_paths(root_dir: str, ignore: str | None = None) -> list[str]:
3333
all_files = []
34-
for dirpath, _dirnames, filenames in os.walk(root_dir):
34+
for dirpath, _, filenames in os.walk(root_dir):
3535
for filename in filenames:
36-
full_path = os.path.join(dirpath, filename)
37-
all_files.append(full_path)
36+
rel_path = os.path.relpath(os.path.join(dirpath, filename), root_dir)
37+
if not (ignore and rel_path.startswith(ignore)):
38+
all_files.append(rel_path)
3839
return all_files
3940

4041

0 commit comments

Comments
 (0)