|
3 | 3 | # Contact: qubitium@modelcloud.ai, x.com/qubitium |
4 | 4 | # GPU=-1 |
5 | 5 | from importlib.metadata import PackageNotFoundError |
| 6 | +from pathlib import Path |
| 7 | +import re |
6 | 8 |
|
7 | 9 | import pytest |
8 | 10 |
|
9 | 11 | from gptqmodel.models import loader |
| 12 | +from gptqmodel.models.definitions.phi4 import Phi4MMGPTQ |
10 | 13 |
|
11 | 14 |
|
12 | 15 | class DummyModel: |
13 | 16 | pass |
14 | 17 |
|
15 | 18 |
|
| 19 | +def _deps_yaml_block_for(test_name: str) -> set[str]: |
| 20 | + deps_yaml = Path(__file__).resolve().parents[1] / ".github" / "scripts" / "deps.yaml" |
| 21 | + text = deps_yaml.read_text(encoding="utf-8") |
| 22 | + match = re.search(rf"(?ms)^ {re.escape(test_name)}:\n((?: - .*\n)+)", text) |
| 23 | + assert match is not None, f"Missing deps.yaml entry for {test_name}" |
| 24 | + return { |
| 25 | + line.strip()[2:].strip() |
| 26 | + for line in match.group(1).splitlines() |
| 27 | + if line.strip().startswith("- ") |
| 28 | + } |
| 29 | + |
| 30 | + |
16 | 31 | def test_check_versions_accepts_satisfied_requirements(monkeypatch): |
17 | 32 | def fake_version(pkg): |
18 | 33 | return {"transformers": "4.44.2"}[pkg] |
@@ -47,3 +62,11 @@ def fake_version(pkg): |
47 | 62 | monkeypatch.setattr(loader, "version", fake_version) |
48 | 63 |
|
49 | 64 | loader.check_versions(DummyModel, ["transformers<=4.38.2", "tokenizers<=0.15.2"]) |
| 65 | + |
| 66 | + |
| 67 | +def test_phi4_ci_deps_cover_required_packages(): |
| 68 | + pkgs = _deps_yaml_block_for("test_phi_4.py") |
| 69 | + |
| 70 | + assert "scipy" in pkgs |
| 71 | + for requirement in Phi4MMGPTQ.require_pkgs: |
| 72 | + assert requirement in pkgs |
0 commit comments