def get_run(output, end_hash, start_hash, orchestrator): # first check if the output is None, if it is we automatically # generate a file in the cwd that is the hash of the snapshot if output is None: output = "{}-{}.orch.sqlite".format(start_hash, end_hash) # check that it doesn't exist, and fail if it does, since we # don't want to implicitly overwrite stuff if osp.exists(output): raise OSError("No output path was specified and default alredy exists, exiting.") orch = Orchestrator(orchestrator, mode='r') start_serial_snapshot = orch.snapshot_kv[start_hash] end_serial_snapshot = orch.snapshot_kv[end_hash] # get the records values for this run rec_d = {field : value for field, value in zip(Orchestrator.RUN_SELECT_FIELDS, orch.get_run_record(start_hash, end_hash))} config = orch.configuration_kv[rec_d['config_hash']] # create a new orchestrator at the output location new_orch = Orchestrator(output, mode='w') _ = new_orch.add_serial_snapshot(start_serial_snapshot) _ = new_orch.add_serial_snapshot(end_serial_snapshot) config_hash = new_orch.add_serial_configuration(config) new_orch.register_run(start_hash, end_hash, config_hash, rec_d['last_cycle_idx']) orch.close() new_orch.close()
def get_run_cycles(end_hash, start_hash, orchestrator): orch = Orchestrator(orchestrator, mode='r') start_serial_snapshot = orch.snapshot_kv[start_hash] end_serial_snapshot = orch.snapshot_kv[end_hash] # get the records values for this run rec_d = {field : value for field, value in zip(Orchestrator.RUN_SELECT_FIELDS, orch.get_run_record(start_hash, end_hash))} click.echo(rec_d['last_cycle_idx'])