mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-08 07:18:27 +01:00
* plots: support images initial * plots: data: unify PlotsData * plots: data conversion refactor * plots: renderers: abstract functionality * plots: uncommenting tests * plots: self implement grouping * plots: rename group * plots: extract rendering tests * plots: move rendering tests to unit * plots: add image rendering tests * plots: dont use dpath to find vega plot * plots: test find_vega * plots: test render function * plots: move rendering out of repo package * plots: refactoring * plots: self review refactor
34 lines
866 B
Python
34 lines
866 B
Python
import logging
|
|
from typing import TYPE_CHECKING, Dict
|
|
|
|
if TYPE_CHECKING:
|
|
from dvc.types import StrPath
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class Renderer:
|
|
def __init__(self, data: Dict):
|
|
self.data = data
|
|
|
|
from dvc.render.utils import get_files
|
|
|
|
files = get_files(self.data)
|
|
|
|
# we assume comparison of same file between revisions for now
|
|
assert len(files) == 1
|
|
self.filename = files.pop()
|
|
|
|
def _convert(self, path: "StrPath"):
|
|
raise NotImplementedError
|
|
|
|
@property
|
|
def DIV(self):
|
|
raise NotImplementedError
|
|
|
|
def generate_html(self, path: "StrPath"):
|
|
"""this method might edit content of path"""
|
|
partial = self._convert(path)
|
|
div_id = f"plot_{self.filename.replace('.', '_').replace('/', '_')}"
|
|
return self.DIV.format(id=div_id, partial=partial)
|