nvflare.fuel.utils.fobs.datum module

class Datum(datum_type: DatumType, value: Any)[source]

Bases: object

Datum is a class that holds information for externalized data

Constructor of Datum object

  • datum_type – type of the datum.

  • value – value of the datum

static blob_datum(blob: bytes | bytearray | memoryview)[source]

Factory method to create a BLOB datum

static file_datum(path: str)[source]

Factory method to crate a file 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.


func: the restore function func_data: arg passed to the restore func when called

Returns: None

static text_datum(text: str)[source]

Factory method to create a TEXT datum

class DatumManager(threshold=None)[source]

Bases: object

externalize(data: Any)[source]
get_datum(datum_id: str)[source]
get_original(obj_copy) Any[source]

Get the registered original object from the object copy.


obj_copy – a copy of the original object

Returns: the original object if found; None otherwise.

internalize(data: Any) Any[source]
register_copy(obj_copy, original_obj)[source]

Register the object_copy => original object

  • obj_copy – a copy of the original object

  • original_obj – the original object

Returns: None

class DatumRef(datum_id: str, unwrap=False)[source]

Bases: object

A reference to externalized datum. If unwrap is true, the reference will be removed and replaced with the content of the datum

class DatumType(value)[source]

Bases: Enum

An enumeration.

BLOB = 2
FILE = 3
TEXT = 1