fix(K): asset library catalog refresh — fix task binding and model imports
- fix(tasks): @shared_task → @celery_app.task so task uses configured redis://redis broker (@shared_task without explicit app bound to default app → localhost:6379 → Connection refused) - fix(tasks): import app.models before DB access so SQLAlchemy can resolve Material.creator → User relationship (was: InvalidRequestError: 'User' failed to locate a name) Verified: catalog refresh now finds and stores 35 materials from uploaded .blend file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import subprocess
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
from celery import shared_task
|
||||
from app.tasks.celery_app import celery_app
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
|
||||
CATALOG_SCRIPT = Path(os.environ.get("RENDER_SCRIPTS_DIR", "/render-scripts")) / "catalog_assets.py"
|
||||
|
||||
|
||||
@shared_task(
|
||||
@celery_app.task(
|
||||
name="app.domains.materials.tasks.refresh_asset_library_catalog",
|
||||
queue="thumbnail_rendering",
|
||||
bind=True,
|
||||
@@ -30,6 +30,7 @@ def refresh_asset_library_catalog(self, asset_library_id: str) -> None:
|
||||
"""
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session
|
||||
import app.models # noqa: F401 — registers all SQLAlchemy models so relationships resolve
|
||||
from app.domains.materials.models import AssetLibrary
|
||||
from app.config import settings
|
||||
|
||||
|
||||
Reference in New Issue
Block a user