[2ff88f42] feat(GTM-Engine): Add final test and trigger scripts

This commit is contained in:
2026-02-20 16:41:56 +00:00
parent 0143dba33e
commit 250ff4d97f
5 changed files with 135 additions and 10 deletions

49
trigger_analysis.py Normal file
View File

@@ -0,0 +1,49 @@
import requests
import os
import time
# --- Configuration ---
def load_env_manual(path):
if not os.path.exists(path):
print(f"⚠️ Warning: .env file not found at {path}")
return
with open(path) as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
key, val = line.split('=', 1)
os.environ.setdefault(key.strip(), val.strip())
load_env_manual('/app/.env')
API_USER = os.getenv("API_USER")
API_PASS = os.getenv("API_PASSWORD")
CE_URL = "http://127.0.0.1:8000"
ANALYZE_ENDPOINT = f"{CE_URL}/api/enrich/analyze"
COMPANY_ID_TO_ANALYZE = 1 # Therme Erding
def trigger_analysis():
print("="*60)
print(f"🚀 Triggering REAL analysis for Company ID: {COMPANY_ID_TO_ANALYZE}")
print("="*60)
payload = {"company_id": COMPANY_ID_TO_ANALYZE}
try:
response = requests.post(ANALYZE_ENDPOINT, json=payload, auth=(API_USER, API_PASS), timeout=10)
if response.status_code == 200 and response.json().get("status") == "queued":
print(" ✅ SUCCESS: Analysis task has been queued on the server.")
print(" The result will be available in the database and UI shortly.")
return True
else:
print(f" ❌ FAILURE: Server responded with status {response.status_code}")
print(f" Response: {response.text}")
return False
except requests.exceptions.RequestException as e:
print(f" ❌ FATAL: Could not connect to the server: {e}")
return False
if __name__ == "__main__":
trigger_analysis()