SamplexModelSSV1
pydantic model SamplexModelSSV1
Bases: SamplexModel
A samplex model constrained to use samplex serialization version (SSV) 1.
samplex_json
field
Type: str [Required]
A JSON string representing the samplex.
Validated by
cross_validate_ssv_version
ssv
field
Type: int [Required]
The samplex serialization version.
Constraints
- ge = 1
- le = 1
Validated by
cross_validate_ssv_version
cross_validate_ssv_version
validator cross_validate_ssv_version
Check that the reported version matches the encoded version.
from_samplex
classmethod from_samplex(samplex, ssv=None)
Create a model instance from a samplex.
The returned instance owns a reference to the provided samplex. This instance may be returned by to_samplex() depending on the value of use_cached. Users of this class are responsible for managing cached instances of the samplex and possible side-effects of their mutations.
Parameters
- samplex (Samplex) – The samplex to encode into the model.
- ssv (int | None)
Returns
A new model instance.
to_samplex
to_samplex(use_cached=False)
Return a decoded samplex instance.
When use_cached is false, or when no cached version exists, samplex_json is decoded and loaded into a new instance. Users of this class are responsible for managing cached instances of the samplex and possible side-effects of their mutations.
Parameters
use_cached (bool) – Whether to return the cached instance (if it exists).
Returns
A samplex.
Return type
Samplex