Skip to content

feat(datasets): add DatasetProfile contract#650

Open
albcui wants to merge 1 commit into
mainfrom
albcui/dataset-profile-contract
Open

feat(datasets): add DatasetProfile contract#650
albcui wants to merge 1 commit into
mainfrom
albcui/dataset-profile-contract

Conversation

@albcui

@albcui albcui commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Introduced a standardized, versioned dataset profiling contract that captures dataset metadata, per-partition feature schemas, column statistics, sampling details, and objective classification (including evidence when available).
    • Profiles serialize/deserialize losslessly and are forward-compatible with unknown fields and vocabulary values.
  • Tests
    • Added fixture-driven contract validation covering multiple dataset types, nested semantic-role reachability, optional verifiability/evidence, and correct quantiles/message statistics wiring.

@albcui albcui marked this pull request as ready for review July 13, 2026 16:13
@albcui albcui requested review from a team as code owners July 13, 2026 16:13
@github-actions github-actions Bot added the feat label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d82dee42-ac9d-44bf-aab0-ff3ae66527dc

📥 Commits

Reviewing files that changed from the base of the PR and between 6c3fb39 and adc3f32.

📒 Files selected for processing (2)
  • packages/nemo_platform_plugin/src/nemo_platform_plugin/files/dataset_profile.py
  • packages/nemo_platform_plugin/tests/files/test_dataset_profile.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/nemo_platform_plugin/tests/files/test_dataset_profile.py
  • packages/nemo_platform_plugin/src/nemo_platform_plugin/files/dataset_profile.py

📝 Walkthrough

Walkthrough

Adds a Pydantic stored contract for dataset profiles, including classification, recursive schemas, statistics, partition metadata, sampling, and serialization. Tests cover YAML fixtures, JSON round trips, nested semantic roles, open vocabularies, forward compatibility, and message statistics.

Changes

Dataset profile contract

Layer / File(s) Summary
Classification and statistics models
packages/nemo_platform_plugin/src/nemo_platform_plugin/files/dataset_profile.py
Defines evidence, classification, recursive feature-schema, and column-statistics models.
Profile containers and envelope
packages/nemo_platform_plugin/src/nemo_platform_plugin/files/dataset_profile.py
Adds file, split, partition, sampling, and root dataset profile models, then rebuilds the recursive schema model.
Fixtures and contract validation
packages/nemo_platform_plugin/tests/files/test_dataset_profile.py
Adds representative YAML profiles and tests serialization, fixture structure, nested semantic roles, vocabulary handling, unknown fields, and statistics construction.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding the DatasetProfile contract.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch albcui/dataset-profile-contract

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
packages/nemo_platform_plugin/src/nemo_platform_plugin/files/dataset_profile.py (1)

32-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Scope the forward reference instead of stringifying the whole module.

from __future__ import annotations makes every annotation in the file a string, which conflicts with the "prefer concrete type hints over string-based type hints" guideline — even though only the two self-referencing FeatureSchema.fields/items fields actually need it. Pydantic v2 resolves a quoted self-reference on just those fields without the future import (model_rebuild() still required either way).

♻️ Narrow the forward reference to the two self-referencing fields
-from __future__ import annotations
-
 from datetime import datetime
@@
-    fields: list[FeatureSchema] | None = Field(default=None, description="dtype == struct: named child fields.")
-    items: FeatureSchema | None = Field(default=None, description="dtype in {list, messages}: element schema.")
+    fields: list["FeatureSchema"] | None = Field(default=None, description="dtype == struct: named child fields.")
+    items: "FeatureSchema" | None = Field(default=None, description="dtype in {list, messages}: element schema.")

As per coding guidelines, **/*.py should "prefer concrete type hints over string-based type hints," and the plugin-scoped rule reiterates the same preference.

Also applies to: 189-190, 361-361

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/nemo_platform_plugin/src/nemo_platform_plugin/files/dataset_profile.py`
at line 32, Remove the module-wide `from __future__ import annotations` in
`dataset_profile.py` and scope forward references only to the self-referencing
`FeatureSchema.fields` and `FeatureSchema.items` annotations using quoted types.
Preserve the existing `model_rebuild()` behavior and keep all unrelated
annotations concrete.

Source: Coding guidelines

packages/nemo_platform_plugin/tests/files/test_dataset_profile.py (1)

171-206: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

_build_profile doesn't actually exercise TextStats/NumericStats.

ColumnStats(text=None) and ColumnStats(numeric=None) are no-ops (both default to None already), so despite the docstring claiming to exercise "every model in the contract," TextStats/NumericStats/Quantiles are never directly constructed here — only reached indirectly via the YAML fixtures elsewhere in the file.

♻️ Populate real stat objects
                 stats={
-                    "prompt": ColumnStats(text=None),
-                    "response": ColumnStats(numeric=None),
+                    "prompt": ColumnStats(text=TextStats(chars=Quantiles(p50=10, p95=40, p99=60, max=100))),
+                    "response": ColumnStats(numeric=NumericStats(min=0.0, max=1.0, mean=0.5)),
                 },

(Requires importing TextStats/NumericStats alongside the existing imports.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nemo_platform_plugin/tests/files/test_dataset_profile.py` around
lines 171 - 206, Update _build_profile to construct and assign actual TextStats
and NumericStats instances in the prompt and response ColumnStats entries,
including a populated Quantiles instance where required by those models. Add the
corresponding TextStats and NumericStats imports alongside the existing model
imports so the hand-built profile directly exercises these contract models.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@packages/nemo_platform_plugin/src/nemo_platform_plugin/files/dataset_profile.py`:
- Line 32: Remove the module-wide `from __future__ import annotations` in
`dataset_profile.py` and scope forward references only to the self-referencing
`FeatureSchema.fields` and `FeatureSchema.items` annotations using quoted types.
Preserve the existing `model_rebuild()` behavior and keep all unrelated
annotations concrete.

In `@packages/nemo_platform_plugin/tests/files/test_dataset_profile.py`:
- Around line 171-206: Update _build_profile to construct and assign actual
TextStats and NumericStats instances in the prompt and response ColumnStats
entries, including a populated Quantiles instance where required by those
models. Add the corresponding TextStats and NumericStats imports alongside the
existing model imports so the hand-built profile directly exercises these
contract models.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d067794a-2f37-457d-ae8d-ab85c5354104

📥 Commits

Reviewing files that changed from the base of the PR and between 275c8cd and 6c3fb39.

📒 Files selected for processing (2)
  • packages/nemo_platform_plugin/src/nemo_platform_plugin/files/dataset_profile.py
  • packages/nemo_platform_plugin/tests/files/test_dataset_profile.py

@albcui albcui force-pushed the albcui/dataset-profile-contract branch from 6c3fb39 to adc3f32 Compare July 13, 2026 16:28
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 23939/31105 77.0% 61.7%
Integration Tests 13905/29754 46.7% 19.6%

@albcui albcui requested a review from soluwalana July 13, 2026 21:20
Signed-off-by: Albert Cui <albcui@nvidia.com>
@albcui albcui force-pushed the albcui/dataset-profile-contract branch from adc3f32 to f571cbb Compare July 14, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant