nexuml.core.serialization¶
nexuml.core.serialization
¶
Generic component lowering and restoration at config boundaries.
lower_component
¶
lower_component(
component: ComponentDefinition,
) -> dict[str, Any]
Lower a concrete definition to its stable serialized identity.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Portable component identity and validated parameters. |
restore_component
¶
restore_component(
*, kind: str, value: Mapping[str, Any]
) -> ComponentDefinition
Restore a concrete definition from stable serialized data.
Returns:
| Type | Description |
|---|---|
ComponentDefinition
|
Validated concrete component definition. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If serialized parameters are not a mapping. |
ValueError
|
If identity fields are missing or invalid. |
lower_model
¶
lower_model(model: BaseModel) -> dict[str, Any]
Recursively lower a Pydantic model and all component definitions.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Portable plain model data. |
restore_model_data
¶
restore_model_data(
data: Mapping[str, Any], model_type: type[BaseModel]
) -> dict[str, Any]
Restore nested component definitions before model validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Model data containing concrete component definition instances. |