deploy: update habadashi_login
Browse files286 unmodified lines287288289290291292293294295296297298299300301302303304305286 unmodified lines# --- Inject Org Context Getter (for HF dataset namespace) ---try:from lib.hf_storage import set_org_context_getterfrom supabase_logger import get_user_contextdef get_org_for_storage():"""現在のリクエストユーザーの org_id/org_name を返す(HF dataset のネームスペース用)"""user_ctx = get_user_context()if user_ctx and isinstance(user_ctx, dict):org_id = user_ctx.get("org_id")org_name = user_ctx.get("org_name")return {"org_id": org_id, "org_name": org_name}return Noneset_org_context_getter(get_org_for_storage)print("[ORG_CONTEXT] Connected org_context getter to hf_storage")except ImportError as e:print(f"[ORG_CONTEXT] Could not inject org_context getter: {e}")# ---------------------------------------------------------286 unmodified lines287288289290291292293294295296297298299300301302303304305306307308309310311312286 unmodified lines# --- Inject Org Context Getter (for HF dataset namespace) ---try:from lib.hf_storage import set_org_context_getterdef get_org_for_storage():"""プロセスレベルの _user_profile_cache から org_id/org_name を返す。ContextVar (get_user_context) は FastAPI リクエストスレッドでのみ有効でGradio WebSocket キュースレッドでは伝播しないため、プロセス共有の_user_profile_cache(ログイン時にセットされる)を参照する。シングルユーザー運用前提; session_org_map が優先されるためマルチユーザー時もStep実行後は正しいorgが使われる。"""if _user_profile_cache:last_user = next(iter(_user_profile_cache.values()))org_id = last_user.get("org_id")org_name = last_user.get("org_name")if org_id or org_name:return {"org_id": org_id, "org_name": org_name}return Noneset_org_context_getter(get_org_for_storage)print("[ORG_CONTEXT] Connected org_context getter to hf_storage (cache-based)")except ImportError as e:print(f"[ORG_CONTEXT] Could not inject org_context getter: {e}")# ---------------------------------------------------------
app.py+15-8