def test_get_step_control_flow(tmp_dir): dvclive = Live() while dvclive.get_step() < 10: dvclive.log("i", dvclive.get_step()) dvclive.next_step() steps, values = read_history("dvclive", "i") assert steps == list(range(10)) assert values == [float(x) for x in range(10)]
def test_get_step_control_flow(tmp_dir): dvclive = Live() out = tmp_dir / dvclive.dir / Scalar.subfolder while dvclive.get_step() < 10: dvclive.log("i", dvclive.get_step()) dvclive.next_step() steps, values = read_history(out, "i") assert steps == list(range(10)) assert values == [float(x) for x in range(10)]
def test_get_step_resume(tmp_dir): dvclive = Live() for metric in [0.9, 0.8]: dvclive.log("metric", metric) dvclive.next_step() assert dvclive.get_step() == 2 dvclive = Live(resume=True) assert dvclive.get_step() == 2 dvclive = Live(resume=False) assert dvclive.get_step() == 0
def test_get_step_custom_steps(tmp_dir): dvclive = Live() steps = [0, 62, 1000] metrics = [0.9, 0.8, 0.7] for step, metric in zip(steps, metrics): dvclive.set_step(step) dvclive.log("x", metric) assert dvclive.get_step() == step