mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-27 07:18:28 +01:00
plots: rename --no-csv-header to --no-header (#4001)
* plots: rename --no-csv-header to --no-header Fixes #3996 * fix typo
This commit is contained in:
@@ -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."
|
||||
|
||||
+1
-1
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
+1
-1
@@ -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],
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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},
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user