# SPDX-License-Identifier: Apache-2.0 """Where host tests find checkpoint files (optional; tests that need them skip otherwise): ``PADDLEOCR_TEST_WEIGHTS`` (a checkpoint dir) or the profile's pinned snapshot in the Hugging Face cache (no download).""" import os from typing import Optional from ..config import WEIGHTS def repo_file(name: str, profile: str = "1.6") -> Optional[str]: d = os.environ.get("PADDLEOCR_TEST_WEIGHTS") if d: p = os.path.join(d, name) return p if os.path.isfile(p) else None try: from huggingface_hub import try_to_load_from_cache repo, rev = WEIGHTS[profile] p = try_to_load_from_cache(repo, name, revision=rev) return p if isinstance(p, str) and os.path.isfile(p) else None except Exception: # noqa: BLE001 -- no huggingface_hub / no cache: the test skips return None