Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion dvc/repo/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,23 @@ def collect(
data[rev][repo_path]["data"] = fd.read()
except FileNotFoundError:
# This might happen simply because cache is absent
pass
logger.debug(
(
"Could not find '%s' on '%s'. "
"File will not be plotted"
),
path,
rev,
)
except UnicodeDecodeError:
logger.debug(
(
"'%s' at '%s' is binary file. It will not be "
"plotted."
),
path,
rev,
)

return data

Expand Down
10 changes: 10 additions & 0 deletions tests/func/plots/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,3 +827,13 @@ def test_show_dir_plots(tmp_dir, dvc, run_copy_metrics):

result = dvc.plots.show(targets=[p1])
assert set(result.keys()) == {p1}


def test_ignore_binary_file(tmp_dir, dvc, run_copy_metrics):
with open("file", "wb") as fobj:
fobj.write(b"\xc1")

run_copy_metrics("file", "plot_file", plots=["plot_file"])

with pytest.raises(NoMetricsParsedError):
dvc.plots.show()