config_builder
config_builder
¶
Builder-pattern configuration layer for Safe Synthesizer.
Provides ConfigBuilder, the base builder that accumulates
per-section configuration objects (training, generation, data, etc.)
via fluent with_* methods before resolving them into a single
SafeSynthesizerParameters.
Classes:
| Name | Description |
|---|---|
ConfigBuilder |
Fluent builder for assembling Safe Synthesizer configuration. |
ConfigBuilder(config=None)
¶
Bases: object
Fluent builder for assembling Safe Synthesizer configuration.
Accumulates per-section configuration objects (data, training,
generation, evaluation, privacy, PII replacement, and time-series)
via with_* methods. Call resolve() (or let
SafeSynthesizer do it) to collapse them into a single
SafeSynthesizerParameters.
Each with_* method accepts an optional typed config object or
a plain dict, plus **kwargs overrides. kwargs always take
precedence over fields in the config/dict. All with_* methods
return self for chaining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SafeSynthesizerParameters | None
|
Optional pre-built parameters. When supplied, the
individual |
None
|
Methods:
| Name | Description |
|---|---|
with_data_source |
Set the data source for synthetic data generation. |
with_data |
Configure data processing settings. |
with_train |
Configure training hyperparameters. |
with_generate |
Configure generation settings. |
with_time_series |
Configure time-series synthesis settings. |
with_differential_privacy |
Configure differential privacy settings. |
with_replace_pii |
Configure PII replacement settings. |
with_evaluate |
Configure evaluation settings. |
resolve |
Finalize configuration and data source. |
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
with_data_source(df_source)
¶
Set the data source for synthetic data generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_source
|
DataSource
|
Training dataset as a pandas DataFrame or a fetchable URL. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with the data source configured. |
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
with_data(config=None, **kwargs)
¶
Configure data processing settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DataParameters | ParamDict | None
|
Data configuration object or dict. |
None
|
**kwargs
|
Field-level overrides (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with data processing settings applied. |
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
with_train(config=None, **kwargs)
¶
Configure training hyperparameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TrainingHyperparams | ParamDict | None
|
Training configuration object or dict. |
None
|
**kwargs
|
Field-level overrides (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with training hyperparameters applied. |
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
with_generate(config=None, **kwargs)
¶
Configure generation settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
GenerateParameters | ParamDict | None
|
Generation configuration object or dict. |
None
|
**kwargs
|
Field-level overrides (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with generation settings applied. |
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
with_time_series(config=None, **kwargs)
¶
Configure time-series synthesis settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TimeSeriesParameters | ParamDict | None
|
Time-series configuration object or dict. |
None
|
**kwargs
|
Field-level overrides (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with time-series synthesis settings applied. |
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
with_differential_privacy(config=None, **kwargs)
¶
Configure differential privacy settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DifferentialPrivacyHyperparams | ParamDict | None
|
DP configuration object or dict. |
None
|
**kwargs
|
Field-level overrides (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with differential privacy settings applied. |
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
with_replace_pii(config=None, *, enable=True, **kwargs)
¶
Configure PII replacement settings.
Falls back to PiiReplacerConfig.get_default_config() when
config is None. Pass enable=False to explicitly
disable PII replacement for this run -- this sets
replace_pii=None, which is the sole disabled signal.
Note: PII replacement uses replace_pii=None as the disabled
signal rather than a PiiReplacerConfig.enabled boolean field.
This differs from EvaluationConfig.enabled but is intentional:
PiiReplacerConfig has a non-trivial default_factory that
must fire when the field is absent from a YAML config. Adding an
enabled boolean inside the sub-config would require a
model_validator to reconcile the two signals and would not
interact cleanly with Pydantic's exclude_unset semantics used
in from_params.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
PiiReplacerConfig | ParamDict | None
|
PII replacement configuration object or dict. |
None
|
enable
|
bool
|
When |
True
|
**kwargs
|
Field-level overrides (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with PII replacement configured. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example::
builder = SafeSynthesizer().with_data_source(your_dataframe).with_replace_pii(config=custom_pii_config)
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
with_evaluate(config=None, **kwargs)
¶
Configure evaluation settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
EvaluationParameters | ParamDict | None
|
Evaluation configuration object or dict. |
None
|
**kwargs
|
Field-level overrides (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with evaluation settings applied. |
Source code in src/nemo_safe_synthesizer/sdk/config_builder.py
resolve()
¶
Finalize configuration and data source.
Assembles the individual _*_config sections into a single
SafeSynthesizerParameters and converts the data source
(URL string or DataFrame) into a DataFrame.
Returns:
| Type | Description |
|---|---|
Self
|
This builder instance with all configuration sections finalized. |