Skip to content

fix: render degenerate judge histograms instead of raising (#905) - #919

Open
chethanuk wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
chethanuk:fix/issue-905-ship
Open

fix: render degenerate judge histograms instead of raising (#905)#919
chethanuk wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
chethanuk:fix/issue-905-ship

Conversation

@chethanuk

Copy link
Copy Markdown

Summary

DatasetProfilerResults.to_report() raises on four judge-profile shapes that model_validate() accepts, so a schema-valid analysis result cannot be rendered. All four are one crash family on one render path (create_rich_histogram_table and its two callers), so they're fixed together.

Related Issue

Fixes #905
Closes #903

Changes

  • create_rich_histogram_table (config/utils/visualization.py): max(data.values()) raised ValueError on an empty mapping, one line before the existing max_count <= 0 guard that already handled "nothing to draw". Changed to max(data.values(), default=0), and an empty mapping now renders a no data placeholder row instead of an empty table.
  • create_judge_score_summary_table (config/analysis/utils/reporting.py): took a histogram by attribute (histogram.categories), so a MissingValue — which the field is typed to allow — raised AttributeError a frame earlier than the fix above. Parameter widened to CategoricalHistogramData | MissingValue; a MissingValue now builds an empty mapping instead.
  • JudgeScoreProfilerResults.create_report_section (config/analysis/column_profilers.py): indexed self.score_distributions.histograms[score_name] unguarded, while score_distributions is itself typed ... | MissingValue — raising AttributeError when missing and KeyError when a summary names a score the histogram map omits. Both now fall back to MissingValue.CALCULATION_FAILED, which the guard above renders.
  • Not touched: CategoricalHistogramData's list constraints. Adding min_length=1 would make CategoricalDistribution.from_series raise on an empty Series, which _load_stage_analysis catches and turns into None — trading a visible crash for a silently discarded analysis.

Testing

  • Two parametrized tests added, driven through the public to_report() entry point both reporters used. On unmodified main with the tests applied: 5 failed, 58 passedValueError at visualization.py:265, AttributeError at reporting.py:174, AttributeError and KeyError at column_profilers.py:146, matching both issues verbatim.
  • With the fix, same command: 63 passed.
  • uv run --group dev pytest packages/data-designer-config/tests652 passed (main: 644; the +8 is exactly the new cases).
  • uv run --group dev pytest packages/data-designer-engine/tests2257 passed.
  • make check-all-fix clean, tree unmodified.

Checklist

  • Follows commit message conventions
  • Commits are signed off (DCO)
  • Unit regression coverage added

…Mo#905)

DatasetProfilerResults.to_report() raised on four judge-profile shapes that
model_validate() accepts, so a schema-valid analysis result could not be
rendered. create_rich_histogram_table called max() on a bare mapping, so an
empty categorical histogram raised ValueError one line before the existing
max_count <= 0 guard. Its only caller passed a MissingValue straight through
to .categories, and create_report_section indexed
score_distributions.histograms[score_name] unguarded, so a missing
score_distributions or a summary naming a score the histogram map omits
raised AttributeError and KeyError.

Guard all four at the shared points every caller routes through: max() takes
default=0 and empty data renders a placeholder row, the histogram mapping is
built empty for a MissingValue with the parameter widened to
CategoricalHistogramData | MissingValue, and the per-score lookup falls back
to MissingValue.CALCULATION_FAILED.

CategoricalHistogramData's list constraints are left alone: adding
min_length=1 would make CategoricalDistribution.from_series raise on an empty
Series, which _load_stage_analysis catches and turns into None, trading a
visible crash for a silently discarded analysis.

Covered by parametrized tests driven through the public to_report() entry
point both reporters used; they fail on unmodified main with the four
exceptions above.

Fixes NVIDIA-NeMo#905
Closes NVIDIA-NeMo#903

Signed-off-by: ChethanUK <chethanuk@outlook.com>
@chethanuk
chethanuk requested a review from a team as a code owner September 5, 2026 04:51
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Linked Issue Check

Issue #905 has not been triaged yet. A maintainer needs to review
the issue and add the triaged label for this check to pass.

You can continue working on the PR in the meantime. The check will
re-run automatically once the issue is triaged.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text:


I have read the DCO document and I hereby sign the DCO.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot.

@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes judge-profile reports render schema-valid empty or missing histogram states instead of raising exceptions.

  • Normalizes missing score distributions and absent per-score histograms to an empty histogram.
  • Makes histogram rendering safe for empty mappings and displays a “no data” placeholder.
  • Adds regression coverage through the public report API and focused visualization tests.

Confidence Score: 5/5

The PR appears safe to merge and addresses the identified report-rendering failures without introducing a concrete regression.

The changed path consistently converts every supported missing-histogram representation into an empty mapping, while populated and all-zero histograms retain their existing rendering behavior.

Important Files Changed

Filename Overview
packages/data-designer-config/src/data_designer/config/analysis/column_profilers.py Safely resolves missing score distributions and absent per-score histograms before constructing report tables.
packages/data-designer-config/src/data_designer/config/analysis/utils/reporting.py Accepts typed missing histogram values and normalizes them to empty renderable data.
packages/data-designer-config/src/data_designer/config/utils/visualization.py Handles empty mappings without calling max() on an empty sequence and renders a placeholder row.
packages/data-designer-config/tests/config/analysis/test_dataset_profiler_results.py Covers empty, missing, omitted, and populated judge histograms through the public report-writing path.
packages/data-designer-config/tests/config/utils/test_visualization.py Verifies row and bar behavior for empty, all-zero, and populated histogram inputs.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Judge profile results] --> B{Score distributions available?}
    B -- No --> C[MissingValue]
    B -- Yes --> D{Histogram exists for score?}
    D -- No --> C
    D -- Yes --> E[Categorical histogram]
    C --> F[Empty histogram mapping]
    E --> G[Category/count mapping]
    F --> H[Rich histogram table]
    G --> H
    H --> I[Rendered report section]
Loading

Reviews (1): Last reviewed commit: "fix: render degenerate judge histograms ..." | Re-trigger Greptile

@chethanuk

Copy link
Copy Markdown
Author

I have read the DCO document and I hereby sign the DCO.

How do I sign it?

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.

Report generation crashes on empty categorical histograms Judge-score report generation crashes on missing or incomplete score distributions

1 participant