fix(compiler): support columns_added and columns_removed in processor config (#394) - #943
ManoharPaturi wants to merge 2 commits into
Conversation
… config (NVIDIA-NeMo#394) Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Linked Issue CheckIssue #394 has not been triaged yet. A maintainer needs to review You can continue working on the PR in the meantime. The check will |
|
|
|
||
| def _apply_processor_column_modifications(config: DataDesignerConfig) -> None: | ||
| """Adjusts columns according to columns_added and columns_removed declared by processors.""" | ||
| for processor in config.processors or []: |
There was a problem hiding this comment.
This applies column declarations from every processor before generation, although processor stages are determined by their runtime implementations. If a POST_BATCH or AFTER_GENERATION processor declares an added column, generation-time templates can reference it successfully during validation even though it will not exist until after generation, causing a runtime failure. Likewise, columns declared as removed by a later-stage processor are hidden from validation before that processor actually runs. Restrict these schema changes to PRE_BATCH processors or make the stage part of the configuration contract.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/data-designer-engine/src/data_designer/engine/compiler.py
Line: 29
Comment:
**Processor stages are ignored**
This applies column declarations from every processor before generation, although processor stages are determined by their runtime implementations. If a POST_BATCH or AFTER_GENERATION processor declares an added column, generation-time templates can reference it successfully during validation even though it will not exist until after generation, causing a runtime failure. Likewise, columns declared as removed by a later-stage processor are hidden from validation before that processor actually runs. Restrict these schema changes to PRE_BATCH processors or make the stage part of the configuration contract.
**Knowledge Base Used:**
- [Validation and processing](https://app.greptile.com/nvidia-public-github/-/custom-context/knowledge-base/nvidia-nemo/datadesigner/-/docs/validation-and-processing.md)
- [Workflow compilation and execution](https://app.greptile.com/nvidia-public-github/-/custom-context/knowledge-base/nvidia-nemo/datadesigner/-/docs/workflow-compilation-execution.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| existing_columns = {col.name for col in config.columns} | ||
| for col_name in processor.columns_added: | ||
| if col_name in existing_columns: | ||
| raise InvalidConfigError( | ||
| f"🛑 Processor '{processor.name}' adds column '{col_name}' which collides with an existing column." | ||
| ) | ||
| config.columns.append(SeedDatasetColumnConfig(name=col_name)) |
There was a problem hiding this comment.
Repeated additions bypass collision checks
existing_columns is captured only once before this loop. With columns_added=["state", "state"], both checks pass and two columns named state are appended. Static validation does not reject the duplicate, so execution-graph construction later tries to register state twice and raises ValueError.
| existing_columns = {col.name for col in config.columns} | |
| for col_name in processor.columns_added: | |
| if col_name in existing_columns: | |
| raise InvalidConfigError( | |
| f"🛑 Processor '{processor.name}' adds column '{col_name}' which collides with an existing column." | |
| ) | |
| config.columns.append(SeedDatasetColumnConfig(name=col_name)) | |
| existing_columns = {col.name for col in config.columns} | |
| for col_name in processor.columns_added: | |
| if col_name in existing_columns: | |
| raise InvalidConfigError( | |
| f"🛑 Processor '{processor.name}' adds column '{col_name}' which collides with an existing column." | |
| ) | |
| config.columns.append(SeedDatasetColumnConfig(name=col_name)) | |
| existing_columns.add(col_name) |
Knowledge Base Used: Workflow compilation and execution
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/data-designer-engine/src/data_designer/engine/compiler.py
Line: 45-51
Comment:
**Repeated additions bypass collision checks**
`existing_columns` is captured only once before this loop. With `columns_added=["state", "state"]`, both checks pass and two columns named `state` are appended. Static validation does not reject the duplicate, so execution-graph construction later tries to register `state` twice and raises `ValueError`.
```suggestion
existing_columns = {col.name for col in config.columns}
for col_name in processor.columns_added:
if col_name in existing_columns:
raise InvalidConfigError(
f"🛑 Processor '{processor.name}' adds column '{col_name}' which collides with an existing column."
)
config.columns.append(SeedDatasetColumnConfig(name=col_name))
existing_columns.add(col_name)
```
**Knowledge Base Used:** [Workflow compilation and execution](https://app.greptile.com/nvidia-public-github/-/custom-context/knowledge-base/nvidia-nemo/datadesigner/-/docs/workflow-compilation-execution.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Description
Fixes #394.
Jinja2
{{ }}references in downstream prompt templates fail when referencing columns created byPRE_BATCHprocessors because the compiler previously validated templates against the raw seed dataset schema, which did not include columns added or removed at runtime by processors.This PR adds:
columns_addedandcolumns_removedfields toProcessorConfigwith default empty lists._apply_processor_column_modificationsincompile_data_designer_configwhich:processor.columns_removedfromconfig.columns(raising anInvalidConfigErrorif a non-existent column is targeted for removal).SeedDatasetColumnConfigentries for columns declared inprocessor.columns_addedtoconfig.columns(validating that a seed dataset is configured and raisingInvalidConfigErroron collisions).packages/data-designer-config/tests/config/test_processors.pyandpackages/data-designer-engine/tests/engine/test_compiler.py.Testing
uv run pytest packages/data-designer-config/tests(659 passed)uv run pytest packages/data-designer-engine/tests(2,262 passed)uv run ruff checkanduv run ruff format --check(all checks passed)