nvflare.app_common.decomposers.numpy_decomposers module

Decomposers for types from app_common and Machine Learning libraries.

class Float32ScalarDecomposer[source]

Bases: NumpyScalarDecomposer

supported_type()[source]

Returns the type/class supported by this decomposer.

Returns:

The class (not instance) of supported type

class Float64ScalarDecomposer[source]

Bases: NumpyScalarDecomposer

supported_type()[source]

Returns the type/class supported by this decomposer.

Returns:

The class (not instance) of supported type

class Int32ScalarDecomposer[source]

Bases: NumpyScalarDecomposer

supported_type()[source]

Returns the type/class supported by this decomposer.

Returns:

The class (not instance) of supported type

class Int64ScalarDecomposer[source]

Bases: NumpyScalarDecomposer

supported_type()[source]

Returns the type/class supported by this decomposer.

Returns:

The class (not instance) of supported type

class NumpyArrayDecomposer[source]

Bases: ViaDownloaderDecomposer

download(from_fqcn: str, ref_id: str, per_request_timeout: float, cell: Cell, secure=False, optional=False, abort_signal=None) Tuple[str, dict][source]
get_download_dot() int[source]

Get the Datum Object Type to be used for download ref datum

Returns: the DOT for download ref datum

native_decompose(target: ndarray, manager: DatumManager | None = None) bytes[source]
native_recompose(data: bytes, manager: DatumManager | None = None) ndarray[source]
supported_type()[source]

Returns the type/class supported by this decomposer.

Returns:

The class (not instance) of supported type

to_downloadable(items: dict, max_chunk_size: int, fobs_ctx: dict) Downloadable[source]

Convert the items Downloadable object.

Parameters:
  • items – a dict of items of target object type to be converted

  • max_chunk_size – max size of one chunk.

  • fobs_ctx – FOBS Context

Returns: a Downloadable object

The “items” is a dict of target objects. The dict contains all objects of the target type in one payload.

class NumpyScalarDecomposer[source]

Bases: Decomposer, ABC

Decomposer base class for all numpy types with item method.

decompose(target: Any, manager: DatumManager | None = None) 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

  • manager – Datum manager to store externalized datum

Returns:

The decomposed serializable objects

recompose(data: Any, manager: DatumManager | None = None) ndarray[source]

Reconstruct the object from decomposed components.

Parameters:
  • data – The decomposed component

  • manager – Datum manager to internalize datum

Returns:

The reconstructed object

register()[source]