From 90092a3262cc7c439650035f0e831477608687f0 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Mon, 24 Aug 2026 08:31:19 +0900 Subject: [PATCH] fix: bootstrap repo-root sys.path in the two operator scripts missing it backfill_post_keymen.py and requeue_failed_post_content.py were the only scripts/ entries without the repo-root sys.path insert their siblings use, so `python scripts/.py` failed with ModuleNotFoundError: backend unless a caller manually exported PYTHONPATH=. first. Match the existing pattern instead of documenting the workaround. Found while re-running backfill_post_keymen.py to refresh a stale reason_no_live_client role row now that the local orchestrator/searxng services are reachable. --- scripts/backfill_post_keymen.py | 6 ++++++ scripts/requeue_failed_post_content.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/scripts/backfill_post_keymen.py b/scripts/backfill_post_keymen.py index 5a4618c48..59e2efd6c 100644 --- a/scripts/backfill_post_keymen.py +++ b/scripts/backfill_post_keymen.py @@ -11,10 +11,16 @@ import asyncio import json import os +import sys from collections import Counter +from pathlib import Path import asyncpg +REPOSITORY_ROOT = Path(__file__).resolve().parents[1] +if str(REPOSITORY_ROOT) not in sys.path: + sys.path.insert(0, str(REPOSITORY_ROOT)) + from backend.app.config import load_settings from backend.app.keyman_ingestion import ingest_post_keymen from backend.app.main import ( diff --git a/scripts/requeue_failed_post_content.py b/scripts/requeue_failed_post_content.py index 3e3e84da4..6747524f8 100644 --- a/scripts/requeue_failed_post_content.py +++ b/scripts/requeue_failed_post_content.py @@ -4,10 +4,16 @@ import argparse import asyncio +import sys +from pathlib import Path import asyncpg import redis.asyncio as redis +REPOSITORY_ROOT = Path(__file__).resolve().parents[1] +if str(REPOSITORY_ROOT) not in sys.path: + sys.path.insert(0, str(REPOSITORY_ROOT)) + from backend.app.config import load_settings from backend.app.post_content_queue import ( publish_post_content_event,