nvflare.fuel.utils.fobs.datum module

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

Bases: object

Datum 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

static file_datum(path: str, dot=0)[source]

Factory method to crate a file datum

static text_datum(text: str, dot=0)[source]

Factory method to create a TEXT datum

class DatumManager(threshold=None, fobs_ctx: dict | None = None)[source]

Bases: object

add_datum(d: Datum)[source]
externalize(data: Any)[source]
get_datum(datum_id: str)[source]
get_datums()[source]
get_error()[source]

Get the error set with the manager

Returns: the error set with the manager

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:

internalize(data: Any) Any[source]
post_process()[source]

Invoke all post serialization callbacks. Called during serialization after all objects are decomposed.

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:

set_error(error: str)[source]

Set an error with the manager. The manager will eventually raise RuntimeError at the end of serialization if any error is set.

Parameters:

error – the error to be set

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