文件
websafe-kb/scripts/lab/seed.py

30 行
1.1 KiB
Python

from __future__ import annotations
from pathlib import Path
from typing import Any, Dict, List
from lab.runners.dispatcher import run_seed as run_runner_seed
from lab.utils import write_json
def run_seed(profile: Dict[str, Any], advisory: Dict[str, Any], run_dir: Path, dry_run: bool = False) -> Dict[str, Any]:
if profile.get("runner_id") and not dry_run:
return run_runner_seed(profile, advisory, run_dir)
steps: List[Dict[str, Any]] = []
for action in profile.get("seed_actions", []):
kind = action.get("kind", "note")
if kind == "note":
steps.append({"kind": kind, "status": "recorded", "message": action.get("message", "")})
else:
steps.append(
{
"kind": kind,
"status": "planned" if dry_run else "skipped",
"message": "Seed action type not yet automated",
}
)
payload = {"steps": steps, "seeded": not any(item["status"] == "skipped" for item in steps)}
write_json(run_dir / "logs" / "seed.json", payload)
return payload