|
|
@@ -0,0 +1,70 @@
|
|
|
+#!/usr/bin/env python
|
|
|
+"""健康评估批次包装:平台分钟数据导出 -> hdkg-run。
|
|
|
+
|
|
|
+需要在已安装 /opt/hdkg 的算法服务器运行;模型未安装时加 --no-llm。
|
|
|
+"""
|
|
|
+from __future__ import annotations
|
|
|
+
|
|
|
+import argparse
|
|
|
+import os
|
|
|
+import subprocess
|
|
|
+import sys
|
|
|
+from pathlib import Path
|
|
|
+
|
|
|
+HERE = Path(__file__).resolve().parent
|
|
|
+EXPORT = HERE / "health_assessment_export.py"
|
|
|
+
|
|
|
+
|
|
|
+def main() -> int:
|
|
|
+ ap = argparse.ArgumentParser()
|
|
|
+ ap.add_argument("--site", required=True)
|
|
|
+ ap.add_argument("--period", required=True)
|
|
|
+ ap.add_argument("--intake-root", default="/data/hdkg/intake")
|
|
|
+ ap.add_argument("--out-root", default="/data/hdkg/out")
|
|
|
+ ap.add_argument("--history-start", default="2023-01-01")
|
|
|
+ ap.add_argument("--hdkg-app", default="/opt/hdkg/app")
|
|
|
+ ap.add_argument("--hdkg-python", default="/opt/hdkg/runtime/bin/python")
|
|
|
+ ap.add_argument("--no-llm", action="store_true")
|
|
|
+ ap.add_argument("--reuse-thermcore", action="store_true")
|
|
|
+ args = ap.parse_args()
|
|
|
+
|
|
|
+ py = args.hdkg_python
|
|
|
+ if not Path(py).is_file():
|
|
|
+ py = sys.executable
|
|
|
+
|
|
|
+ export_cmd = [
|
|
|
+ py,
|
|
|
+ str(EXPORT),
|
|
|
+ "--site", args.site,
|
|
|
+ "--period", args.period,
|
|
|
+ "--out-root", args.intake_root,
|
|
|
+ "--history-start", args.history_start,
|
|
|
+ ]
|
|
|
+ print("[1/2] export:", " ".join(export_cmd), flush=True)
|
|
|
+ subprocess.run(export_cmd, check=True, env=os.environ.copy())
|
|
|
+
|
|
|
+ run_cmd = [
|
|
|
+ py,
|
|
|
+ str(Path(args.hdkg_app) / "scripts/hdkg_run.py"),
|
|
|
+ "--site", args.site,
|
|
|
+ "--period", args.period,
|
|
|
+ "--intake-root", args.intake_root,
|
|
|
+ "--out-root", args.out_root,
|
|
|
+ "--model-conf", "",
|
|
|
+ ]
|
|
|
+ if args.no_llm:
|
|
|
+ run_cmd.append("--no-llm")
|
|
|
+ if args.reuse_thermcore:
|
|
|
+ run_cmd.append("--reuse-thermcore")
|
|
|
+ print("[2/2] batch:", " ".join(run_cmd), flush=True)
|
|
|
+ env = os.environ.copy()
|
|
|
+ env["HDKG_HOME"] = args.hdkg_app
|
|
|
+ env["PYTHONDONTWRITEBYTECODE"] = "1"
|
|
|
+ env["PYTHONPATH"] = os.pathsep.join(
|
|
|
+ [args.hdkg_app, str(Path(args.hdkg_app) / "src"), env.get("PYTHONPATH", "")]
|
|
|
+ ).rstrip(os.pathsep)
|
|
|
+ return subprocess.run(run_cmd, env=env).returncode
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ raise SystemExit(main())
|