diff --git a/dvc/command/plots.py b/dvc/command/plots.py index f495a55b5a..00d1902698 100644 --- a/dvc/command/plots.py +++ b/dvc/command/plots.py @@ -193,11 +193,11 @@ def _add_props_arguments(parser): parser.add_argument("-x", default=None, help="Field name for x axis.") parser.add_argument("-y", default=None, help="Field name for y axis.") parser.add_argument( - "--no-csv-header", + "--no-header", action="store_false", - dest="csv_header", + dest="header", default=None, # Use default None to distinguish when it's not used - help="Provided CSV ot TSV datafile does not have a header.", + help="Provided CSV or TSV datafile does not have a header.", ) parser.add_argument( "--title", default=None, metavar="", help="Plot title." diff --git a/dvc/output/base.py b/dvc/output/base.py index f6eceec9f2..de1e4f403d 100644 --- a/dvc/output/base.py +++ b/dvc/output/base.py @@ -61,7 +61,7 @@ class BaseOutput: PARAM_PLOT_X_LABEL = "x_label" PARAM_PLOT_Y_LABEL = "y_label" PARAM_PLOT_TITLE = "title" - PARAM_PLOT_CSV_HEADER = "csv_header" + PARAM_PLOT_HEADER = "header" PARAM_PERSIST = "persist" METRIC_SCHEMA = Any( diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index a76a897012..fd092bdf1c 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -18,7 +18,7 @@ def collect(self, targets=None, revs=None): Returns a structure like: {rev: {plots.csv: { - props: {x: ..., "csv_header": ..., ...}, + props: {x: ..., "header": ..., ...}, data: "...data as a string...", }}} Data parsing is postponed, since it's affected by props. @@ -200,7 +200,7 @@ def _render(datafile, datas, props, templates): rev_data = plot_data(datafile, rev, datablob).to_datapoints( fields=fields, path=props.get("path"), - csv_header=props.get("csv_header", True), + header=props.get("header", True), append_index=props.get("append_index", False), ) data.extend(rev_data) diff --git a/dvc/repo/plots/data.py b/dvc/repo/plots/data.py index 0cce973643..d56e3ab9f7 100644 --- a/dvc/repo/plots/data.py +++ b/dvc/repo/plots/data.py @@ -181,10 +181,10 @@ def __init__(self, filename, revision, content, delimiter=","): super().__init__(filename, revision, content) self.delimiter = delimiter - def raw(self, csv_header=True, **kwargs): + def raw(self, header=True, **kwargs): first_row = first(csv.reader(io.StringIO(self.content))) - if csv_header: + if header: reader = csv.DictReader( io.StringIO(self.content), delimiter=self.delimiter, ) diff --git a/dvc/schema.py b/dvc/schema.py index 3fb762b022..0948f1f613 100644 --- a/dvc/schema.py +++ b/dvc/schema.py @@ -37,7 +37,7 @@ BaseOutput.PARAM_PLOT_X_LABEL: str, BaseOutput.PARAM_PLOT_Y_LABEL: str, BaseOutput.PARAM_PLOT_TITLE: str, - BaseOutput.PARAM_PLOT_CSV_HEADER: bool, + BaseOutput.PARAM_PLOT_HEADER: bool, } PLOT_PROPS_SCHEMA = { **OUT_PSTAGE_DETAILED_SCHEMA[str], diff --git a/tests/func/plots/test_plots.py b/tests/func/plots/test_plots.py index 365ae98238..46b145deb0 100644 --- a/tests/func/plots/test_plots.py +++ b/tests/func/plots/test_plots.py @@ -47,7 +47,7 @@ def test_plot_csv_one_column(tmp_dir, scm, dvc, run_copy_metrics): ) props = { - "csv_header": False, + "header": False, "x_label": "x_title", "y_label": "y_title", "title": "mytitle", diff --git a/tests/unit/command/test_plots.py b/tests/unit/command/test_plots.py index 8dba519af2..1cc7543eeb 100644 --- a/tests/unit/command/test_plots.py +++ b/tests/unit/command/test_plots.py @@ -63,7 +63,7 @@ def test_metrics_show(dvc, mocker): "-t", "template", "--show-vega", - "--no-csv-header", + "--no-header", "datafile", ] ) @@ -79,8 +79,7 @@ def test_metrics_show(dvc, mocker): assert cmd.run() == 0 m.assert_called_once_with( - targets=["datafile"], - props={"template": "template", "csv_header": False}, + targets=["datafile"], props={"template": "template", "header": False}, )