mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
plots: ignore binary plot files (#5523)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user