Config Coercion
Shared constructor and process-config coercion for media toolkit processors.
coerce_config
hydrates a stable constructor model.
merge_process_config
overlays per-call process_config fields (None means “keep constructor”)
and returns the same constructor model type.
coerce_config(config, model)
Coerce a constructor config dict / model / None into model.
Shared family configs (parent BaseModel instances that are not the exact
backend model) are re-validated so backend-specific defaults fill in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any] | BaseModel | None
|
A dict to hydrate, a model
instance, or |
required |
model
|
type[TModel]
|
Target constructor config class. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TModel |
TModel
|
A typed config instance of |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
coerce_optional_process_config(process_config, model_cls, *, allow_family=False)
Normalize an optional per-invocation process config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_config
|
ProcessorProcessConfig | dict[str, Any] | None
|
Per-call
config, a dict to hydrate, or |
required |
model_cls
|
type[TProcess]
|
Backend process-config class. |
required |
allow_family
|
bool
|
When True, parent family process configs
are re-validated into |
False
|
Returns:
| Type | Description |
|---|---|
TProcess | None
|
TProcess | None: |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
merge_process_config(stable, process_config, *, process_model, exclude_keys=frozenset(), field_map=None)
Overlay non-None process-config fields onto stable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stable
|
TModel
|
Constructor config to start from. |
required |
process_config
|
ProcessorProcessConfig | dict[str, Any] | None
|
Per-call
overrides. |
required |
process_model
|
type[TProcess]
|
Backend process-config class. |
required |
exclude_keys
|
frozenset[str]
|
Process-config keys skipped during the overlay. Defaults to empty. |
frozenset()
|
field_map
|
Mapping[str, str] | None
|
Copy process-config
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
TModel |
TModel
|
Effective constructor config of the same type as |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |