mirror of
https://github.com/wiltodelta/remove-ai-watermarks.git
synced 2026-10-15 05:50:45 +02:00
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Local staging checks for the source-classifier Hub publisher."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
SCRIPTS = Path(__file__).resolve().parents[1] / "scripts"
|
|
sys.path.insert(0, str(SCRIPTS))
|
|
import publish_source_classify_hf as publish # noqa: E402
|
|
|
|
|
|
def test_hub_id_is_the_source_classify_repo() -> None:
|
|
assert publish.HUB_REPO == "wiltodelta/raiw-source-classify"
|
|
|
|
|
|
def test_stage_release_copies_only_public_artifacts(tmp_path: Path) -> None:
|
|
source = tmp_path / "source"
|
|
source.mkdir()
|
|
(source / "source-pipeline-mlp.npz").write_bytes(b"weights")
|
|
destination = tmp_path / "stage"
|
|
publish.stage_release(destination, source)
|
|
assert sorted(path.name for path in destination.iterdir()) == sorted(publish.PUBLIC_FILES)
|
|
|
|
|
|
def test_stage_release_requires_the_model(tmp_path: Path) -> None:
|
|
with pytest.raises(SystemExit, match=r"source-pipeline-mlp\.npz"):
|
|
publish.stage_release(tmp_path / "stage", tmp_path)
|
|
|
|
|
|
def test_card_sha_matches_the_metrics_manifest() -> None:
|
|
metrics = json.loads((publish.CARD_DIR / "metrics.json").read_text())
|
|
card = (publish.CARD_DIR / "README.md").read_text()
|
|
assert metrics["artifact_sha256"] in card
|