nvflare.fuel.utils.fobs.datum module¶
- class Datum(datum_type: DatumType, value: Any, dot=0)[source]¶
Bases:
objectDatum is a class that holds information for externalized data
Constructor of Datum object
- Parameters:
datum_type – type of the datum.
value – value of the datum
dot – the Object Type of the datum
- static blob_datum(blob: bytes | bytearray | memoryview, dot=0)[source]¶
Factory method to create a BLOB datum
- set_restore_func(func, func_data)[source]¶
Set the restore function and func data. Restore func is set during the serialization process. If set, the func will be called after the serialization to restore the serialized object back to its original state.
- Args:
func: the restore function func_data: arg passed to the restore func when called
Returns: None
- class DatumManager(threshold=None, fobs_ctx: dict | None = None)[source]¶
Bases:
object- get_fobs_context()[source]¶
Get the FOBS Context associated with the manager. The context is available during the whole process of serialization/deserialization of a single message. Since Decomposers are singleton objects that could be used by multiple decomposition processes concurrently, processing state data must not be stored in the decomposer! Instead, such data should be stored in the FOBS context.
Returns:
- get_original(obj_copy) Any[source]¶
Get the registered original object from the object copy.
- Parameters:
obj_copy – a copy of the original object
Returns: the original object if found; None otherwise.
- post_process()[source]¶
Invoke all post serialization callbacks. Called during serialization after all objects are decomposed.
Returns: None
- register_copy(obj_copy, original_obj)[source]¶
Register the object_copy => original object
- Parameters:
obj_copy – a copy of the original object
original_obj – the original object
Returns: None
- register_post_cb(cb: Callable[[DatumManager], None], **cb_kwargs)[source]¶
Register a callback that will be called after the decomposition is done during serialization process. The callback is typically registered during decomposition by decomposers.
Note that the callback itself could also call this method to register additional callbacks. These callbacks will be appended to the callback list.
The manager’s post CB processing continues until all registered callbacks are invoked.
- Parameters:
cb – the callback to be registered
**cb_kwargs – kwargs to be passed to the callback when invoked
Returns: