-
Notifications
You must be signed in to change notification settings - Fork 57
refactor: callback-based processor design #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b546082
refactor: processors use callback-based design with multiple stages
andreatgretel 0347798
add edge case handling and tests for processor stages
andreatgretel 8c5296b
remove duplicate processor stage tests
andreatgretel 4ea55c4
refactor processor tests with fixtures and add edge cases
andreatgretel 4663818
extract processor execution to ProcessorRunner class
andreatgretel b25f83b
address PR review feedback on processor refactor
andreatgretel 5074981
reword docs info box about schema availability during generation
andreatgretel 56b29ad
support row-count changes in PRE_BATCH processors
andreatgretel fec7af5
fix preview artifact output and harden processors API
andreatgretel c151550
remove preprocessor stage and rename postprocess to process_after_gen…
andreatgretel cd7031e
address PR review feedback
andreatgretel b6e4155
chunk after-generation output by batch_size
andreatgretel 014ae30
address nabinchha review feedback
andreatgretel a8715dc
move post-batch processing into _run_batch
andreatgretel a61848e
Merge remote-tracking branch 'origin/main' into andreatgretel/feat/pr…
andreatgretel fe55c43
Merge branch 'main' into andreatgretel/feat/processor-plugins
andreatgretel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
packages/data-designer-config/src/data_designer/config/dataset_builders.py
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,11 +12,8 @@ | |
| from typing_extensions import TypeAlias | ||
|
|
||
| from data_designer.config.base import ConfigBase | ||
| from data_designer.config.dataset_builders import BuildStage | ||
| from data_designer.config.errors import InvalidConfigError | ||
|
|
||
| SUPPORTED_STAGES = [BuildStage.POST_BATCH] | ||
|
|
||
|
|
||
| class ProcessorType(str, Enum): | ||
| """Enumeration of available processor types. | ||
|
|
@@ -33,33 +30,22 @@ class ProcessorType(str, Enum): | |
| class ProcessorConfig(ConfigBase, ABC): | ||
| """Abstract base class for all processor configuration types. | ||
|
|
||
| Processors are transformations that run before or after columns are generated. | ||
| They can modify, reshape, or augment the dataset before it's saved. | ||
| Processors are transformations that run at different stages of the generation | ||
| pipeline. They can modify, reshape, or augment the dataset. | ||
|
|
||
| The processor implementation determines which stages it handles by overriding | ||
| the appropriate callback methods (process_before_batch, process_after_batch, process_after_generation). | ||
|
|
||
| Attributes: | ||
| name: Unique name of the processor, used to identify the processor in results | ||
| and to name output artifacts on disk. | ||
| build_stage: The stage at which the processor runs. Currently only `POST_BATCH` | ||
| is supported, meaning processors run after each batch of columns is generated. | ||
| """ | ||
|
|
||
| name: str = Field( | ||
| description="The name of the processor, used to identify the processor in the results and to write the artifacts to disk.", | ||
| ) | ||
| build_stage: BuildStage = Field( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sweet, this is a neat approach! |
||
| default=BuildStage.POST_BATCH, | ||
| description=f"The stage at which the processor will run. Supported stages: {', '.join(SUPPORTED_STAGES)}", | ||
| ) | ||
| processor_type: str | ||
|
|
||
| @field_validator("build_stage") | ||
| def validate_build_stage(cls, v: BuildStage) -> BuildStage: | ||
| if v not in SUPPORTED_STAGES: | ||
| raise ValueError( | ||
| f"Invalid dataset builder stage: {v}. Only these stages are supported: {', '.join(SUPPORTED_STAGES)}" | ||
| ) | ||
| return v | ||
|
|
||
|
|
||
| def get_processor_config_from_kwargs(processor_type: ProcessorType, **kwargs: Any) -> ProcessorConfig: | ||
| """Create a processor configuration from a processor type and keyword arguments. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow in by head dropping columns needs to happen post generation, BUT the key point is that each batch contains the full schema of the dataset. Might be good to have a tip (or something) box that highlights this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an info box to the docs. dropping columns post-batch is probably better than post-generation since we don't need to write dropped columns to disk.