Skip to content

feat: Introduce new summary section for data metrics#47

Draft
Moritz Potthoff (MoritzPotthoffQC) wants to merge 8 commits into
mainfrom
data-inspection-section
Draft

feat: Introduce new summary section for data metrics#47
Moritz Potthoff (MoritzPotthoffQC) wants to merge 8 commits into
mainfrom
data-inspection-section

Conversation

@MoritzPotthoffQC

@MoritzPotthoffQC Moritz Potthoff (MoritzPotthoffQC) commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Motivation

See this discussion: We want to display data metrics in their own section in the summary.

Changes

  • Add differentiation for the metrics
  • Add new section Data Inspection that gets all the data metrics

@github-actions github-actions Bot added the enhancement New feature or request label Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.16981% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.64%. Comparing base (01cef28) to head (6c868d6).

Files with missing lines Patch % Lines
diffly/comparison.py 88.88% 1 Missing ⚠️
diffly/metrics/change.py 80.00% 1 Missing ⚠️
diffly/summary.py 98.48% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main      #47      +/-   ##
===========================================
- Coverage   100.00%   99.64%   -0.36%     
===========================================
  Files           14       14              
  Lines         1052     1117      +65     
===========================================
+ Hits          1052     1113      +61     
- Misses           0        4       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Diffly’s summary reporting to distinguish change metrics (computed over deltas) from data inspection metrics (describing left/right datasets), and renders the latter in a new dedicated “Data Inspection” section while also separating them in the JSON schema.

Changes:

  • Add Metric.kind ("change" vs "data") and mark the Null% preset as a "data" metric.
  • Split per-column metric outputs into metrics vs data_metrics in the summary JSON, and render "data" metrics in a new “Data Inspection” section.
  • Update summary tests and regenerate pretty-output fixtures to reflect the new section/layout.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
diffly/metrics/_common.py Adds Metric.kind to classify metrics by rendering section.
diffly/metrics/data.py Marks Null% preset as a "data" metric.
diffly/summary.py Routes metric labels into change vs data lists; adds “Data Inspection” rendering and JSON schema changes.
tests/summary/test_summary.py Adds coverage for metrics vs data_metrics JSON routing; updates expected JSON shape.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_True_slim_True_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_True_slim_False_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_True_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_False_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_True_slim_True_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_True_slim_False_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_True_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_True_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_False_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_True_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_False_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_True_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_False_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread diffly/summary.py

@EgeKaraismailogluQC EgeKaraismailogluQC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Moritz Potthoff (@MoritzPotthoffQC)! In general I am happy with the layout. I added a few comments. In addition to those, I think it would be nice to have at least one summary fixture where we render two or more data metrics rather than just one, just to see what that looks like (maybe I missed it?).

Comment thread diffly/summary.py Outdated
@@ -716,6 +749,7 @@ class SummaryDataColumn:
n_total_changes: int
changes: list[SummaryDataColumnChange] | None
metrics: dict[str, Any] | None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Suggested change
metrics: dict[str, Any] | None
change_metrics: dict[str, Any] | None

Comment thread diffly/metrics/_common.py Outdated
Comment on lines +18 to +20
``kind`` selects the summary section the metric is rendered in: ``"change"`` metrics
appear as columns in the "Columns" table, while ``"data"`` metrics get their own
"Data Inspection" section.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be nicer to also explain the semantic difference between change metrics and data metrics. Right now, it sounds like the only difference is where it gets rendered, but the underlying reason for why we present these two options is not clear.

Comment thread diffly/metrics/_common.py Outdated

fn: MetricFn
selector: cs.Selector
kind: Literal["change", "data"] = "change"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be good to not provide a default here to force the user to think about what kind of metric they implemented. Wdyt?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, nothing prevents me from "registering" a change metric as a data metric and vice versa. Going a step further, I wish there was a way to infer kind from the type of fn automatically. Right now that does not work of course since both change metrics and data metrics are the same type. Something along these lines:

DataMetricFn = Callable[[pl.Expr], pl.Expr]

and then rewrite:

def null_fraction_change(col: pl.Expr) -> pl.Expr:
	return col.is_null().mean()

class Metric:
	fn: ChangeMetricFn | DataMetricFn

	#(property)
	def kind(self) -> str:
		return "data" if isinstance(DataMetricFn, self.fn) else "change"

Metric would then also need to wrap .fn if it is a DataMetricFn to make it have the same interface. Could you follow my idea? Wdyt?

Comment thread diffly/metrics/data.py Outdated
from ._common import Metric, MetricFn


def _make_data_metric(fn: MetricFn, selector: cs.Selector = cs.all()) -> Metric:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this partial method does not add a lot of value, so it could be dropped. We could just add the kind parameter below in DEFAULT_DATA_METRICS. Wdyt?

@MoritzPotthoffQC
Moritz Potthoff (MoritzPotthoffQC) marked this pull request as draft July 22, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants