Skip to main content

protocols

Protocols for inter-machine communication.

Federated protocol plugins can also be imported from this package.

Module

Submodules

Classes

BaseProtocolFactory

class BaseProtocolFactory(    *,    algorithm: Union[BaseCompatibleAlgoFactory, Sequence[BaseCompatibleAlgoFactory]],    **kwargs: Any,):

Base Protocol from which all other protocols must inherit.

Ancestors

  • abc.ABC
  • bitfount.federated.roles._RolesMixIn
  • bitfount.types._BaseSerializableObjectMixIn

Variables

  • algorithms : list - Returns the algorithms in the protocol.

Methods


dump

def dump(self)> SerializedProtocol:

Returns the JSON-serializable representation of the protocol.

modeller

def modeller(    self, mailbox: _ModellerMailbox, **kwargs: Any,)> BaseModellerProtocol:

Creates an instance of the modeller-side for this 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]:

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,)> BaseWorkerProtocol:

Creates an instance of the worker-side for this protocol.

Conversation

class Conversation(*, algorithm: _ConversationCompatibleAlgoFactory):

Conversation protocol.

This protocol is used for a conversation between a modeller and a pod. The pod does not remember the previous prompts and responses.

Attributes

  • 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()}).
  • 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})

Ancestors

Variables

  • static algorithm : bitfount.federated.protocols.conversation._ConversationCompatibleAlgoFactory
  • 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.conversation._ModellerSide:

Creates a modeller-side protocol instance.

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:

Creates a worker-side protocol instance.

FederatedAveraging

class FederatedAveraging(    *,    algorithm: _FederatedAveragingCompatibleAlgoFactory,    aggregator: Optional[_BaseAggregatorFactory] = None,    steps_between_parameter_updates: Optional[int] = None,    epochs_between_parameter_updates: Optional[int] = None,    auto_eval: bool = True,    secure_aggregation: bool = False,):

Original Federated Averaging algorithm by McMahan et al. (2017).

This protocol performs a predetermined number of epochs or steps of training on each remote Pod before sending the updated model parameters to the modeller. These parameters are then averaged and sent back to the Pods for as many federated iterations as the Modeller specifies.

tip

For more information, take a look at the seminal paper: https://arxiv.org/abs/1602.05629

Arguments

  • aggregator: The aggregator to use for updating the model parameters across all Pods participating in the task. This argument takes priority over the secure_aggregation argument.
  • algorithm: The algorithm to use for training. This must be compatible with the FederatedAveraging protocol.
  • auto_eval: Whether to automatically evaluate the model on the validation dataset. Defaults to True.
  • epochs_between_parameter_updates: The number of epochs between parameter updates, i.e. the number of rounds of local training before parameters are updated. If steps_between_parameter_updates is provided, epochs_between_parameter_updates cannot be provided. Defaults to None.
  • secure_aggregation: Whether to use secure aggregation. This argument is overridden by the aggregator argument. Defaults to False.
  • steps_between_parameter_updates: The number of steps between parameter updates, i.e. the number of rounds of local training before parameters are updated. If epochs_between_parameter_updates is provided, steps_between_parameter_updates cannot be provided. Defaults to None.

Attributes

  • aggregator: The aggregator to use for updating the model parameters.
  • algorithm: The algorithm to use for training
  • auto_eval: Whether to automatically evaluate the model on the validation dataset.
  • epochs_between_parameter_updates: The number of epochs between parameter updates.
  • 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})
  • steps_between_parameter_updates: The number of steps between parameter updates.

Raises

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

Ancestors

Variables

  • static algorithm : bitfount.federated.protocols.model_protocols.federated_averaging._FederatedAveragingCompatibleAlgoFactory
  • 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,    early_stopping: Optional[FederatedEarlyStopping] = None,    **kwargs: Any,)> bitfount.federated.protocols.model_protocols.federated_averaging._ModellerSide:

Returns the modeller side of the FederatedAveraging 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,)> bitfount.federated.protocols.model_protocols.federated_averaging._WorkerSide:

Returns the worker side of the FederatedAveraging protocol.

Raises

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

GAScreeningProtocolAmethyst

class GAScreeningProtocolAmethyst(    *,    algorithm: Sequence[Union[ModelInference, GATrialCalculationAlgorithmJade, TrialInclusionCriteriaMatchAlgorithmAmethyst, CSVReportGeneratorOphthalmologyAlgorithm, GATrialPDFGeneratorAlgorithmAmethyst]],    results_notification_email: Optional[bool] = False,    trial_name: Optional[str] = None,    rename_columns: Optional[Mapping[str, str]] = None,    **kwargs: Any,):

Protocol for running GA Algorithms sequentially.

Ancestors

Variables

  • algorithms : list - Returns the algorithms in the protocol.

Methods


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.ophthalmology.ga_screening_protocol_amethyst._ModellerSide:

Returns the Modeller side of the 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 worker side of the protocol.

GAScreeningProtocolBronze

class GAScreeningProtocolBronze(    *,    algorithm: Sequence[Union[ModelInference, ModelInference, GATrialCalculationAlgorithmJade, TrialInclusionCriteriaMatchAlgorithmBronze, CSVReportGeneratorOphthalmologyAlgorithm, GATrialPDFGeneratorAlgorithmAmethyst]],    results_notification_email: Optional[bool] = False,    trial_name: Optional[str] = None,    rename_columns: Optional[Mapping[str, str]] = None,    **kwargs: Any,):

Protocol for running GA Algorithms sequentially.

Ancestors

Variables

  • algorithms : list - Returns the algorithms in the protocol.

Methods


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.ophthalmology.ga_screening_protocol_bronze._ModellerSide:

Returns the Modeller side of the 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 worker side of the protocol.

GAScreeningProtocolJade

class GAScreeningProtocolJade(    *,    algorithm: Sequence[Union[ModelInference, GATrialCalculationAlgorithmJade, CSVReportGeneratorOphthalmologyAlgorithm, GATrialPDFGeneratorAlgorithmJade, TrialInclusionCriteriaMatchAlgorithmJade]],    results_notification_email: Optional[bool] = False,    trial_name: Optional[str] = None,    rename_columns: Optional[Mapping[str, str]] = None,    **kwargs: Any,):

Protocol for running GA Algorithms sequentially.

Ancestors

Variables

  • algorithms : list - Returns the algorithms in the protocol.

Methods


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.ophthalmology.ga_screening_protocol_jade._ModellerSide:

Returns the Modeller side of the 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 worker side of the protocol.

InferenceAndCSVReport

class InferenceAndCSVReport(    *,    algorithm: Sequence[Union[_InferenceAndCSVReportCompatibleAlgoFactory_, _InferenceAndCSVReportCompatibleModelAlgoFactory, _InferenceAndCSVReportCompatibleHuggingFaceAlgoFactory]],    **kwargs: Any,):

Protocol for running a model inference generating a csv report.

Ancestors

Variables

  • algorithms : list - Returns the algorithms in the protocol.

Methods


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.model_protocols.inference_csv_report._ModellerSide:

Returns the Modeller side of the 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 worker side of the protocol.

InferenceAndReturnCSVReport

class InferenceAndReturnCSVReport(    *,    algorithm: Sequence[Union[_InferenceAndCSVReportCompatibleAlgoFactory_, _InferenceAndCSVReportCompatibleModelAlgoFactory, _InferenceAndCSVReportCompatibleHuggingFaceAlgoFactory]],    **kwargs: Any,):

Protocol that sends runs inference and sends the result as CSV to the modeller.

Extends InferenceAndCSVReport to send the number of records output to CSV.

Ancestors

Variables

  • algorithms : list - Returns the algorithms in the protocol.

Methods


dump

def dump(self)> SerializedProtocol:

Inherited from:

InferenceAndCSVReport.dump :

Returns the JSON-serializable representation of the protocol.

modeller

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

Inherited from:

InferenceAndCSVReport.modeller :

Returns the Modeller side of the 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:

Inherited from:

InferenceAndCSVReport.worker :

Returns worker side of the protocol.

InstrumentedInferenceAndCSVReport

class InstrumentedInferenceAndCSVReport(    *,    algorithm: Sequence[Union[_InferenceAndCSVReportCompatibleAlgoFactory_, _InferenceAndCSVReportCompatibleModelAlgoFactory, _InferenceAndCSVReportCompatibleHuggingFaceAlgoFactory]],    **kwargs: Any,):

Protocol that sends telemetry metrics back to Bitfount.

Extends InferenceAndCSVReport to send the number of records output to CSV.

Ancestors

Variables

  • algorithms : list - Returns the algorithms in the protocol.

Methods


dump

def dump(self)> SerializedProtocol:

Inherited from:

InferenceAndCSVReport.dump :

Returns the JSON-serializable representation of the protocol.

modeller

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

Inherited from:

InferenceAndCSVReport.modeller :

Returns the Modeller side of the 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:

Inherited from:

InferenceAndCSVReport.worker :

Returns worker side of the protocol.

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.

RetinalDiseaseProtocolCobalt

class RetinalDiseaseProtocolCobalt(    *,    algorithm: Sequence[Union[ModelInference, CSVReportGeneratorOphthalmologyAlgorithm]],    **kwargs: Any,):

Protocol for running the basic OCT model algorithm.

Ancestors

Variables

  • algorithms : list - Returns the algorithms in the protocol.

Methods


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.ophthalmology.retinal_disease_protocol_cobalt._ModellerSide:

Returns the Modeller side of the 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 worker side of the protocol.