Skip to main content

results_only

Results Only protocol.

Classes

ResultsOnly

class ResultsOnly(    *,    algorithm: Union[_ResultsOnlyCompatibleAlgoFactory_, _ResultsOnlyCompatibleModelAlgoFactory],    aggregator: Optional[_BaseAggregatorFactory] = None,    secure_aggregation: bool = False,):

Simply returns the results from the provided algorithm.

This protocol is the most permissive protocol and only involves one round of communication. It simply runs the algorithm on the Pod(s) and returns the results as a list (one element for every pod) unless an aggregator is specified.

Arguments

  • aggregator: The aggregator to use for updating the algorithm results across all Pods participating in the task. This argument takes priority over the secure_aggregation argument.
  • algorithm: The algorithm to run.
  • secure_aggregation: Whether to use secure aggregation. This argument is overridden by the aggregator argument.

Attributes

  • aggregator: The aggregator to use for updating the algorithm results.
  • algorithm: The algorithm to run. This must be compatible with the ResultsOnly protocol.
  • fields_dict: A dictionary mapping all attributes that will be serialized in the class to their marshamllow field type. (e.g. fields_dict = {"class_name": fields.Str()}).
  • name: The name of the protocol.
  • nested_fields: A dictionary mapping all nested attributes to a registry that contains class names mapped to the respective classes. (e.g. nested_fields = {"datastructure": datastructure.registry})

Raises

  • TypeError: If the algorithm is not compatible with the protocol.

Ancestors

Variables

  • static algorithm : Union[bitfount.federated.protocols.results_only.ResultsOnlyCompatibleAlgoFactory, bitfount.federated.protocols.results_only._ResultsOnlyCompatibleModelAlgoFactory]
  • algorithms : list - Returns the algorithms in the protocol.

Methods


create

def create(self, role: Union[str, Role], **kwargs: Any)> Any:

Create an instance representing the role specified.

dump

def dump(self)> SerializedProtocol:

Inherited from:

BaseProtocolFactory.dump :

Returns the JSON-serializable representation of the protocol.

modeller

def modeller(    self, mailbox: _ModellerMailbox, **kwargs: Any,)> bitfount.federated.protocols.results_only._ModellerSide:

Returns the modeller side of the ResultsOnly protocol.

run

def run(    self,    pod_identifiers: Collection[str],    session: Optional[BitfountSession] = None,    username: Optional[str] = None,    hub: Optional[BitfountHub] = None,    ms_config: Optional[MessageServiceConfig] = None,    message_service: Optional[_MessageService] = None,    pod_public_key_paths: Optional[Mapping[str, Path]] = None,    identity_verification_method: IdentityVerificationMethod = IdentityVerificationMethod.OIDC_DEVICE_CODE,    private_key_or_file: Optional[Union[RSAPrivateKey, Path]] = None,    idp_url: Optional[str] = None,    require_all_pods: bool = False,    run_on_new_data_only: bool = False,    model_out: Optional[Union[Path, str]] = None,    project_id: Optional[str] = None,    batched_execution: Optional[bool] = None,)> Optional[Any]:

Inherited from:

BaseProtocolFactory.run :

Sets up a local Modeller instance and runs the protocol.

Arguments

  • pod_identifiers: The BitfountHub pod identifiers to run against.
  • session: Optional. Session to use for authenticated requests. Created if needed.
  • username: Username to run as. Defaults to logged in user.
  • hub: BitfountHub instance. Default: hub.bitfount.com.
  • ms_config: Message service config. Default: messaging.bitfount.com.
  • message_service: Message service instance, created from ms_config if not provided. Defaults to "messaging.bitfount.com".
  • pod_public_key_paths: Public keys of pods to be checked against.
  • identity_verification_method: The identity verification method to use.
  • private_key_or_file: Private key (to be removed).
  • idp_url: The IDP URL.
  • require_all_pods: If true raise PodResponseError if at least one pod identifier specified rejects or fails to respond to a task request.
  • run_on_new_data_only: Whether to run the task on new datapoints only. Defaults to False.
  • model_out: The path to save the model to.
  • project_id: The project ID to run the task under.
  • batched_execution: Whether to run the task in batched mode. Defaults to False.

Returns Results of the protocol.

Raises

  • PodResponseError: If require_all_pods is true and at least one pod identifier specified rejects or fails to respond to a task request.
  • ValueError: If attempting to train on multiple pods, and the DataStructure table name is given as a string.

worker

def worker(self, mailbox: _WorkerMailbox, hub: BitfountHub, **kwargs: Any)> _WorkerSide:

Returns the worker side of the ResultsOnly protocol.

Raises

  • TypeError: If the mailbox is not compatible with the aggregator.