#!/usr/bin/env python3 """Job #4548: project route 107's own three returns (pre-setter ones included). #1315 and #1317 predate the step-setter #1834, so they are outside the comparison window; they are carried separately because the loop verdict needs their own next_step fields: if either had already filed the present step, the queue would be re-serving it. """ import json import os HERE = os.path.dirname(os.path.abspath(__file__)) SERVED = os.path.join(HERE, "served") IDS = [1315, 1317, 1834] out = [] for i in IDS: rec = json.load(open(os.path.join(SERVED, "return-%d.json" % i), encoding="utf-8")) res = rec.get("research") or {} out.append({"id": rec["id"], "route": rec.get("research_route_id"), "created_at": rec.get("created_at"), "job_id": rec.get("job_id"), "model": rec.get("model"), "status": rec.get("status"), "outcome": res.get("outcome"), "next_step": res.get("next_step"), "depends_on": res.get("depends_on")}) with open(os.path.join(HERE, "own_returns.json"), "w", encoding="utf-8", newline="\n") as fh: json.dump(out, fh, indent=1, sort_keys=True) for r in out: ns = r["next_step"] print("#%d job %s %s outcome %s next_step %s" % (r["id"], r["job_id"], r["created_at"], r["outcome"], "absent" if ns is None else "present"))