plots: ignore binary plot files (#5523)

This commit is contained in:
Paweł Redzyński
2021-03-01 15:00:42 +02:00
committed by GitHub
parent f2e0059392
commit 92b95bae9b
2 changed files with 27 additions and 1 deletions
+17 -1
View File
@@ -87,7 +87,23 @@ class Plots:
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
+10
View File
@@ -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()