All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 4s
- Updated the .env loading process to first check for an explicit path, improving reliability in different working directories. - Added logging for successful .env loading and fallback mechanisms. - Enhanced EdgeDTO creation with robust error handling, including fallbacks for unsupported provenance values and logging of errors for better traceability.
115 lines
3.4 KiB
Python
115 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Script zur Verifikation des .env-Ladens in Prod.
|
|
Prüft, ob die .env-Datei korrekt geladen wird und welche Werte tatsächlich verwendet werden.
|
|
"""
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Stelle sicher, dass der Projekt-Pfad im Python-Path ist
|
|
project_root = Path(__file__).parent.parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
print("=" * 80)
|
|
print("🔍 .env-Lade-Verifikation")
|
|
print("=" * 80)
|
|
|
|
# 1. Prüfe, ob .env-Datei existiert
|
|
env_files = [
|
|
project_root / ".env",
|
|
project_root / "prod.env",
|
|
project_root / "config" / "prod.env",
|
|
Path.cwd() / ".env",
|
|
Path.cwd() / "prod.env",
|
|
]
|
|
|
|
print("\n1. Suche nach .env-Dateien:")
|
|
found_env = None
|
|
for env_file in env_files:
|
|
if env_file.exists():
|
|
print(f" ✅ Gefunden: {env_file}")
|
|
if found_env is None:
|
|
found_env = env_file
|
|
else:
|
|
print(f" ❌ Nicht gefunden: {env_file}")
|
|
|
|
if not found_env:
|
|
print("\n ⚠️ WARNUNG: Keine .env-Datei gefunden!")
|
|
print(" -> load_dotenv() wird Standard-Werte verwenden")
|
|
|
|
# 2. Lade .env manuell
|
|
print("\n2. Lade .env-Datei:")
|
|
from dotenv import load_dotenv
|
|
|
|
if found_env:
|
|
result = load_dotenv(found_env, override=True)
|
|
print(f" ✅ load_dotenv('{found_env}') = {result}")
|
|
else:
|
|
result = load_dotenv(override=True)
|
|
print(f" ⚠️ load_dotenv() ohne expliziten Pfad = {result}")
|
|
print(" -> Sucht automatisch nach .env im aktuellen Verzeichnis")
|
|
|
|
# 3. Prüfe kritische Umgebungsvariablen
|
|
print("\n3. Kritische Umgebungsvariablen:")
|
|
critical_vars = [
|
|
"COLLECTION_PREFIX",
|
|
"MINDNET_PREFIX",
|
|
"DEBUG",
|
|
"VECTOR_DIM",
|
|
"MINDNET_EMBEDDING_MODEL",
|
|
"QDRANT_URL",
|
|
]
|
|
|
|
for var in critical_vars:
|
|
value = os.getenv(var, "NICHT GESETZT")
|
|
source = "Umgebung" if var in os.environ else "Default/Code"
|
|
print(f" {var:30} = {value:40} ({source})")
|
|
|
|
# 4. Prüfe, welche .env-Datei tatsächlich geladen wurde
|
|
print("\n4. Verifikation der geladenen Werte:")
|
|
print(f" Arbeitsverzeichnis: {Path.cwd()}")
|
|
print(f" Projekt-Root: {project_root}")
|
|
print(f" Python-Pfad[0]: {sys.path[0] if sys.path else 'N/A'}")
|
|
|
|
# 5. Test: Importiere Settings
|
|
print("\n5. Test: Importiere Settings aus app.config:")
|
|
try:
|
|
from app.config import get_settings
|
|
settings = get_settings()
|
|
print(f" ✅ Settings erfolgreich geladen")
|
|
print(f" -> COLLECTION_PREFIX: {settings.COLLECTION_PREFIX}")
|
|
print(f" -> VECTOR_SIZE: {settings.VECTOR_SIZE}")
|
|
print(f" -> EMBEDDING_MODEL: {settings.EMBEDDING_MODEL}")
|
|
except Exception as e:
|
|
print(f" ❌ Fehler beim Laden der Settings: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
# 6. Test: Prüfe EdgeDTO
|
|
print("\n6. Test: Prüfe EdgeDTO-Import:")
|
|
try:
|
|
from app.models.dto import EdgeDTO
|
|
import inspect
|
|
|
|
source = inspect.getsource(EdgeDTO)
|
|
if "explicit:callout" in source:
|
|
print(" ✅ EdgeDTO unterstützt 'explicit:callout'")
|
|
print(f" -> Modul-Pfad: {EdgeDTO.__module__}")
|
|
print(f" -> Datei: {inspect.getfile(EdgeDTO)}")
|
|
else:
|
|
print(" ❌ EdgeDTO unterstützt NICHT 'explicit:callout'")
|
|
|
|
# Test-Erstellung
|
|
test_edge = EdgeDTO(
|
|
id="test", kind="test", source="test", target="test",
|
|
weight=1.0, provenance="explicit:callout"
|
|
)
|
|
print(" ✅ EdgeDTO mit 'explicit:callout' erfolgreich erstellt!")
|
|
except Exception as e:
|
|
print(f" ❌ Fehler: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
print("\n" + "=" * 80)
|