Skip to content

Add semantic_model_diff_editor: interactive diff & cherry-pick UI for semantic models - #1233

Draft
m-kovalsky with Copilot wants to merge 4 commits into
mainfrom
copilot/create-interactive-ui-for-diff-tool
Draft

Add semantic_model_diff_editor: interactive diff & cherry-pick UI for semantic models#1233
m-kovalsky with Copilot wants to merge 4 commits into
mainfrom
copilot/create-interactive-ui-for-diff-tool

Conversation

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor

Adds an interactive UI (in the style of perspective_editor) for diffing two Fabric / Power BI semantic models and selectively promoting changes between them — a lightweight CI/CD workflow for semantic modelers.

from sempy_labs.semantic_model import semantic_model_diff_editor

semantic_model_diff_editor(
    source_workspace="Dev",   source_dataset="Sales",
    target_workspace="Prod",  target_dataset="Sales",
    format="TMDL",   # or "BIM" / "TMSL"
)

UI (src/sempy_labs/semantic_model/_diff_editor.py)

  • Independent workspace + dataset pickers for source and target, with a swap button.
  • Format segmented control: TMDL (per-file .tmdl) vs BIM (single model.bim).
  • Color-coded file list (added / removed / modified / unchanged) with per-file +/- counts and summary stat chips.
  • Click-to-expand inline unified diff per file; per-hunk checkboxes plus a tri-state aggregate per file.
  • Apply selected → Target / Apply selected → Source (confirmation prompt) — destination is rewritten via the Fabric updateDefinition API; non-text parts (e.g. definition.pbidataset) are echoed back unchanged. Both sides auto-refetch and re-diff after apply.
  • Bells & whistles: filter, expand/collapse all, select all/none, reload, download .patch, dark/light theme toggle.

Diff & apply pipeline

  • Diff computed server-side per file via difflib.SequenceMatcher.get_opcodes(), producing line-level hunks tagged equal / replace / insert / delete.
  • Apply semantics: for each modified file, kept hunks come from the destination and selected hunks are replaced with the other side's lines. Added/removed files are propagated/dropped according to direction.

Tests (tests/test_semantic_model_diff_editor.py, 73 tests)

  • Functionality — pure helpers (_split_lines, _join_lines, _compute_file_hunks, _compute_diff, _apply_hunks_to_lines) hoisted to module level and unit-tested for empty/identical/insert/delete/replace cases, file-status classification, sort order, and select-none/all/partial cherry-pick in both directions.
  • Design — public surface (signature, defaults, numpydoc docstring incl. Service-Principal note, package export, format validation, BIM alias); embedded CSS (scoped .slls-de-* prefix, light + dark themes, required selectors, semantic color tokens); embedded JS (anywidget ESM shape, every traitlet referenced from JS, every pending_action emitted, expected UI labels, escapeHtml present).
  • tests/conftest.py — puts src/ on sys.path and stubs sempy._utils._log so the suite runs without semantic-link-sempy installed.

Copilot AI and others added 3 commits May 17, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants