From 55cf8c474b08f87992dd9c14b7a119463992f136 Mon Sep 17 00:00:00 2001 From: Cyril Achard Date: Thu, 26 Nov 2026 15:33:27 +0100 Subject: [PATCH 1/2] Copy findings and tree rendering, with the display hooks that use them --- dlccore/project/schemas/base/findings.py | 33 +- dlccore/project/schemas/base/observations.py | 37 ++- dlccore/project/schemas/snapshots.py | 50 ++-- dlccore/project/visualization/__init__.py | 14 + dlccore/project/visualization/findings.py | 231 ++++++++++++++ dlccore/project/visualization/tree.py | 299 +++++++++++++++++++ tests/project/visualization/test_findings.py | 183 ++++++++++++ tests/project/visualization/test_tree.py | 210 +++++++++++++ 8 files changed, 1008 insertions(+), 49 deletions(-) create mode 100644 dlccore/project/visualization/__init__.py create mode 100644 dlccore/project/visualization/findings.py create mode 100644 dlccore/project/visualization/tree.py create mode 100644 tests/project/visualization/test_findings.py create mode 100644 tests/project/visualization/test_tree.py diff --git a/dlccore/project/schemas/base/findings.py b/dlccore/project/schemas/base/findings.py index f5a7f83..cf651aa 100644 --- a/dlccore/project/schemas/base/findings.py +++ b/dlccore/project/schemas/base/findings.py @@ -1,14 +1,4 @@ -# -# DeepLabCut Toolbox (deeplabcut.org) -# © A. & M.W. Mathis Labs -# https://github.com/DeepLabCut/dlccore -# -# Contributors: -# https://github.com/DeepLabCut/dlccore/graphs/contributors -# -# Licensed under GNU Lesser General Public License v3.0 -# - +# schemas/base/findings.py """Simple diagnostic facts generated from walking through the project structure. These are the main enablers for downstream reporting, consumption by GUI/CLI/LLM agents, @@ -20,12 +10,16 @@ from enum import Enum from pathlib import Path +from typing import TYPE_CHECKING from pydantic import Field, JsonValue, model_validator from typing_extensions import Self -from dlccore.project.schemas.base.core import FrozenModel, LayoutInstance, SchemaId -from dlccore.project.schemas.base.finding_codes import FindingCode, Severity, finding_code +from dlc_octopus.schemas.base.core import FrozenModel, LayoutInstance, SchemaId +from dlc_octopus.schemas.base.finding_codes import FindingCode, Severity, finding_code + +if TYPE_CHECKING: + from IPython.lib.pretty import RepresentationPrinter class Reach(str, Enum): @@ -100,3 +94,16 @@ def _check_reach(self) -> Self: raise ValueError(f"Reach {self.reach.name} names one instance, but got none.") return self + + # Display hooks only IPython and Jupyter call; repr, str and serialization stay pydantic's. + # Imported on call so that schemas never load visualization. + + def _repr_pretty_(self, printer: RepresentationPrinter, cycle: bool) -> None: # noqa: FBT001 - IPython's signature + from dlc_octopus.visualization.findings import render_finding + + printer.text("Finding(...)" if cycle else render_finding(self)) + + def _repr_markdown_(self) -> str: + from dlc_octopus.visualization.findings import render_finding + + return render_finding(self, style="markdown") diff --git a/dlccore/project/schemas/base/observations.py b/dlccore/project/schemas/base/observations.py index 7fcdab8..b78bc1b 100644 --- a/dlccore/project/schemas/base/observations.py +++ b/dlccore/project/schemas/base/observations.py @@ -1,30 +1,24 @@ -# -# DeepLabCut Toolbox (deeplabcut.org) -# © A. & M.W. Mathis Labs -# https://github.com/DeepLabCut/dlccore -# -# Contributors: -# https://github.com/DeepLabCut/dlccore/graphs/contributors -# -# Licensed under GNU Lesser General Public License v3.0 -# - +# schemas/base/observations.py from __future__ import annotations from enum import Enum +from typing import TYPE_CHECKING -from dlccore.project.schemas.base.core import FrozenModel, ProjectRelativePath, SchemaId -from dlccore.project.schemas.base.probes import PathProbe -from dlccore.project.schemas.base.resources import ( +from dlc_octopus.schemas.base.core import FrozenModel, ProjectRelativePath, SchemaId +from dlc_octopus.schemas.base.probes import PathProbe +from dlc_octopus.schemas.base.resources import ( DirectoryResourceKind, FileResourceKind, ProjectResource, ResourceManagement, ) -from dlccore.project.schemas.base.symlinks import ( +from dlc_octopus.schemas.base.symlinks import ( SymlinkObservation, ) +if TYPE_CHECKING: + from IPython.lib.pretty import RepresentationPrinter + class NodeStatus(str, Enum): """Observed state of a project node.""" @@ -79,6 +73,19 @@ def should_be_directory(self) -> bool: """Whether the project schema defines this node as a directory.""" return isinstance(self.kind, DirectoryResourceKind) + # Display hooks only IPython and Jupyter call; repr, str and serialization stay pydantic's. + # Imported on call so that schemas never load visualization. + + def _repr_pretty_(self, printer: RepresentationPrinter, cycle: bool) -> None: # noqa: FBT001 - IPython's signature + from dlc_octopus.visualization.tree import render_project_tree + + printer.text("ObservedNode(...)" if cycle else render_project_tree(self)) + + def _repr_html_(self) -> str: + from dlc_octopus.visualization.tree import render_project_tree_html + + return render_project_tree_html(self) + def walk_observed_nodes(node: ObservedNode) -> tuple[ObservedNode, ...]: """Return a node and its schema-recognized descendants, depth first.""" diff --git a/dlccore/project/schemas/snapshots.py b/dlccore/project/schemas/snapshots.py index 4f80965..7f2d300 100644 --- a/dlccore/project/schemas/snapshots.py +++ b/dlccore/project/schemas/snapshots.py @@ -1,14 +1,3 @@ -# -# DeepLabCut Toolbox (deeplabcut.org) -# © A. & M.W. Mathis Labs -# https://github.com/DeepLabCut/dlccore -# -# Contributors: -# https://github.com/DeepLabCut/dlccore/graphs/contributors -# -# Licensed under GNU Lesser General Public License v3.0 -# - from __future__ import annotations from enum import Enum @@ -18,28 +7,29 @@ from pydantic import model_validator from typing_extensions import Self -from dlccore.project.errors import ConfigUnavailableError -from dlccore.project.schemas.base.core import FrozenModel -from dlccore.project.schemas.base.findings import ( +from dlc_octopus.errors import ConfigUnavailableError +from dlc_octopus.schemas.base.core import FrozenModel +from dlc_octopus.schemas.base.findings import ( Finding, Reach, ) -from dlccore.project.schemas.base.observations import ObservedNode -from dlccore.project.schemas.base.resources import ( +from dlc_octopus.schemas.base.observations import ObservedNode +from dlc_octopus.schemas.base.resources import ( ProjectResource, ResourceKind, ) -from dlccore.project.schemas.base.validation import ValidationCheck -from dlccore.project.schemas.project_layout.config import ( +from dlc_octopus.schemas.base.validation import ValidationCheck +from dlc_octopus.schemas.project_layout.config import ( ConfigObservation, FailedConfigObservation, ValidConfigObservation, ) -from dlccore.project.schemas.utils import flatten_observed_project +from dlc_octopus.schemas.utils import flatten_observed_project if TYPE_CHECKING: - from dlccore.config import ProjectConfig - from dlccore.project.validation.results import ValidationResult + from deeplabcut.core.config import ProjectConfig + + from dlc_octopus.validation.results import ValidationResult # 0.x declares the snapshot format unstable: it changes with the vocabulary and carries # no compatibility promise. Bumping is owed once a consumer reads a snapshot back. @@ -174,6 +164,24 @@ def config_state( return ConfigState.VALID + def render_tree( + self, + *, + show_schema_ids: bool = False, + show_unknown: bool = True, + max_children_per_kind: int | None = 50, + ) -> str: + """Render a tree view of the project snapshot.""" + + from dlc_octopus.visualization import render_project_tree + + return render_project_tree( + project=self.project, + show_schema_ids=show_schema_ids, + show_unknown=show_unknown, + max_children_per_kind=max_children_per_kind, + ) + @property def config(self) -> ProjectConfig: """Return canonical config data or fail explicitly.""" diff --git a/dlccore/project/visualization/__init__.py b/dlccore/project/visualization/__init__.py new file mode 100644 index 0000000..104d5c6 --- /dev/null +++ b/dlccore/project/visualization/__init__.py @@ -0,0 +1,14 @@ +from .capabilities import render_capabilities +from .findings import render_finding, render_finding_catalogue, render_findings_markdown +from .report import render_project_report +from .tree import render_project_tree, render_project_tree_html + +__all__ = [ + "render_capabilities", + "render_finding", + "render_finding_catalogue", + "render_findings_markdown", + "render_project_report", + "render_project_tree", + "render_project_tree_html", +] diff --git a/dlccore/project/visualization/findings.py b/dlccore/project/visualization/findings.py new file mode 100644 index 0000000..e65a84b --- /dev/null +++ b/dlccore/project/visualization/findings.py @@ -0,0 +1,231 @@ +"""Render findings for people: several lines, one line for logs, or Markdown for notebooks and issues.""" + +from __future__ import annotations + +from collections import Counter +from collections.abc import Iterable +from pathlib import Path +from typing import Literal + +from dlc_octopus.schemas.base.finding_codes import FindingCode, Severity, iter_finding_codes +from dlc_octopus.schemas.base.findings import Finding + +FindingStyle = Literal["text", "compact", "markdown"] +CatalogueStyle = Literal["text", "markdown"] + +REDACTED_ROOT = "" +_SEVERITY_WIDTH = max(len(severity.value) for severity in Severity) +_MOST_SEVERE_FIRST = tuple(Severity)[::-1] +_FIELD_SEPARATOR = chr(0x203A) # single right-pointing angle quotation mark, between a file and a field + + +def render_finding( + finding: Finding, + *, + project_root: Path | None = None, + style: FindingStyle = "text", +) -> str: + """Render one finding: where it is, what it says and its code, then its evidence. + + Args: + finding: The finding to render. + project_root: The snapshot's project root; a ``path`` under it is shown project-relative. + style: ``"text"`` over several lines, ``"compact"`` on one line, or ``"markdown"``. + + Raises: + ValueError: If ``style`` is not one of the three. + """ + + severity = finding.severity.value.upper() + evidence = _evidence(finding) + + if style == "text": + indent = " " * (_SEVERITY_WIDTH + 2) + lines = [ + f"{severity:<{_SEVERITY_WIDTH}} {_location(finding, project_root)}", + f"{indent}{finding.code.description} [{finding.code}]", + ] + lines.extend(f"{indent}{key}: {value}" for key, value in evidence) + return "\n".join(lines) + + if style == "compact": + details = ", ".join(f"{key}={value}" for key, value in evidence) + line = f"{severity} {finding.code} {_location(finding, project_root)}: {finding.code.description}" + return f"{line} ({details})" if details else line + + if style == "markdown": + lines = [ + f"**{severity}** {_markdown_location(finding, project_root)}: " + f"{finding.code.description} {_inline_code(str(finding.code))}" + ] + lines.extend(f"- {_inline_code(key)}: {_inline_code(value)}" for key, value in evidence) + return "\n".join(lines) + + raise ValueError(f"Unknown finding style {style!r}; expected 'text', 'compact' or 'markdown'.") + + +def render_finding_catalogue(*, style: CatalogueStyle = "text") -> str: + """Render every finding code Octopus can emit, one section per category, in catalogue order. + + Args: + style: ``"text"``, or ``"markdown"`` with one table per category. + + Raises: + ValueError: If ``style`` is not one of the two. + """ + + if style not in ("text", "markdown"): + raise ValueError(f"Unknown catalogue style {style!r}; expected 'text' or 'markdown'.") + + categories: dict[type[FindingCode], list[FindingCode]] = {} + for code in iter_finding_codes(): + categories.setdefault(type(code), []).append(code) + + sections = [] + for category, codes in categories.items(): + title = _category_title(category) + summary = (category.__doc__ or "").strip().splitlines()[0].replace("``", "`") + if style == "text": + width = max(len(code.value) for code in codes) + rows = [ + f" {code.severity.value.upper():<{_SEVERITY_WIDTH}} {code.value:<{width}} {code.description}" + for code in codes + ] + sections.append("\n".join([f"{title}: {summary.replace('`', '')}", *rows])) + else: + rows = [ + f"| {_inline_code(code.value)} | {code.severity.value} | {_table_cell(code.description)} |" + for code in codes + ] + header = ["| Code | Default severity | Meaning |", "|---|---|---|"] + sections.append("\n".join([f"**{title}**: {summary}", "", *header, *rows])) + + return "\n\n".join(sections) + + +def render_findings_markdown( + findings: Iterable[Finding], + *, + project_root: Path | None = None, + redact_root: bool = True, +) -> str: + """Render findings as a Markdown table, their evidence folded below it, ready to paste into an issue. + + With ``redact_root``, the project root is replaced by ```` wherever it appears verbatim, so the + pasted text does not carry the local path. Paths outside the project root are left as observed. + + Args: + findings: The findings to render, in the order given. + project_root: The snapshot's project root. + redact_root: Whether to replace ``project_root`` in locations and evidence. + """ + + findings = tuple(findings) + if not findings: + return "No findings." + + redact = project_root if redact_root else None + counts = Counter(finding.severity for finding in findings) + tally = " · ".join( + f"{counts[severity]} {severity.value}{'' if counts[severity] == 1 else 's'}" + for severity in _MOST_SEVERE_FIRST + if counts[severity] + ) + lines = [ + f"**{len(findings)} finding{'' if len(findings) == 1 else 's'}** · {tally}", + "", + "| Severity | Where | What | Code |", + "|---|---|---|---|", + ] + lines.extend( + f"| {finding.severity.value.upper()} " + f"| {_table_cell(_redacted(_markdown_location(finding, project_root), redact))} " + f"| {_table_cell(finding.code.description)} " + f"| {_inline_code(str(finding.code))} |" + for finding in findings + ) + + detailed = [finding for finding in findings if finding.evidence] + if detailed: + lines.extend(["", "
Evidence", ""]) + lines.extend( + f"- {_inline_code(str(finding.code))} at " + f"{_redacted(_markdown_location(finding, project_root), redact)}: " + + " · ".join( + f"{_inline_code(key)}: {_inline_code(_redacted(value, redact))}" for key, value in _evidence(finding) + ) + for finding in detailed + ) + lines.extend(["", "
"]) + + return "\n".join(lines) + + +def _place(finding: Finding, project_root: Path | None) -> str: + """Return where the finding was observed: its path, else its instance, else its layout node.""" + + if finding.path is not None: + if project_root is not None and finding.path.is_relative_to(project_root): + return finding.path.relative_to(project_root).as_posix() + return str(finding.path) + + if finding.instance: + return "/".join(finding.instance) + + return finding.schema_id + + +def _field(finding: Finding) -> str: + return ".".join(str(part) for part in finding.field_location) + + +def _location(finding: Finding, project_root: Path | None) -> str: + field = _field(finding) + place = _place(finding, project_root) + return f"{place}:{field}" if field else place + + +def _markdown_location(finding: Finding, project_root: Path | None) -> str: + field = _field(finding) + place = _inline_code(_place(finding, project_root)) + return f"{place} {_FIELD_SEPARATOR} {_inline_code(field)}" if field else place + + +def _evidence(finding: Finding) -> list[tuple[str, str]]: + """Return the evidence, the code's declared keys first, each value collapsed onto one line.""" + + declared = [key for key in finding.code.evidence_keys if key in finding.evidence] + extra = sorted(key for key in finding.evidence if key not in finding.code.evidence_keys) + + return [(key, " ".join(str(finding.evidence[key]).split())) for key in (*declared, *extra)] + + +def _redacted(text: str, project_root: Path | None) -> str: + if project_root is None: + return text + + for spelling in dict.fromkeys((str(project_root), project_root.as_posix())): + text = text.replace(spelling, REDACTED_ROOT) + + return text + + +def _inline_code(text: str) -> str: + """Wrap ``text`` in a code span that a backtick inside it cannot close.""" + + if "`" in text: + return f"`` {text} ``" + return f"`{text}`" + + +def _table_cell(text: str) -> str: + return text.replace("|", "\\|") + + +def _category_title(category: type[FindingCode]) -> str: + """``ConfiguredVideoFindingCode`` reads as "Configured video".""" + + name = category.__name__.removesuffix("FindingCode") + words = "".join(f" {char}" if char.isupper() else char for char in name).split() + + return " ".join([words[0], *(word.lower() for word in words[1:])]) diff --git a/dlccore/project/visualization/tree.py b/dlccore/project/visualization/tree.py new file mode 100644 index 0000000..2d82a8c --- /dev/null +++ b/dlccore/project/visualization/tree.py @@ -0,0 +1,299 @@ +# dlc_octopus/visualization/tree.py +from __future__ import annotations + +from html import escape +from typing import Any + +from dlc_octopus.schemas.base.observations import ( + NodeStatus, + ObservedNode, +) +from dlc_octopus.schemas.base.resources import ( + DirectoryResourceKind, + FileResourceKind, + ProjectResource, + ResourceManagement, +) + +_STATUS_MARKERS = { + NodeStatus.PRESENT: "✓", + NodeStatus.MISSING: "✗", + NodeStatus.UNREADABLE: "!", + NodeStatus.WRONG_TYPE: "!", +} + + +class _FileBudget: + """How many more files a rendering may list; ``None`` is unlimited.""" + + def __init__(self, remaining: int | None) -> None: + self.remaining = remaining + + def take(self) -> bool: + """Spend one file if any remain, and say whether it was spent.""" + + if self.remaining is None: + return True + if self.remaining == 0: + return False + self.remaining -= 1 + return True + + +def render_project_tree( + project: ObservedNode, + *, + show_schema_ids: bool = False, + show_unmanaged: bool = False, + show_unknown: bool = True, + max_children_per_kind: int | None = 10, +) -> str: + """Render an observed project as a compact semantic tree.""" + + lines: list[str] = [] + + _render_node( + project, + prefix="", + is_last=True, + is_root=True, + lines=lines, + show_schema_ids=show_schema_ids, + show_unmanaged=show_unmanaged, + show_unknown=show_unknown, + max_children_per_kind=max_children_per_kind, + ) + + return "\n".join(lines) + + +def _render_node( + node: ObservedNode, + *, + prefix: str, + is_last: bool, + is_root: bool, + lines: list[str], + show_schema_ids: bool, + show_unmanaged: bool, + show_unknown: bool, + max_children_per_kind: int | None, +) -> None: + """Append one observed node and its descendants to rendered lines.""" + + connector = "" if is_root else "└── " if is_last else "├── " + marker = _STATUS_MARKERS[node.status] + + label = _label(node, is_root=is_root) + + details = [ + node.kind.value, + node.status.value, + ] + + if node.management != ResourceManagement.MANAGED: + details.append(node.management.value) + + if show_schema_ids: + details.append(node.schema_id) + + lines.append(f"{prefix}{connector}{marker} {label} [{', '.join(details)}]") + + eligible_children = _eligible_children(node, show_unmanaged=show_unmanaged) + + visible_children, omitted_count = _compact_children( + eligible_children, + maximum=max_children_per_kind, + ) + + entries: list[tuple[str, Any]] = [("node", child) for child in visible_children] + + if omitted_count: + entries.append(("omitted", omitted_count)) + + if show_unknown: + entries.extend(("unknown", resource) for resource in node.unclaimed_resources) + + child_prefix = prefix if is_root else prefix + (" " if is_last else "│ ") + + for index, (entry_type, entry) in enumerate(entries): + entry_is_last = index == len(entries) - 1 + + if entry_type == "node": + _render_node( + entry, + prefix=child_prefix, + is_last=entry_is_last, + is_root=False, + lines=lines, + show_schema_ids=show_schema_ids, + show_unknown=show_unknown, + show_unmanaged=show_unmanaged, + max_children_per_kind=max_children_per_kind, + ) + continue + + connector = "└── " if entry_is_last else "├── " + + if entry_type == "unknown": + lines.append(f"{child_prefix}{connector}? {entry.project_relative_path.name} [{entry.kind.value}]") + else: + lines.append(f"{child_prefix}{connector}… {entry} additional children omitted") + + +def render_project_tree_html( + project: ObservedNode, + *, + show_schema_ids: bool = False, + show_unmanaged: bool = False, + show_unknown: bool = True, + max_files: int | None = 500, +) -> str: + """Render an observed project as a collapsible HTML tree, listing at most ``max_files`` files on disk. + + Directories are ``
`` elements, the project root open and the rest closed. Directories, and files that + are missing or of the wrong type, are always listed. Files on disk count towards ``max_files``, unclaimed ones + too while ``show_unknown`` lists them; once it is reached, + each directory reports the number of additional files not shown. + + Raises: + ValueError: If ``max_files`` is negative. + """ + + if max_files is not None and max_files < 0: + raise ValueError(f"max_files must be None or at least 0, not {max_files}.") + + budget = _FileBudget(max_files) + body = _html_node( + project, + is_root=True, + show_schema_ids=show_schema_ids, + show_unmanaged=show_unmanaged, + show_unknown=show_unknown, + budget=budget, + ) + + return f'
{body}
' + + +def _label(node: ObservedNode, *, is_root: bool) -> str: + """The project root by its kind, any other top node by its project-relative path, a child by its name.""" + + if not is_root: + return node.project_relative_path.name + if node.kind is DirectoryResourceKind.PROJECT_ROOT: + return node.kind.value + return node.project_relative_path.as_posix() + + +def _html_node( + node: ObservedNode, + *, + is_root: bool, + show_schema_ids: bool, + show_unmanaged: bool, + show_unknown: bool, + budget: _FileBudget, +) -> str: + """Render one observed node and its descendants as HTML.""" + + label = _label(node, is_root=is_root) + details = [node.kind.value, node.status.value] + + if node.management != ResourceManagement.MANAGED: + details.append(node.management.value) + + if show_schema_ids: + details.append(node.schema_id) + + line = ( + f'{_STATUS_MARKERS[node.status]} {escape(label)} ' + f'[{escape(", ".join(details))}]' + ) + + children = _eligible_children(node, show_unmanaged=show_unmanaged) + unknown = node.unclaimed_resources if show_unknown else () + + if not children and not unknown: + return line + + items: list[str] = [] + omitted = 0 + + for child in children: + if child.should_be_file and child.status is NodeStatus.PRESENT and not budget.take(): + omitted += 1 + continue + items.append( + _html_node( + child, + is_root=False, + show_schema_ids=show_schema_ids, + show_unmanaged=show_unmanaged, + show_unknown=show_unknown, + budget=budget, + ) + ) + + for resource in unknown: + if isinstance(resource.kind, FileResourceKind) and not budget.take(): + omitted += 1 + continue + items.append(_html_unknown(resource)) + + if omitted: + items.append(f"… {omitted} more {'file' if omitted == 1 else 'files'} not shown") + + listed = "".join(f"
  • {item}
  • " for item in items) + + return ( + f"{line}" + f'
      {listed}
    ' + ) + + +def _html_unknown(resource: ProjectResource) -> str: + """Render one resource the layout does not claim.""" + + return ( + f"? {escape(resource.project_relative_path.name)} " + f'[{escape(resource.kind.value)}]' + ) + + +def _eligible_children(node: ObservedNode, *, show_unmanaged: bool) -> tuple[ObservedNode, ...]: + """The node's schema children a rendering may show: known-unmanaged ones only when asked.""" + + return tuple( + child + for child in node.schema_children + if show_unmanaged or child.management != ResourceManagement.KNOWN_UNMANAGED + ) + + +def _compact_children( + children: tuple[ObservedNode, ...], + *, + maximum: int | None, +) -> tuple[tuple[ObservedNode, ...], int]: + """Limit repetitive leaf nodes while preserving structural nodes. + + Returns: + A tuple containing the visible children and the number of omitted + leaf nodes. + """ + + if maximum is None: + return children, 0 + + structural = tuple(child for child in children if child.schema_children or child.unclaimed_resources) + + leaves = tuple(child for child in children if not child.schema_children and not child.unclaimed_resources) + + visible_leaves = leaves[:maximum] + omitted_count = len(leaves) - len(visible_leaves) + + return ( + structural + visible_leaves, + omitted_count, + ) diff --git a/tests/project/visualization/test_findings.py b/tests/project/visualization/test_findings.py new file mode 100644 index 0000000..6fdcd64 --- /dev/null +++ b/tests/project/visualization/test_findings.py @@ -0,0 +1,183 @@ +from __future__ import annotations + +from pathlib import Path + +import pytest +from pydantic import BaseModel + +from dlc_octopus.schemas.base.finding_codes import ConfigFindingCode, StructureFindingCode, iter_finding_codes +from dlc_octopus.schemas.base.findings import Finding, Reach +from dlc_octopus.visualization import render_finding, render_finding_catalogue, render_findings_markdown + +NO_KEYPOINTS = "The config loads but declares no keypoints." +SEP = chr(0x203A) # between a file and a field in Markdown + + +def _no_keypoints(root: Path) -> Finding: + return Finding( + code=ConfigFindingCode.CONFIG_NO_KEYPOINTS, + schema_id="dlc.project.config", + reach=Reach.ONE_PER_PROJECT, + path=root / "config.yaml", + field_location=("bodyparts",), + evidence={"multianimal_project": False, "declared": {"bodyparts": []}}, + ) + + +def _moved(root: Path) -> Finding: + return Finding( + code=ConfigFindingCode.CONFIG_PROJECT_PATH_MISMATCH, + schema_id="dlc.project.config", + reach=Reach.ONE_PER_PROJECT, + path=root / "config.yaml", + field_location=("project_path",), + evidence={ + "declared_project_path": "/old/place", + "observed_project_root": str(root), + "declared_path_probe": "missing", + "error_type": None, + "error_message": None, + }, + ) + + +def _unreadable(instance: tuple[str, ...], **evidence: str) -> Finding: + code = StructureFindingCode.PROJECT_NODE_UNREADABLE + return Finding( + code=code, + schema_id="dlc.labeled_data.dataset", + reach=Reach.ONE_OF, + instance=instance, + evidence={**dict.fromkeys(code.evidence_keys, "x"), **evidence}, + ) + + +def test_text_puts_the_location_first_then_the_description_and_code_then_evidence(tmp_path: Path) -> None: + assert render_finding(_no_keypoints(tmp_path), project_root=tmp_path) == ( + "WARNING config.yaml:bodyparts\n" + f" {NO_KEYPOINTS} [CONFIG_NO_KEYPOINTS]\n" + " multianimal_project: False\n" + " declared: {'bodyparts': []}" + ) + + +def test_compact_is_one_line(tmp_path: Path) -> None: + assert render_finding(_no_keypoints(tmp_path), project_root=tmp_path, style="compact") == ( + f"WARNING CONFIG_NO_KEYPOINTS config.yaml:bodyparts: {NO_KEYPOINTS} " + "(multianimal_project=False, declared={'bodyparts': []})" + ) + + +def test_markdown_renders_one_finding(tmp_path: Path) -> None: + assert render_finding(_no_keypoints(tmp_path), project_root=tmp_path, style="markdown") == ( + f"**WARNING** `config.yaml` {SEP} `bodyparts`: {NO_KEYPOINTS} `CONFIG_NO_KEYPOINTS`\n" + "- `multianimal_project`: `False`\n" + "- `declared`: `{'bodyparts': []}`" + ) + + +def test_the_location_falls_back_from_path_to_instance_to_layout_node(tmp_path: Path) -> None: + outside = _no_keypoints(Path("/elsewhere")) + nowhere = Finding( + code=ConfigFindingCode.CONFIG_NO_KEYPOINTS, + schema_id="dlc.project.config", + reach=Reach.ONE_PER_PROJECT, + evidence={"multianimal_project": False, "declared": {}}, + ) + + def first_line(finding: Finding) -> str: + return render_finding(finding, project_root=tmp_path, style="compact").split(": ")[0] + + assert first_line(outside) == f"WARNING CONFIG_NO_KEYPOINTS {Path('/elsewhere/config.yaml')}:bodyparts" + assert first_line(_unreadable(("labeled-data", "mouse1"))).endswith(" labeled-data/mouse1") + assert first_line(nowhere) == "WARNING CONFIG_NO_KEYPOINTS dlc.project.config" + + +def test_an_unknown_style_is_refused(tmp_path: Path) -> None: + with pytest.raises(ValueError, match="Unknown finding style"): + render_finding(_no_keypoints(tmp_path), style="html") # type: ignore[arg-type] + + +def test_a_markdown_list_tallies_severities_and_folds_the_evidence(tmp_path: Path) -> None: + rendered = render_findings_markdown([_no_keypoints(tmp_path), _moved(tmp_path)], project_root=tmp_path) + + assert rendered.splitlines()[:5] == [ + "**2 findings** · 1 warning · 1 note", + "", + "| Severity | Where | What | Code |", + "|---|---|---|---|", + f"| WARNING | `config.yaml` {SEP} `bodyparts` | {NO_KEYPOINTS} | `CONFIG_NO_KEYPOINTS` |", + ] + assert "
    Evidence" in rendered + assert render_findings_markdown([]) == "No findings." + + +def test_a_markdown_list_redacts_the_project_root_unless_asked_not_to(tmp_path: Path) -> None: + redacted = render_findings_markdown([_moved(tmp_path)], project_root=tmp_path) + kept = render_findings_markdown([_moved(tmp_path)], project_root=tmp_path, redact_root=False) + + assert str(tmp_path) not in redacted + assert "`observed_project_root`: ``" in redacted + assert str(tmp_path) in kept # control: the root is in the evidence to begin with + + +def test_markdown_escapes_what_would_break_a_table_or_a_code_span() -> None: + finding = _unreadable(("labeled-data", "a|b"), error_message="unexpected `token`") + + rendered = render_findings_markdown([finding]) + + assert "| `labeled-data/a\\|b` |" in rendered + assert "`` unexpected `token` ``" in rendered + + +def test_repr_str_and_serialization_stay_pydantics(tmp_path: Path) -> None: + finding = _no_keypoints(tmp_path) + + assert (type(finding).__repr__, type(finding).__str__) == (BaseModel.__repr__, BaseModel.__str__) + assert repr(finding).startswith("Finding(code=") + assert Finding.model_validate_json(finding.model_dump_json()) == finding + + +def test_jupyter_shows_a_finding_as_markdown(tmp_path: Path) -> None: + finding = _no_keypoints(tmp_path) + + assert finding._repr_markdown_() == render_finding(finding, style="markdown") + + +def test_ipython_pretty_prints_findings_alone_and_inside_containers(tmp_path: Path) -> None: + pretty = pytest.importorskip("IPython.lib.pretty").pretty + finding = _no_keypoints(tmp_path) + + assert pretty(finding) == render_finding(finding) + assert render_finding(finding).splitlines()[1].strip() in pretty((finding, _moved(tmp_path))) + + +def test_the_catalogue_lists_every_code_once_under_its_category() -> None: + codes = iter_finding_codes() + categories = list(dict.fromkeys(type(code) for code in codes)) + rendered = render_finding_catalogue() + sections = rendered.split("\n\n") + + assert [section.split(":")[0] for section in sections] == [ + "Structure", + "Config", + "Configured video", + "Fingerprint", + "Labeled data", + ] + for code in codes: + assert rendered.count(f" {code.value} ") == 1 + assert f" {code.value} " in sections[categories.index(type(code))] + + +def test_the_markdown_catalogue_has_one_table_per_category() -> None: + rendered = render_finding_catalogue(style="markdown") + + assert rendered.count("|---|---|---|") == len({type(code) for code in iter_finding_codes()}) + assert "**Configured video**: Findings about video paths declared in `config.yaml`." in rendered + assert "``" not in rendered + + +def test_an_unknown_catalogue_style_is_refused() -> None: + with pytest.raises(ValueError, match="'compact'"): + render_finding_catalogue(style="compact") # type: ignore[arg-type] diff --git a/tests/project/visualization/test_tree.py b/tests/project/visualization/test_tree.py new file mode 100644 index 0000000..7a08493 --- /dev/null +++ b/tests/project/visualization/test_tree.py @@ -0,0 +1,210 @@ +from pathlib import Path + +import pytest + +from dlc_octopus.api import inspect_project +from dlc_octopus.schemas.base.observations import ObservedNode +from dlc_octopus.visualization import render_project_tree, render_project_tree_html + + +def test_render_tree_shows_project_structure(valid_project: Path) -> None: + videos = valid_project / "videos" + (videos / "session-01.mp4").touch() + + snapshot = inspect_project(valid_project) + rendered = snapshot.render_tree() + + assert "project_root" in rendered + assert "config.yaml" in rendered + assert "videos" in rendered + assert "session-01.mp4" in rendered + assert "[source_video, present]" in rendered + + +def test_render_tree_shows_missing_fixed_children( + valid_project: Path, +) -> None: + (valid_project / "videos").rmdir() + (valid_project / "labeled-data").rmdir() + rendered = inspect_project(valid_project).render_tree() + + assert "✗ videos [videos_directory, missing]" in rendered + assert "✗ labeled-data [labeled_data_directory, missing]" in rendered + + +def test_render_tree_shows_unknown_resources( + valid_project: Path, +) -> None: + videos = valid_project / "videos" + (videos / "notes.txt").write_text( + "notes", + encoding="utf-8", + ) + + rendered = inspect_project(valid_project).render_tree() + + assert "? notes.txt [unknown_file]" in rendered + + +def test_render_tree_can_hide_unknown_resources( + valid_project: Path, +) -> None: + videos = valid_project / "videos" + + (videos / "notes.txt").write_text( + "notes", + encoding="utf-8", + ) + + rendered = inspect_project(valid_project).render_tree( + show_unknown=False, + ) + + assert "notes.txt" not in rendered + + +def test_render_tree_can_show_schema_ids( + valid_project: Path, +) -> None: + rendered = inspect_project(valid_project).render_tree( + show_schema_ids=True, + ) + + assert "dlc.project" in rendered + assert "dlc.project.config" in rendered + + +def test_render_tree_reports_omitted_leaf_children( + tmp_path: Path, +) -> None: + videos = tmp_path / "videos" + videos.mkdir() + + for index in range(5): + (videos / f"session-{index:02d}.mp4").touch() + + rendered = inspect_project(tmp_path).render_tree( + max_children_per_kind=2, + ) + + assert "session-00.mp4" in rendered + assert "session-01.mp4" in rendered + assert "session-02.mp4" not in rendered + assert "3 additional children omitted" in rendered + + +def test_render_tree_without_child_limit( + tmp_path: Path, +) -> None: + videos = tmp_path / "videos" + videos.mkdir() + + for index in range(3): + (videos / f"session-{index:02d}.mp4").touch() + + rendered = inspect_project(tmp_path).render_tree( + max_children_per_kind=None, + ) + + assert "session-00.mp4" in rendered + assert "session-01.mp4" in rendered + assert "session-02.mp4" in rendered + assert "additional children omitted" not in rendered + + +def _project_with_videos(root: Path, *names: str) -> ObservedNode: + videos = root / "videos" + videos.mkdir() + for name in names: + (videos / name).touch() + return inspect_project(root).project + + +def test_html_tree_lists_directories_as_collapsible_details(tmp_path: Path) -> None: + html = render_project_tree_html(_project_with_videos(tmp_path, "session-00.mp4")) + + assert html.count("
    ") == 1 # the project root + assert "
    " in html # control: other directories start closed + assert "session-00.mp4" in html + assert "[source_video, present]" in html + + +def test_html_tree_caps_the_files_it_lists_and_counts_the_rest(tmp_path: Path) -> None: + project = _project_with_videos(tmp_path, *(f"session-{i:02d}.mp4" for i in range(5))) + + capped = render_project_tree_html(project, max_files=0) + uncapped = render_project_tree_html(project, max_files=None) + + assert "session-" not in capped + assert "… 5 more files not shown" in capped + assert all(f"session-{i:02d}.mp4" in uncapped for i in range(5)) + assert "not shown" not in uncapped + + +def test_html_tree_spends_the_cap_across_directories(tmp_path: Path) -> None: + project = _project_with_videos(tmp_path, *(f"session-{i:02d}.mp4" for i in range(5))) + + html = render_project_tree_html(project, max_files=2) + + assert sum(f"session-{i:02d}.mp4" in html for i in range(5)) == 2 + assert "… 3 more files not shown" in html + + +def test_html_tree_counts_unclaimed_files_towards_the_cap_only_when_listing_them(tmp_path: Path) -> None: + videos = tmp_path / "videos" + videos.mkdir() + (videos / "session-00.mp4").touch() + (videos / "notes.txt").write_text("notes", encoding="utf-8") + project = inspect_project(tmp_path).project + + assert "… 1 more file not shown" in render_project_tree_html(project, max_files=1) + assert "not shown" not in render_project_tree_html(project, max_files=1, show_unknown=False) + + +def test_html_tree_escapes_names(tmp_path: Path) -> None: + html = render_project_tree_html(_project_with_videos(tmp_path, "a&b.mp4")) + + assert "a&b.mp4" in html + assert "a&b.mp4" not in html + + +def test_html_tree_shows_unknown_resources_unless_asked_not_to(tmp_path: Path) -> None: + videos = tmp_path / "videos" + videos.mkdir() + (videos / "notes.txt").write_text("notes", encoding="utf-8") + project = inspect_project(tmp_path).project + + assert "? notes.txt" in render_project_tree_html(project) + assert "notes.txt" not in render_project_tree_html(project, show_unknown=False) + + +def test_html_tree_refuses_a_negative_cap(tmp_path: Path) -> None: + with pytest.raises(ValueError, match="max_files"): + render_project_tree_html(_project_with_videos(tmp_path), max_files=-1) + + +def test_an_observed_project_displays_as_its_tree(tmp_path: Path) -> None: + project = _project_with_videos(tmp_path, "session-00.mp4") + + class Printer: + text = "" + + def text(self, value: str) -> None: # noqa: F811 - records what IPython would print + Printer.text = value + + printer = Printer() + project._repr_pretty_(printer, cycle=False) + + assert project._repr_html_() == render_project_tree_html(project) + assert Printer.text == render_project_tree(project) + + +def test_a_node_displayed_alone_is_named_by_its_project_relative_path(tmp_path: Path) -> None: + project = _project_with_videos(tmp_path, "session-00.mp4", "session-01.mp4") + (videos,) = (child for child in project.schema_children if child.project_relative_path == Path("videos")) + first, second = videos.schema_children + + assert render_project_tree(first).endswith("videos/session-00.mp4 [source_video, present]") + assert render_project_tree(first) != render_project_tree(second) + assert "videos/session-00.mp4 " in render_project_tree_html(first) + assert render_project_tree(project).splitlines()[0].endswith("project_root [project_root, present]") # control From 1117846bc3b770f9ba80526c9399976b630d91c2 Mon Sep 17 00:00:00 2001 From: Cyril Achard Date: Thu, 26 Nov 2026 15:35:17 +0100 Subject: [PATCH 2/2] Adapt findings and tree rendering to dlccore - Rename the packages to dlccore.project and add the dlccore license header - Restore the display hooks of Finding and ObservedNode, and ProjectSnapshot.render_tree, which render through this package - Export findings and tree rendering only; report and capabilities follow with their PR - Name the project layer, not Octopus, in a docstring; the tree's HTML class stays dlc-octopus-tree --- dlccore/project/schemas/base/findings.py | 22 +++++++++---- dlccore/project/schemas/base/observations.py | 26 ++++++++++----- dlccore/project/schemas/snapshots.py | 34 +++++++++++++------- dlccore/project/visualization/__init__.py | 15 ++++++--- dlccore/project/visualization/findings.py | 17 ++++++++-- dlccore/project/visualization/tree.py | 16 +++++++-- tests/project/visualization/test_findings.py | 17 ++++++++-- tests/project/visualization/test_tree.py | 17 ++++++++-- 8 files changed, 122 insertions(+), 42 deletions(-) diff --git a/dlccore/project/schemas/base/findings.py b/dlccore/project/schemas/base/findings.py index cf651aa..d4b8649 100644 --- a/dlccore/project/schemas/base/findings.py +++ b/dlccore/project/schemas/base/findings.py @@ -1,4 +1,14 @@ -# schemas/base/findings.py +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + """Simple diagnostic facts generated from walking through the project structure. These are the main enablers for downstream reporting, consumption by GUI/CLI/LLM agents, @@ -15,8 +25,8 @@ from pydantic import Field, JsonValue, model_validator from typing_extensions import Self -from dlc_octopus.schemas.base.core import FrozenModel, LayoutInstance, SchemaId -from dlc_octopus.schemas.base.finding_codes import FindingCode, Severity, finding_code +from dlccore.project.schemas.base.core import FrozenModel, LayoutInstance, SchemaId +from dlccore.project.schemas.base.finding_codes import FindingCode, Severity, finding_code if TYPE_CHECKING: from IPython.lib.pretty import RepresentationPrinter @@ -98,12 +108,12 @@ def _check_reach(self) -> Self: # Display hooks only IPython and Jupyter call; repr, str and serialization stay pydantic's. # Imported on call so that schemas never load visualization. - def _repr_pretty_(self, printer: RepresentationPrinter, cycle: bool) -> None: # noqa: FBT001 - IPython's signature - from dlc_octopus.visualization.findings import render_finding + def _repr_pretty_(self, printer: RepresentationPrinter, cycle: bool) -> None: + from dlccore.project.visualization.findings import render_finding printer.text("Finding(...)" if cycle else render_finding(self)) def _repr_markdown_(self) -> str: - from dlc_octopus.visualization.findings import render_finding + from dlccore.project.visualization.findings import render_finding return render_finding(self, style="markdown") diff --git a/dlccore/project/schemas/base/observations.py b/dlccore/project/schemas/base/observations.py index b78bc1b..d335318 100644 --- a/dlccore/project/schemas/base/observations.py +++ b/dlccore/project/schemas/base/observations.py @@ -1,18 +1,28 @@ -# schemas/base/observations.py +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + from __future__ import annotations from enum import Enum from typing import TYPE_CHECKING -from dlc_octopus.schemas.base.core import FrozenModel, ProjectRelativePath, SchemaId -from dlc_octopus.schemas.base.probes import PathProbe -from dlc_octopus.schemas.base.resources import ( +from dlccore.project.schemas.base.core import FrozenModel, ProjectRelativePath, SchemaId +from dlccore.project.schemas.base.probes import PathProbe +from dlccore.project.schemas.base.resources import ( DirectoryResourceKind, FileResourceKind, ProjectResource, ResourceManagement, ) -from dlc_octopus.schemas.base.symlinks import ( +from dlccore.project.schemas.base.symlinks import ( SymlinkObservation, ) @@ -76,13 +86,13 @@ def should_be_directory(self) -> bool: # Display hooks only IPython and Jupyter call; repr, str and serialization stay pydantic's. # Imported on call so that schemas never load visualization. - def _repr_pretty_(self, printer: RepresentationPrinter, cycle: bool) -> None: # noqa: FBT001 - IPython's signature - from dlc_octopus.visualization.tree import render_project_tree + def _repr_pretty_(self, printer: RepresentationPrinter, cycle: bool) -> None: + from dlccore.project.visualization.tree import render_project_tree printer.text("ObservedNode(...)" if cycle else render_project_tree(self)) def _repr_html_(self) -> str: - from dlc_octopus.visualization.tree import render_project_tree_html + from dlccore.project.visualization.tree import render_project_tree_html return render_project_tree_html(self) diff --git a/dlccore/project/schemas/snapshots.py b/dlccore/project/schemas/snapshots.py index 7f2d300..5fe5364 100644 --- a/dlccore/project/schemas/snapshots.py +++ b/dlccore/project/schemas/snapshots.py @@ -1,3 +1,14 @@ +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + from __future__ import annotations from enum import Enum @@ -7,29 +18,28 @@ from pydantic import model_validator from typing_extensions import Self -from dlc_octopus.errors import ConfigUnavailableError -from dlc_octopus.schemas.base.core import FrozenModel -from dlc_octopus.schemas.base.findings import ( +from dlccore.project.errors import ConfigUnavailableError +from dlccore.project.schemas.base.core import FrozenModel +from dlccore.project.schemas.base.findings import ( Finding, Reach, ) -from dlc_octopus.schemas.base.observations import ObservedNode -from dlc_octopus.schemas.base.resources import ( +from dlccore.project.schemas.base.observations import ObservedNode +from dlccore.project.schemas.base.resources import ( ProjectResource, ResourceKind, ) -from dlc_octopus.schemas.base.validation import ValidationCheck -from dlc_octopus.schemas.project_layout.config import ( +from dlccore.project.schemas.base.validation import ValidationCheck +from dlccore.project.schemas.project_layout.config import ( ConfigObservation, FailedConfigObservation, ValidConfigObservation, ) -from dlc_octopus.schemas.utils import flatten_observed_project +from dlccore.project.schemas.utils import flatten_observed_project if TYPE_CHECKING: - from deeplabcut.core.config import ProjectConfig - - from dlc_octopus.validation.results import ValidationResult + from dlccore.config import ProjectConfig + from dlccore.project.validation.results import ValidationResult # 0.x declares the snapshot format unstable: it changes with the vocabulary and carries # no compatibility promise. Bumping is owed once a consumer reads a snapshot back. @@ -173,7 +183,7 @@ def render_tree( ) -> str: """Render a tree view of the project snapshot.""" - from dlc_octopus.visualization import render_project_tree + from dlccore.project.visualization import render_project_tree return render_project_tree( project=self.project, diff --git a/dlccore/project/visualization/__init__.py b/dlccore/project/visualization/__init__.py index 104d5c6..4074afc 100644 --- a/dlccore/project/visualization/__init__.py +++ b/dlccore/project/visualization/__init__.py @@ -1,14 +1,21 @@ -from .capabilities import render_capabilities +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + from .findings import render_finding, render_finding_catalogue, render_findings_markdown -from .report import render_project_report from .tree import render_project_tree, render_project_tree_html __all__ = [ - "render_capabilities", "render_finding", "render_finding_catalogue", "render_findings_markdown", - "render_project_report", "render_project_tree", "render_project_tree_html", ] diff --git a/dlccore/project/visualization/findings.py b/dlccore/project/visualization/findings.py index e65a84b..2da1151 100644 --- a/dlccore/project/visualization/findings.py +++ b/dlccore/project/visualization/findings.py @@ -1,3 +1,14 @@ +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + """Render findings for people: several lines, one line for logs, or Markdown for notebooks and issues.""" from __future__ import annotations @@ -7,8 +18,8 @@ from pathlib import Path from typing import Literal -from dlc_octopus.schemas.base.finding_codes import FindingCode, Severity, iter_finding_codes -from dlc_octopus.schemas.base.findings import Finding +from dlccore.project.schemas.base.finding_codes import FindingCode, Severity, iter_finding_codes +from dlccore.project.schemas.base.findings import Finding FindingStyle = Literal["text", "compact", "markdown"] CatalogueStyle = Literal["text", "markdown"] @@ -65,7 +76,7 @@ def render_finding( def render_finding_catalogue(*, style: CatalogueStyle = "text") -> str: - """Render every finding code Octopus can emit, one section per category, in catalogue order. + """Render every finding code the project layer can emit, one section per category, in catalogue order. Args: style: ``"text"``, or ``"markdown"`` with one table per category. diff --git a/dlccore/project/visualization/tree.py b/dlccore/project/visualization/tree.py index 2d82a8c..9f4f869 100644 --- a/dlccore/project/visualization/tree.py +++ b/dlccore/project/visualization/tree.py @@ -1,14 +1,24 @@ -# dlc_octopus/visualization/tree.py +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + from __future__ import annotations from html import escape from typing import Any -from dlc_octopus.schemas.base.observations import ( +from dlccore.project.schemas.base.observations import ( NodeStatus, ObservedNode, ) -from dlc_octopus.schemas.base.resources import ( +from dlccore.project.schemas.base.resources import ( DirectoryResourceKind, FileResourceKind, ProjectResource, diff --git a/tests/project/visualization/test_findings.py b/tests/project/visualization/test_findings.py index 6fdcd64..cfe38e8 100644 --- a/tests/project/visualization/test_findings.py +++ b/tests/project/visualization/test_findings.py @@ -1,3 +1,14 @@ +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + from __future__ import annotations from pathlib import Path @@ -5,9 +16,9 @@ import pytest from pydantic import BaseModel -from dlc_octopus.schemas.base.finding_codes import ConfigFindingCode, StructureFindingCode, iter_finding_codes -from dlc_octopus.schemas.base.findings import Finding, Reach -from dlc_octopus.visualization import render_finding, render_finding_catalogue, render_findings_markdown +from dlccore.project.schemas.base.finding_codes import ConfigFindingCode, StructureFindingCode, iter_finding_codes +from dlccore.project.schemas.base.findings import Finding, Reach +from dlccore.project.visualization import render_finding, render_finding_catalogue, render_findings_markdown NO_KEYPOINTS = "The config loads but declares no keypoints." SEP = chr(0x203A) # between a file and a field in Markdown diff --git a/tests/project/visualization/test_tree.py b/tests/project/visualization/test_tree.py index 7a08493..150d118 100644 --- a/tests/project/visualization/test_tree.py +++ b/tests/project/visualization/test_tree.py @@ -1,10 +1,21 @@ +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + from pathlib import Path import pytest -from dlc_octopus.api import inspect_project -from dlc_octopus.schemas.base.observations import ObservedNode -from dlc_octopus.visualization import render_project_tree, render_project_tree_html +from dlccore.project.api import inspect_project +from dlccore.project.schemas.base.observations import ObservedNode +from dlccore.project.visualization import render_project_tree, render_project_tree_html def test_render_tree_shows_project_structure(valid_project: Path) -> None: