fedn.network.combiner package

The FEDn Combiner package is responsible for combining models from multiple clients. It’s the acting gRPC server for the federated network.

Subpackages

Submodules

fedn.network.combiner.combiner module

fedn.network.combiner.combiner_tests module

fedn.network.combiner.connect module

class fedn.network.combiner.connect.ConnectorCombiner(host, port, myhost, fqdn, myport, token, name, secure=False, verify=False)[source]

Bases: object

Connector for annnouncing combiner to the FEDn network.

Parameters:
  • host (str) – host of discovery service

  • port (int) – port of discovery service

  • myhost (str) – host of combiner

  • fqdn (str) – fully qualified domain name of combiner

  • myport (int) – port of combiner

  • token (str) – token for authentication

  • name (str) – name of combiner

  • secure (bool) – True if https is used, False if http

  • verify (bool) – True if certificate is verified, False if not

announce()[source]

Announce combiner to FEDn network via discovery service (REST-API).

Returns:

Tuple with announcement Status, FEDn network configuration if sucessful, else None.

Return type:

fedn.network.combiner.connect.Status, str

class fedn.network.combiner.connect.Status(value)[source]

Bases: Enum

Enum for representing the status of a combiner announcement.

Assigned = 1
TryAgain = 2
UnAuthorized = 3
UnMatchedConfig = 4
Unassigned = 0

fedn.network.combiner.interfaces module

fedn.network.combiner.modelservice module

class fedn.network.combiner.modelservice.ModelService[source]

Bases: ModelServiceServicer

Service for handling download and upload of models to the server.

Download(request, context)[source]

RPC endpoints for downloading a model.

Parameters:
  • request (fedn.network.grpc.fedn_pb2.ModelRequest) – The model request object.

  • context (grpc._server._Context) – The context object (unused)

Returns:

A model response iterator.

Return type:

fedn.network.grpc.fedn_pb2.ModelResponse

Upload(request_iterator, context)[source]

RPC endpoints for uploading a model.

Parameters:
  • request_iterator (fedn.network.grpc.fedn_pb2.ModelRequest) – The model request iterator.

  • context (grpc._server._Context) – The context object (unused)

Returns:

A model response object.

Return type:

fedn.network.grpc.fedn_pb2.ModelResponse

exist(model_id)[source]

Check if a model exists on the server.

Parameters:

model_id – The model id.

Returns:

True if the model exists, else False.

get_model(id)[source]

Download model with id ‘id’ from server.

Parameters:

id (str) – The model id.

Returns:

A BytesIO object containing the model.

Return type:

io.BytesIO, None if model does not exist.

set_model(model, id)[source]

Upload model to server.

Parameters:
  • model (io.BytesIO) – A model object (BytesIO)

  • id (str) – The model id.

fedn.network.combiner.modelservice.get_tmp_path()[source]

Return a temporary output path compatible with save_model, load_model.

fedn.network.combiner.modelservice.load_model_from_BytesIO(model_bytesio, helper)[source]

Load a model from a BytesIO object. :param model_bytesio: A BytesIO object containing the model. :type model_bytesio: io.BytesIO :param helper: The helper object for the model. :type helper: fedn.utils.helperbase.HelperBase :return: The model object. :rtype: return type of helper.load

fedn.network.combiner.modelservice.model_as_bytesIO(model)[source]
fedn.network.combiner.modelservice.serialize_model_to_BytesIO(model, helper)[source]

Serialize a model to a BytesIO object.

Parameters:
  • model (return type of helper.load) – The model object.

  • helper (fedn.utils.helperbase.HelperBase) – The helper object for the model.

Returns:

A BytesIO object containing the model.

Return type:

io.BytesIO

fedn.network.combiner.modelservice.upload_request_generator(mdl, id)[source]

Generator function for model upload requests.

Parameters:

mdl (BytesIO) – The model update object.

Returns:

A model update request.

Return type:

fedn.ModelRequest

fedn.network.combiner.roundhandler module