更新: 421 个文件 - 2026-03-17 18:30:02
这个提交包含在:
@@ -10,6 +10,7 @@ from lab.utils import write_json
|
||||
|
||||
def collect(profile: Dict[str, Any], run_dir: Path, timeout: float = 8.0) -> Dict[str, Any]:
|
||||
observations: List[Dict[str, Any]] = []
|
||||
steps: List[Dict[str, Any]] = []
|
||||
for url in profile.get("baseline_urls", []):
|
||||
try:
|
||||
response = requests.get(url, timeout=timeout, verify=False)
|
||||
@@ -23,6 +24,41 @@ def collect(profile: Dict[str, Any], run_dir: Path, timeout: float = 8.0) -> Dic
|
||||
)
|
||||
except Exception as exc:
|
||||
observations.append({"url": url, "error": str(exc)})
|
||||
payload = {"observations": observations}
|
||||
base_url = str((profile.get("baseline_urls") or [""])[0]).rstrip("/")
|
||||
for action in profile.get("baseline_actions", []) or []:
|
||||
kind = action.get("kind", "note")
|
||||
if kind == "note":
|
||||
steps.append({"kind": kind, "status": "recorded", "message": action.get("message", "")})
|
||||
continue
|
||||
try:
|
||||
if kind == "http-get":
|
||||
path = action.get("path", "/")
|
||||
response = requests.get(f"{base_url}{path}", timeout=timeout)
|
||||
steps.append(
|
||||
{
|
||||
"kind": kind,
|
||||
"status": "completed",
|
||||
"path": path,
|
||||
"status_code": response.status_code,
|
||||
"body_excerpt": response.text[:200],
|
||||
}
|
||||
)
|
||||
elif kind == "http-post":
|
||||
path = action.get("path", "/")
|
||||
response = requests.post(f"{base_url}{path}", json=action.get("json", {}), timeout=timeout)
|
||||
steps.append(
|
||||
{
|
||||
"kind": kind,
|
||||
"status": "completed",
|
||||
"path": path,
|
||||
"status_code": response.status_code,
|
||||
"body_excerpt": response.text[:200],
|
||||
}
|
||||
)
|
||||
else:
|
||||
steps.append({"kind": kind, "status": "skipped", "message": "baseline action type not automated"})
|
||||
except Exception as exc:
|
||||
steps.append({"kind": kind, "status": "failed", "message": str(exc)})
|
||||
payload = {"observations": observations, "steps": steps}
|
||||
write_json(run_dir / "logs" / "baseline.json", payload)
|
||||
return payload
|
||||
|
||||
在新工单中引用
屏蔽一个用户