Files
boc/projects/landvex/20-automation/batch_runner.py
T
Bernt 6de2455917 v1.2.0: Add Global Markets footer, translated to 9 languages
- Added GLOBAL_MARKETS_TITLE to all translation files
- Updated footer with 12 markets (4 active + 8 upcoming)
- Translated market section to: zh-cn, zh-tw, ja, ko, th, vi, id, ms, hi
- Built and deployed to production
- CloudFront invalidation: I3RTMXVFDJXWLG3SYX208OP1CC
2026-07-08 19:56:03 +00:00

72 lines
2.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
Landvex Batch Runner — kör massproduktion av artiklar
"""
import subprocess
import concurrent.futures
import time
import sys
from datetime import datetime, timezone
def log(msg):
ts = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
print(f"[{ts}] {msg}", flush=True)
def kor_batch(batch_id, cap=10):
"""Kör en batch med kor_agent_kimi.py"""
agent_id = f"batch-{batch_id:04d}"
cmd = f"cd /home/bernt/.openclaw/workspace/projects/landvex/20-automation && python3 kor_agent_kimi.py --agent-id {agent_id} --cap {cap}"
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
return result.returncode == 0
def main():
log("=== LANDVEX GRUNDUPPBYGGNAD STARTAR ===")
log("Mål: 2000 artiklar på 2 timmar")
log("Konfiguration: 10 parallella batcher × 100 artiklar")
start_time = time.time()
total_batches = 20 # 20 batcher × 100 artiklar = 2000
batch_size = 100
max_workers = 10
completed = 0
failed = 0
for round_num in range(2): # 2 rundor × 10 batcher
log(f"Runda {round_num + 1}/2 startar...")
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
futures = {}
for i in range(max_workers):
batch_id = round_num * max_workers + i
future = executor.submit(kor_batch, batch_id, batch_size)
futures[future] = batch_id
for future in concurrent.futures.as_completed(futures):
batch_id = futures[future]
try:
success = future.result()
if success:
completed += 1
log(f"✓ Batch {batch_id} klar")
else:
failed += 1
log(f"✗ Batch {batch_id} misslyckades")
except Exception as e:
failed += 1
log(f"✗ Batch {batch_id} fel: {e}")
elapsed = time.time() - start_time
rate = (completed * batch_size) / (elapsed / 3600) if elapsed > 0 else 0
log(f"Runda {round_num + 1} klar. Tid: {elapsed/60:.1f} min. Takt: {rate:.0f} art/h")
total_time = time.time() - start_time
log("=== GRUNDUPPBYGGNAD AVSLUTAD ===")
log(f"Totalt: {completed * batch_size} artiklar på {total_time/60:.1f} minuter")
log(f"Genomsnittlig takt: {completed * batch_size / (total_time/3600):.0f} artiklar/timme")
log(f"Misslyckade batcher: {failed}")
if __name__ == "__main__":
main()