def check(sweep_id, num=None, result=None, stopped=None): settings = wandb.InternalApi().settings() api = wandb.Api(overrides=settings) sweep = api.sweep("%s/%s" % (PROJECT, sweep_id)) runs = sorted(sweep.runs, key=lambda run: run.summary.get("val_acc", 0), reverse=True) if num is not None: print("CHECKING: runs, saw: {}, expecting: {}".format(len(runs), num)) assert len(runs) == num val_acc = None cnt_stopped = 0 for run in runs: print("stop debug", run.id, getattr(run, "stopped", None), run.state) if getattr(run, "stopped", None) or run.state == "stopped": cnt_stopped += 1 tmp = run.summary.get("val_acc") assert tmp is not None val_acc = tmp if val_acc is None or tmp > val_acc else val_acc if stopped is not None: print("NOT CHECKING: stopped, saw: {}, expecting: {}".format( cnt_stopped, stopped)) # FIXME: turn on stopped run state if result is not None: print("CHECKING: metric, saw: {}, expecting: {}".format( val_acc, result)) assert val_acc == result print("ALL GOOD")
def find_entity() -> str: return wandb.InternalApi().viewer()["entity"]