sheet upload fix
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Dict, List
|
||||
|
||||
import pandas as pd
|
||||
|
||||
@@ -50,7 +50,6 @@ def product_dashboard(brand: str, image_id: str) -> Dict:
|
||||
|
||||
popularity = None
|
||||
if engagement_row:
|
||||
from app.intelligence import features as F
|
||||
feat_row = pd.DataFrame([{
|
||||
"views_norm": min(engagement_row["views"] / 10, 100),
|
||||
"wishlist_norm": min(engagement_row["wishlist_count"] / 2, 100),
|
||||
|
||||
@@ -10,7 +10,7 @@ ranked by health_score improvement rather than by distance.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from app.services import nutrition_db
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ treating NULL as "zero".
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
|
||||
@@ -46,6 +46,11 @@ from typing import Any, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.infrastructure.settings import (
|
||||
VALIDATION_REJECT_THRESHOLD,
|
||||
VALIDATION_REVIEW_THRESHOLD,
|
||||
)
|
||||
|
||||
from app.services.title_validator import find_category_conflicts
|
||||
from app.services import price_estimator
|
||||
from app.services import category_units as cu
|
||||
@@ -119,10 +124,20 @@ class ValidationIssue(BaseModel):
|
||||
|
||||
class ValidationConfig(BaseModel):
|
||||
"""Tunable thresholds - see docs/VALIDATION_PIPELINE.md for defaults
|
||||
and how to change them via settings.py without editing this file."""
|
||||
and how to change them via settings.py without editing this file.
|
||||
|
||||
reject_below: float = 0.35
|
||||
review_below: float = 0.70
|
||||
The two settings really are read now. They were declared in settings.py
|
||||
with these same numbers as their defaults, and nothing ever imported them:
|
||||
the values below were hardcoded copies, so setting VALIDATION_REJECT_THRESHOLD
|
||||
in the environment did exactly nothing while appearing to work.
|
||||
|
||||
`default_factory` rather than a plain default so the setting is read when a
|
||||
config is constructed, not once at import - which is what lets a test move
|
||||
the threshold without reloading the module.
|
||||
"""
|
||||
|
||||
reject_below: float = Field(default_factory=lambda: VALIDATION_REJECT_THRESHOLD)
|
||||
review_below: float = Field(default_factory=lambda: VALIDATION_REVIEW_THRESHOLD)
|
||||
|
||||
|
||||
class ValidationReport(BaseModel):
|
||||
|
||||
@@ -6,13 +6,11 @@ functions need, then persists/reads the result cache via `store_db.py`.
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Dict, List
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from app.intelligence import recommendation_engine as RE
|
||||
from app.intelligence.popularity_model import popularity_scorer
|
||||
from app.services import store_db
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -34,7 +34,7 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from datetime import date, datetime
|
||||
from datetime import date
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
import pandas as pd
|
||||
|
||||
@@ -39,7 +39,7 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
import logging
|
||||
from typing import Iterable, Optional
|
||||
from typing import Optional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List, Optional, Dict, Any
|
||||
from typing import List, Optional, Dict, Any, Tuple
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
@@ -10,7 +9,7 @@ import time
|
||||
import psycopg
|
||||
|
||||
from app.infrastructure.settings import (
|
||||
DATABASE_URL, USE_PGVECTOR, DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD,
|
||||
USE_PGVECTOR, DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD,
|
||||
DB_CONNECT_TIMEOUT_SECONDS,
|
||||
)
|
||||
from app.services.brand_registry import BRAND_ALIASES, resolve_parent_brand
|
||||
@@ -161,8 +160,8 @@ def _ensure_columns(cur, table_name: str) -> None:
|
||||
"embedding": "vector(384)",
|
||||
}
|
||||
cur.execute(
|
||||
f"SELECT column_name, is_nullable, column_default FROM information_schema.columns "
|
||||
f"WHERE table_schema = 'public' AND table_name = %s",
|
||||
"SELECT column_name, is_nullable, column_default FROM information_schema.columns "
|
||||
"WHERE table_schema = 'public' AND table_name = %s",
|
||||
(table_name,),
|
||||
)
|
||||
col_info = cur.fetchall()
|
||||
|
||||
Reference in New Issue
Block a user