nvflare.fuel.utils.fobs.decomposer module¶
- class DataClassDecomposer(data_type: Type[T])[source]¶
Bases:
Decomposer
Generic decomposers for data classes, which must meet following requirements:
All class members must be serializable. The type of member must be one of the types supported by MessagePack or a decomposer is registered for the type.
The __new__ method only takes one argument which is the class type.
The __init__ method has no side effects. It can only change the states of the object. The side effects include creating files, initializing loggers, modifying global variables.
- decompose(target: T) Any [source]¶
Decompose the target into types supported by msgpack or classes with decomposers registered.
Msgpack supports primitives, bytes, memoryview, lists, dicts.
- Parameters:
target – The instance to be serialized
- Returns:
The decomposed serializable objects
- class Decomposer[source]¶
Bases:
ABC
Abstract base class for decomposers.
Every class to be serialized by FOBS must register a decomposer which is a concrete subclass of this class.
- abstract decompose(target: T) Any [source]¶
Decompose the target into types supported by msgpack or classes with decomposers registered.
Msgpack supports primitives, bytes, memoryview, lists, dicts.
- Parameters:
target – The instance to be serialized
- Returns:
The decomposed serializable objects
- class DictDecomposer(dict_type: Type[dict])[source]¶
Bases:
Decomposer
Generic decomposer for subclasses of dict like Shareable
- decompose(target: dict) Any [source]¶
Decompose the target into types supported by msgpack or classes with decomposers registered.
Msgpack supports primitives, bytes, memoryview, lists, dicts.
- Parameters:
target – The instance to be serialized
- Returns:
The decomposed serializable objects
- class EnumTypeDecomposer(data_type: Type[Enum])[source]¶
Bases:
Decomposer
Generic decomposers for enum types.
- decompose(target: Enum) Any [source]¶
Decompose the target into types supported by msgpack or classes with decomposers registered.
Msgpack supports primitives, bytes, memoryview, lists, dicts.
- Parameters:
target – The instance to be serialized
- Returns:
The decomposed serializable objects