def update_checkpoint(launchpad: LaunchPad, launch_dir: str, launch_id: int, checkpoint: Dict[str, any]) -> None: """ Helper function to update checkpoint Args: launchpad (LaunchPad): LaunchPad to ping with checkpoint data launch_dir (str): directory in which FW_offline.json was created launch_id (int): launch id to update checkpoint (dict): checkpoint data """ if launchpad: launchpad.ping_launch(launch_id, checkpoint=checkpoint) else: fpath = zpath(os.path.join(launch_dir, "FW_offline.json")) with zopen(fpath) as f_in: d = json.loads(f_in.read()) d["checkpoint"] = checkpoint with zopen(fpath, "wt") as f_out: f_out.write(json.dumps(d, ensure_ascii=False))
def do_ping(launchpad: LaunchPad, launch_id: int) -> None: if launchpad: launchpad.ping_launch(launch_id) else: with open("FW_ping.json", "w") as f: f.write('{"ping_time": "%s"}' % datetime.utcnow().isoformat())