mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-07 07:18:27 +01:00
* params: add targets option * fixup * remove unnecessary changes * fix isort * params: diff: add test for --targets * tests: roll back metric/plots unification, introduce collect test * metrics/plots: refactoring * missing plots test added
24 lines
627 B
Python
24 lines
627 B
Python
import csv
|
|
import json
|
|
|
|
from funcy import first
|
|
|
|
|
|
def _write_csv(metric, filename, header=True):
|
|
with open(filename, "w", newline="") as csvobj:
|
|
if header:
|
|
writer = csv.DictWriter(
|
|
csvobj, fieldnames=list(first(metric).keys())
|
|
)
|
|
writer.writeheader()
|
|
writer.writerows(metric)
|
|
else:
|
|
writer = csv.writer(csvobj)
|
|
for d in metric:
|
|
assert len(d) == 1
|
|
writer.writerow(list(d.values()))
|
|
|
|
|
|
def _write_json(tmp_dir, metric, filename):
|
|
tmp_dir.gen(filename, json.dumps(metric, sort_keys=True))
|