Repository: iterative/dvc

Issue:
plots modify: change --no-csv-header to --no-header?
> Extracted from https://github.com/iterative/dvc.org/pull/1382#pullrequestreview-425769472

> should it be just --no-header? - @shcheklein

> or --no-table-header since TSV is also supported. This way it remains obvious that it only applies to tabular metric files. But I could also support --no-header — cleaner.
- me

> I like the --no-table-header - @pared 

### Please provide information about your setup

DVC 1.0

Discussion:

Patch:
diff --git a/dvc/command/plots.py b/dvc/command/plots.py
index f495a55b5..00d190269 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="<text>", help="Plot title."
diff --git a/dvc/output/base.py b/dvc/output/base.py
index f6eceec9f..de1e4f403 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 a76a89701..fd092bdf1 100644
--- a/dvc/repo/plots/__init__.py
+++ b/dvc/repo/plots/__init__.py
@@ -18,7 +18,7 @@ class Plots:
 
         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 0cce97364..d56e3ab9f 100644
--- a/dvc/repo/plots/data.py
+++ b/dvc/repo/plots/data.py
@@ -181,10 +181,10 @@ class CSVPlotData(PlotData):
         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 3fb762b02..0948f1f61 100644
--- a/dvc/schema.py
+++ b/dvc/schema.py
@@ -37,7 +37,7 @@ PLOT_PROPS = {
     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],


Test patch:
diff --git a/tests/func/plots/test_plots.py b/tests/func/plots/test_plots.py
index 365ae9823..46b145deb 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 8dba519af..1cc7543ee 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},
     )