fix: 清除硬编码API Key与机器特定路径,改用环境变量+混合式路径解析

This commit is contained in:
hangshuo652
2026-08-25 21:53:18 +08:00
parent b3895a905e
commit 8e81f960af
32 changed files with 200 additions and 76 deletions
+14 -4
View File
@@ -1,7 +1,8 @@
"""E2E Tests for COBOL->Java Verification Platform
Run: cd D:/cobol-java/v3-gstack-code-gen && python -m pytest tests/e2e/ -v
Requires: web server on http://127.0.0.1:8000, WSL available
Run: cd <project-root> && python -m pytest tests/e2e/ -v
Requires: web server on http://127.0.0.1:8000, WSL available,
DEEPSEEK_API_KEY set in the environment.
"""
import json, os, sys, time, uuid, shutil
from datetime import datetime
@@ -50,10 +51,19 @@ def create_task(copybook: str, cobol: str, java_dir: str, mapping: str, runner="
return tid
def _wsl_path(p: Path) -> str:
"""Convert a Windows path to its WSL /mnt/<drive> equivalent."""
s = str(p).replace("\\", "/")
if len(s) > 1 and s[1] == ":":
return f"/mnt/{s[0].lower()}{s[2:]}"
return s
def run_worker_for_task(tid: str):
api_key = os.environ.get("DEEPSEEK_API_KEY", "")
script = (
"cd /mnt/d/cobol-java/v3-gstack-code-gen && "
"export LLM_API_KEY=sk-ca4961087c7f4aefa8ed0fc6f3d02329 && "
f"cd {_wsl_path(PROJECT)} && "
f"export LLM_API_KEY='{api_key}' && "
"export LLM_API_BASE=https://api.deepseek.com/v1 && "
"export LLM_MODEL=deepseek-chat && "
f"python3 -c \"exec(open('write_result.py').read().replace('ec17bf32','{tid}'))\""