Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,6 @@ def stages(self):
"""
return self._collect_stages()

@cached_property
def plot_templates(self):
from .plots.template import PlotTemplates

return PlotTemplates(self.dvc_dir)

def _collect_stages(self):
stages = []
outs = set()
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def init(root_dir=os.curdir, no_scm=False, force=False, subdir=False):
proj = Repo(root_dir)

scm.add(
[config.files["repo"], dvcignore, proj.plot_templates.templates_dir]
[config.files["repo"], dvcignore, proj.plots.templates.templates_dir]
)

if scm.ignore_file:
Expand Down
12 changes: 9 additions & 3 deletions dvc/repo/plots/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os

from funcy import first, project
from funcy import cached_property, first, project

from dvc.exceptions import DvcException, NoPlotsError
from dvc.path_info import PathInfo
Expand Down Expand Up @@ -93,7 +93,7 @@ def show(self, targets=None, revs=None, props=None, templates=None):
raise NoPlotsError()

if templates is None:
templates = self.repo.plot_templates
templates = self.templates
return self.render(data, revs, props, templates)

def diff(self, *args, **kwargs):
Expand All @@ -118,7 +118,7 @@ def modify(self, path, props=None, unset=None):
props = props or {}
template = props.get("template")
if template:
self.repo.plot_templates.get_template(template)
self.templates.get_template(template)

(out,) = self.repo.find_outs_by_path(path)
if not out.plot and unset is not None:
Expand All @@ -142,6 +142,12 @@ def modify(self, path, props=None, unset=None):
dvcfile = Dvcfile(self.repo, out.stage.path)
dvcfile.dump(out.stage, update_lock=False)

@cached_property
def templates(self):
from .template import PlotTemplates

return PlotTemplates(self.repo.dvc_dir)


def _collect_plots(repo, targets=None, rev=None):
plots = {out for stage in repo.stages for out in stage.outs if out.plot}
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/plots/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _revisions(repo, revs, experiment):
def diff(repo, *args, revs=None, experiment=False, **kwargs):
if experiment:
# use experiments repo brancher with templates from the main repo
kwargs["templates"] = repo.plot_templates
kwargs["templates"] = repo.plots.templates
plots_repo = repo.experiments.exp_dvc
else:
plots_repo = repo
Expand Down
2 changes: 1 addition & 1 deletion tests/func/plots/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def test_plot_multiple_revs_default(tmp_dir, scm, dvc, run_copy_metrics):


def test_plot_multiple_revs(tmp_dir, scm, dvc, run_copy_metrics):
templates_dir = dvc.plot_templates.templates_dir
templates_dir = dvc.plots.templates.templates_dir
shutil.copy(
os.path.join(templates_dir, "default.json"),
os.path.join(templates_dir, "template.json"),
Expand Down