Spaces:
Running
Running
Download docqa/tests/conftest.py from validops-east-3/instance-2: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/validops-east-3/instance-2/resolve/main/docqa/tests/conftest.py
- Command line
-
hf download hf://spaces/validops-east-3/instance-2/docqa/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/validops-east-3/instance-2/resolve/main/docqa/tests/conftest.py
1.16 kB
| """Shared pytest fixtures.""" | |
| from __future__ import annotations | |
| import json | |
| import sys | |
| from pathlib import Path | |
| import pytest | |
| ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(ROOT / "src")) | |
| CORPUS = ROOT / "corpus" | |
| def corpus_dir() -> Path: | |
| if not (CORPUS / "ground_truth.json").exists(): | |
| pytest.skip("corpus not generated; run: python tests/corpus.py corpus 12") | |
| return CORPUS | |
| def ground_truth(corpus_dir: Path) -> list[dict]: | |
| return json.loads((corpus_dir / "ground_truth.json").read_text()) | |
| def settings(): | |
| from docxextract.config import Settings | |
| return Settings(torch_threads=4, parse_cache_size=32) | |
| def sample_pdf(ground_truth) -> bytes: | |
| return Path(ground_truth[0]["path"]).read_bytes() | |
| def engine(settings): | |
| """Session-scoped warmed engine. Loading a model per test is too slow.""" | |
| from docxextract.engine import Engine, reset_engine | |
| eng = Engine(settings) | |
| eng.warmup() | |
| yield eng | |
| reset_engine() | |