55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
"""
|
|
run_full_sync_pipeline_jsonl_sm.py
|
|
|
|
独立执行:基于 sync_state_machine 的 JSONL -> JSONL 全量同步脚本。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
import sync_state_machine.domain # noqa: F401, E402
|
|
from sync_state_machine.logging import configure_app_logging, get_logger # noqa: E402
|
|
from sync_state_machine.pipeline import ( # noqa: E402
|
|
build_config,
|
|
run_pipeline_from_config,
|
|
)
|
|
from sync_state_machine.config import load_named_preset_overrides # noqa: E402
|
|
|
|
|
|
PRESET_NAME = "jsonl_sm"
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
async def main() -> int:
|
|
try:
|
|
overrides, preset_file, used_default = load_named_preset_overrides(PROJECT_ROOT, PRESET_NAME)
|
|
source_label = "default" if used_default else "custom"
|
|
|
|
config = build_config(project_root=PROJECT_ROOT, overrides=overrides)
|
|
configure_app_logging(config.logging, replace_handlers=True)
|
|
logger.info("🧩 Loaded preset (%s): %s", source_label, preset_file)
|
|
await run_pipeline_from_config(
|
|
config,
|
|
title="sync_state_machine JSONL -> JSONL pipeline",
|
|
print_summary=True,
|
|
)
|
|
return 0
|
|
|
|
except KeyboardInterrupt:
|
|
logger.warning("⚠️ Interrupted by user")
|
|
return 130
|
|
except Exception as exc:
|
|
logger.exception("❌ Pipeline failed: %s: %s", type(exc).__name__, exc)
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(asyncio.run(main()))
|