From 895b91cfa9f5ec399673ef455bd0af408e50c90e Mon Sep 17 00:00:00 2001 From: Auguste Baum Date: Mon, 20 Jan 2025 17:25:33 +0100 Subject: [PATCH] revert: Remove HTML repr of Items Closes #1161 --- skore/src/skore/persistence/item/item.py | 31 ------------------------ 1 file changed, 31 deletions(-) diff --git a/skore/src/skore/persistence/item/item.py b/skore/src/skore/persistence/item/item.py index 8cde7ab84..bd3cd9de0 100644 --- a/skore/src/skore/persistence/item/item.py +++ b/skore/src/skore/persistence/item/item.py @@ -5,11 +5,7 @@ import inspect from abc import ABC, abstractmethod from datetime import datetime, timezone -from pathlib import Path from typing import Any, Optional -from uuid import uuid4 - -from jinja2 import Environment, FileSystemLoader class ItemTypeError(Exception): @@ -89,33 +85,6 @@ def __repr__(self) -> str: """Represent the item.""" return f"{self.__class__.__name__}(...)" - def _repr_mimebundle_(self, include=None, exclude=None): - return {"text/html": self._repr_html_()} - - def _repr_html_(self): - """Represent the item in a notebook.""" - item_folder = Path(__file__).resolve().parent - templates_env = Environment(loader=FileSystemLoader(item_folder)) - template = templates_env.get_template("standalone_widget.html.jinja") - - static_files_path = item_folder.parent / "ui" / "static" / "assets" - - def read_asset_content(path): - with open(static_files_path / path) as f: - return f.read() - - script_content = read_asset_content("index.js") - styles_content = read_asset_content("index.css") - - context = { - "id": uuid4().hex, - "item": self.as_serializable_dict(), - "script": script_content, - "styles": styles_content, - } - - return template.render(**context) - def as_serializable_dict(self): """Convert item to a JSON-serializable dict to used by frontend.