def test_exists(tmp_dir, dvc): tmp_dir.gen("foo", "foo") dvc.add("foo") (tmp_dir / "foo").unlink() tree = RepoTree(dvc) assert tree.exists("foo")
def _read_metrics(repo, metrics, rev): tree = RepoTree(repo) res = {} for metric in metrics: if not tree.exists(fspath_py35(metric)): continue with tree.open(fspath_py35(metric), "r") as fobj: try: # NOTE this also supports JSON val = yaml.safe_load(fobj) except yaml.YAMLError: logger.debug( "failed to read '%s' on '%s'", metric, rev, exc_info=True ) continue val = _extract_metrics(val) if val: res[str(metric)] = val return res