跳到内容

llmcompressor.entrypoints.model_free.model_utils

walk_file_paths

walk_file_paths(
    root_dir: str, ignore: str | None = None
) -> list[str]

返回相对于根目录的所有文件路径

源代码在 llmcompressor/entrypoints/model_free/model_utils.py
def walk_file_paths(root_dir: str, ignore: str | None = None) -> list[str]:
    """
    Return all file paths relative to the root directory
    """

    all_files = []
    for dirpath, _, filenames in os.walk(root_dir):
        for filename in filenames:
            rel_path = os.path.relpath(os.path.join(dirpath, filename), root_dir)
            if not (ignore and rel_path.startswith(ignore)):
                all_files.append(rel_path)
    return all_files