test: end-to-end user journey in CI; fix ALS vectors for small libraries
- newApp (extracted from main) is the exact production wiring; the `ci / db` job now also runs it on PostgreSQL, Redis and Meilisearch and walks the main user flows over HTTP: first admin sign-in and credential change, local source and scan, search, album / artist / top tracks, signed stream, events and history, likes, fallback wave, playback state, upload queue up to review. - ALS on a small library produced fewer than 64 factors and the insert into vector(64) failed; vectors are now zero-padded to the column size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f5c276092f
commit
2285107d04
5 files changed
+382
-11
No files matched your search
@@ -108,9 +108,20 @@ def should_activate(new: dict[str, Any], current: dict[str, Any] | None) -> bool
|
||||
return float(new_ndcg) >= float(cur_ndcg) * (1 - MAX_REGRESSION)
|
||||
|
||||
|
||||
# Размерность колонок track_embeddings.cf / user_profiles_rec.taste_cf (vector(64)).
|
||||
CF_DIM = 64
|
||||
|
||||
|
||||
def pad(v: np.ndarray, dim: int = CF_DIM) -> np.ndarray:
|
||||
"""Маленькая библиотека даёт меньше факторов, чем колонка: добиваем нулями (косинус не меняется)."""
|
||||
if v.shape[1] >= dim:
|
||||
return v[:, :dim]
|
||||
return np.pad(v, ((0, 0), (0, dim - v.shape[1])))
|
||||
|
||||
|
||||
def save_als(conn: psycopg.Connection[Any], model: ALSModel, version: str, metrics: dict[str, Any]) -> None:
|
||||
items = normalize(model.item_factors)
|
||||
users = normalize(model.user_factors)
|
||||
items = pad(normalize(model.item_factors))
|
||||
users = pad(normalize(model.user_factors))
|
||||
with conn.transaction():
|
||||
with conn.cursor() as cur:
|
||||
cur.executemany(
|
||||
|
||||
@@ -108,3 +108,11 @@ def test_engine_uses_cf_source() -> None:
|
||||
assert len(picks) == 5
|
||||
assert sum(int(p.id[1:]) < 20 for p in picks) >= 4 # почти всё — из «своей» половины по ALS
|
||||
assert model_version(index, profile).endswith("+cf")
|
||||
|
||||
|
||||
def test_cf_vectors_are_padded_to_column_size() -> None:
|
||||
from pipu_rec.train.pipeline import CF_DIM, pad
|
||||
|
||||
v = np.ones((3, 5), dtype=np.float32)
|
||||
assert pad(v).shape == (3, CF_DIM)
|
||||
assert pad(np.ones((2, 80), dtype=np.float32)).shape == (2, CF_DIM)
|
||||
Reference in new issue
Block a user