def _build_offline_siblings()

in api_inference_community/hub.py [0:0]


def _build_offline_siblings(repo: pathlib.Path) -> List[dict]:
    siblings = []
    prefix_pattern = re.compile(r"^" + re.escape(str(repo)) + r"(.*)$")
    for root, dirs, files in os.walk(repo):
        for file in files:
            filepath = os.path.join(root, file)
            size = os.stat(filepath).st_size
            m = prefix_pattern.match(filepath)
            if not m:
                msg = (
                    f"File {filepath} does not match expected pattern {prefix_pattern}"
                )
                logger.error(msg)
                raise Exception(msg)
            filepath = m.group(1)
            filepath = filepath.strip(os.sep)
            sibling = dict(rfilename=filepath, size=size)
            siblings.append(sibling)
    return siblings