37 lines
1.3 KiB
Python
Executable File
37 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Repair only the generated Blender/WBV2 scheduler checkpoint metadata."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from datetime import datetime, timezone
|
|
|
|
from wbv2_runtime import CONTROL_ROOT, SCHEDULER_CHECKPOINT, queue_pointer, terminal_pointer
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--quiet", action="store_true")
|
|
args = parser.parse_args()
|
|
pointer = queue_pointer()
|
|
checkpoint = {}
|
|
try:
|
|
checkpoint = json.loads(SCHEDULER_CHECKPOINT.read_text(encoding="utf-8"))
|
|
except (OSError, json.JSONDecodeError):
|
|
checkpoint = {"schemaVersion": 1}
|
|
if terminal_pointer(pointer):
|
|
checkpoint.update({"state": "complete", "current": pointer, "repairedAt": datetime.now(timezone.utc).isoformat()})
|
|
CONTROL_ROOT.mkdir(parents=True, exist_ok=True)
|
|
SCHEDULER_CHECKPOINT.write_text(json.dumps(checkpoint, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
if not args.quiet:
|
|
print(f"WBV2 CHECKPOINT REPAIRED: terminal task={pointer.get('task') or 'NONE'}")
|
|
return 0
|
|
if not args.quiet:
|
|
print(f"WBV2 CHECKPOINT NOT REPAIRED: active task={pointer.get('task') or 'NONE'} requires scheduler evidence")
|
|
return 2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|