Subcategory columns cannot use a category parent with numeric values

オープン
#1,203 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
data

調査の方向性

Start with DataSchema.validate_subcategory_columns_if_present in engine/sampling_gen/schema.py and the lookup in SubcategorySampler.inject_data_column in engine/sampling_gen/data_sources/sources.py. Read the existing cases in tests/engine/sampling_gen/test_schema.py and test_generator.py, then add regression coverage for numeric parent values and their string keys. Done when numeric values generate the expected pairs and missing or extra keys still fail validation.

索引モデルが issue の本文から書いたものです。

説明

Priority Level

Medium (Annoying but has workaround)

Describe the bug

A category sampler accepts numeric values (CategorySamplerParams.values: list[str | int | float]), but a subcategory column can never use such a category as its parent. SubcategorySamplerParams.values is dict[str, list[...]], so the keys have to be strings (integer keys are rejected by Pydantic, and JSON/YAML configs always have string keys). The engine then compares those string keys to the raw category values:

  • DataSchema.validate_subcategory_columns_if_present (engine/sampling_gen/schema.py) builds cat_vals = set(cat.params.values) and takes the symmetric difference with the subcategory keys, so {1, 2} vs {"1", "2"} always fails.
  • SubcategorySampler.inject_data_column (engine/sampling_gen/data_sources/sources.py) looks up self.params.values[cat_value] with the numeric cell value, which would raise KeyError even if validation passed.

DataDesignerConfigBuilder.build() accepts the config, so the failure only shows up at generation time.

Steps/Code to reproduce bug
import data_designer.config as dd
from data_designer.interface import DataDesigner

builder = dd.DataDesignerConfigBuilder()
builder.add_column(dd.SamplerColumnConfig(name="grade", sampler_type="category", params=dd.CategorySamplerParams(values=[1, 2, 3])))
builder.add_column(
    dd.SamplerColumnConfig(
        name="topic",
        sampler_type="subcategory",
        params=dd.SubcategorySamplerParams(category="grade", values={"1": ["counting"], "2": ["addition"], "3": ["fractions"]}),
    )
)
DataDesigner().preview(builder, num_records=5)

On main (861a082):

data_designer.interface.errors.DataDesignerGenerationError: DatasetGenerationError: Generator failed for column 'grade' during from-scratch generation: 1 validation error for DataSchema
  Value error, Subcategory column 'topic' must have values for each value of its parent category 'grade'. The following values need attention: {1, '1', 2, 3, '2', '3'}

The error lists both 1 and '1', and there is no key type that satisfies it.

Expected behavior

Numeric category values match their string keys (1 -> "1", 0.5 -> "0.5"), so the preview produces grade/topic pairs such as 1 counting, 3 fractions. Missing or extra keys should still be reported as today.

Prior Investigation

Traced the error to DataSchema.validate_subcategory_columns_if_present and the lookup in SubcategorySampler; the existing subcategory tests in tests/engine/sampling_gen/test_schema.py and test_generator.py only use string parent values. Searched open and closed issues and PRs for subcategory, SubcategorySampler and numeric category values; #614 and #628 validate the parent column type but do not touch value matching, and #1201 is an unrelated feature request.

Workaround today is to make the parent values strings, which changes the column dtype.

Proposed fix: compare str(value) of the parent category values (including conditional params) with the subcategory keys in the schema validator, and look up values[str(cat_value)] in SubcategorySampler. String parents behave exactly as before. I have the fix and regression tests ready and can open a PR once this is triaged.

Checklist
  • I reproduced this issue or provided a minimal example
  • I searched the docs/issues myself
主要言語
Python
スター
2.4k
フォーク
258
平均マージ
4日 20分
マージ済み PR(30日)
32

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA-NeMo/DataDesigner のほかの issue

NVIDIA-NeMo/DataDesigner の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。