bc6d43d3f2
Hygiene follow-up to the Camie retirement (#1189) — these were left inert to bound that change; nothing reads them now. Migration 0068 drops: - ml_settings: tagger_store_floor, tagger_model_version, suggestion_threshold_ character/general (already dead pre-retirement — scoring uses per-head thresholds), video_min_tag_frames (only the deleted video-prediction aggregator used it). - image_record: tagger_model_version (no writer), centroid_scores (dead JSON cache, no reader). Also: ml_admin _EDITABLE/GET/_validate pruned (dropped the store-floor invariant + video_min_tag_frames check); MLThresholdSliders trimmed to a video-embedding card (interval + max frames only); importer no longer resets the dropped cols; download_models drops the Camie fetch; stale CASCADE comments in cleanup_service no longer name the removed tables. Tests updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
105 lines
3.6 KiB
Python
105 lines
3.6 KiB
Python
import pytest
|
|
|
|
from backend.app.celery_app import celery
|
|
from backend.app.models import TagKind
|
|
from backend.app.services.tag_service import TagService
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def eager():
|
|
celery.conf.task_always_eager = True
|
|
yield
|
|
celery.conf.task_always_eager = False
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_and_patch_settings(client):
|
|
resp = await client.get("/api/ml/settings")
|
|
assert resp.status_code == 200
|
|
body = await resp.get_json()
|
|
assert body["head_min_positives"] == 8
|
|
# Retired tagger/suggestion-threshold columns are gone from the payload
|
|
# (Camie retirement #1189/#1199).
|
|
assert "suggestion_threshold_general" not in body
|
|
assert "tagger_store_floor" not in body
|
|
assert "tagger_model_version" not in body
|
|
|
|
resp = await client.patch(
|
|
"/api/ml/settings", json={"head_min_positives": 12}
|
|
)
|
|
assert resp.status_code == 200
|
|
assert (await resp.get_json())["head_min_positives"] == 12
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_embedder_model_settable_and_empty_rejected(client):
|
|
# #1190: the embedder model name + version are operator-settable (a swap),
|
|
# and neither may be blanked.
|
|
body = await (await client.get("/api/ml/settings")).get_json()
|
|
assert body["embedder_model_name"] == "google/siglip-so400m-patch14-384"
|
|
|
|
ok = await client.patch("/api/ml/settings", json={
|
|
"embedder_model_name": "google/siglip2-so400m-patch16-512",
|
|
"embedder_model_version": "siglip2-so400m-patch16-512",
|
|
})
|
|
assert ok.status_code == 200
|
|
out = await ok.get_json()
|
|
assert out["embedder_model_name"] == "google/siglip2-so400m-patch16-512"
|
|
assert out["embedder_model_version"] == "siglip2-so400m-patch16-512"
|
|
|
|
bad = await client.patch("/api/ml/settings", json={"embedder_model_name": " "})
|
|
assert bad.status_code == 400
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_video_settings_default_and_patch(client):
|
|
"""#747: video frame-sampling knobs are exposed + patchable."""
|
|
body = await (await client.get("/api/ml/settings")).get_json()
|
|
assert body["video_frame_interval_seconds"] == pytest.approx(4.0)
|
|
assert body["video_max_frames"] == 64
|
|
|
|
resp = await client.patch(
|
|
"/api/ml/settings",
|
|
json={"video_frame_interval_seconds": 5, "video_max_frames": 40},
|
|
)
|
|
assert resp.status_code == 200
|
|
out = await resp.get_json()
|
|
assert out["video_frame_interval_seconds"] == pytest.approx(5.0)
|
|
assert out["video_max_frames"] == 40
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_video_max_frames_below_one_rejected(client):
|
|
resp = await client.patch(
|
|
"/api/ml/settings", json={"video_max_frames": 0},
|
|
)
|
|
assert resp.status_code == 400
|
|
assert "video_max_frames" in (await resp.get_json())["error"]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_backfill_trigger(client):
|
|
r1 = await client.post("/api/ml/backfill")
|
|
assert r1.status_code == 202
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_rename_tag(client, db):
|
|
tag = await TagService(db).find_or_create("oldname", TagKind.character)
|
|
await db.commit()
|
|
resp = await client.patch(f"/api/tags/{tag.id}", json={"name": "New Name"})
|
|
assert resp.status_code == 200
|
|
assert (await resp.get_json())["name"] == "New Name"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_rename_collision_409(client, db):
|
|
svc = TagService(db)
|
|
await svc.find_or_create("Taken", TagKind.character)
|
|
other = await svc.find_or_create("Mover", TagKind.character)
|
|
await db.commit()
|
|
resp = await client.patch(f"/api/tags/{other.id}", json={"name": "Taken"})
|
|
assert resp.status_code == 409
|