protocols
Protocols for inter-machine communication.
Federated protocol plugins can also be imported from this package.
Module
Submodules
- bitfount.federated.protocols.base - Pod communication protocols.
- bitfount.federated.protocols.ehr - Protocols related to EHR interactions.
- bitfount.federated.protocols.model_protocols - Protocols for remote/federated model training on data.
- bitfount.federated.protocols.ophthalmology - Protocol plugins in this package.
- bitfount.federated.protocols.resilience - Resilience handling for batch execution in federated protocols.
- bitfount.federated.protocols.results_only - Results Only protocol.
- bitfount.federated.protocols.types - Batch execution types and data structures for protocols.
- bitfount.federated.protocols.utils - Utility functions for federated protocols.
Classes
BaseProtocolFactory
class BaseProtocolFactory( *, algorithm: Union[BaseCompatibleAlgoFactory, Sequence[BaseCompatibleAlgoFactory]], primary_results_path: Optional[str] = None, **kwargs: Any,):Base Protocol from which all other protocols must inherit.
Subclasses
- DataExtractionProtocolCharcoal
- NextGenSearchProtocol
- FederatedAveraging
- InferenceAndCSVReport
- InferenceAndImageOutput
- FluidVolumeScreeningProtocol
- GAScreeningProtocolAmethyst
- GAScreeningProtocolBronze
- GAScreeningProtocolBronzeWithEHR
- GAScreeningProtocolCharcoal
- GAScreeningProtocolJade
- InSiteInsightsProtocol
- RetinalDiseaseProtocolCobalt
- ResultsOnly
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
- static
nested_fields : ClassVar[dict[str, collections.abc.Mapping[str, Any]]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- 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, context: ProtocolContext, **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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> 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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> BaseWorkerProtocol:Creates an instance of the worker-side for this protocol.
DataExtractionProtocolCharcoal
class DataExtractionProtocolCharcoal( *, patient_ids: Optional[list[str]] = None, patient_ids_file: Optional[os.PathLike | str] = None, algorithm: Sequence[EHRPatientInfoDownloadAlgorithm], trial_name: Optional[str] = None, **kwargs: Any,):Protocol for running EHR Data Extraction for Charcoal.
Data extraction protocol for Charcoal project.
Patient IDs can either be supplied as an explicit list of patient IDs or as a path to a file which contains one patient ID per line. These two options are mutually exclusive from each other.
Arguments
patient_ids: List of patient ID strings. Mutually exclusive withpatient_ids_file.patient_ids_file: Path to file containing patient ID strings, one per line. Mutually exclusive withpatient_ids.algorithm: The sequence of algorithms to be used. On the modeller side these will be noop algorithms.trial_name: Name of the trial.- **
**kwargs**: Additional keyword arguments.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.protocols.ehr.data_extraction_protocol_charcoal._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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the DataExtractionProtocolCharcoal protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
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, primary_results_path: Optional[str] = None,):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.
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 thesecure_aggregationargument.algorithm: The algorithm to use for training. This must be compatible with theFederatedAveragingprotocol.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. Ifsteps_between_parameter_updatesis provided,epochs_between_parameter_updatescannot be provided. Defaults to None.secure_aggregation: Whether to use secure aggregation. This argument is overridden by theaggregatorargument. 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. Ifepochs_between_parameter_updatesis provided,steps_between_parameter_updatescannot be provided. Defaults to None.
Attributes
aggregator: The aggregator to use for updating the model parameters.algorithm: The algorithm to use for trainingauto_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 marshmallow 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 thealgorithmis not compatible with the protocol.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
algorithm : bitfount.federated.protocols.model_protocols.federated_averaging._FederatedAveragingCompatibleAlgoFactory
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
- static
nested_fields : ClassVar[dict[str, collections.abc.Mapping[str, Any]]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- 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:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, early_stopping: Optional[FederatedEarlyStopping] = None, context: ProtocolContext, **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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.protocols.model_protocols.federated_averaging._WorkerSide:Returns the worker side of the FederatedAveraging protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
Raises
TypeError: If the mailbox is not compatible with the aggregator.
FluidVolumeScreeningProtocol
class FluidVolumeScreeningProtocol( *, algorithm: Sequence[Union[ModelInference, FluidVolumeCalculationAlgorithm, CSVReportGeneratorOphthalmologyAlgorithm]], results_notification_email: Optional[bool] = False, trial_name: Optional[str] = None, rename_columns: Optional[Mapping[str, str]] = None, **kwargs: Any,):Protocol for running Fluid Volume Algorithms sequentially.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> GenericOphthalmologyModellerSide: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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the FluidVolumeScreeningProtocol protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
GAScreeningProtocolAmethyst
class GAScreeningProtocolAmethyst( *, algorithm: Sequence[Union[ModelInference, GATrialCalculationAlgorithmJade, GATrialCalculationAlgorithmAmethyst, 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
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> GenericOphthalmologyModellerSide: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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the GAScreeningProtocolAmethyst protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
GAScreeningProtocolBronze
class GAScreeningProtocolBronze( *, algorithm: Sequence[Union[ModelInference, ModelInference, GATrialCalculationAlgorithmBronze, 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 and fovea sequentially.
Init protocol for running GA Algorithms and fovea sequentially.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> GenericOphthalmologyModellerSide: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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the GAScreeningProtocolBronze protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
GAScreeningProtocolBronzeWithEHR
class GAScreeningProtocolBronzeWithEHR( *, algorithm: Sequence[Union[ModelInference, ModelInference, GATrialCalculationAlgorithmBronze, TrialInclusionCriteriaMatchAlgorithmBronze, EHRPatientQueryAlgorithm, 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 and fovea sequentially with EHR info.
Init Protocol factory for Bronze with EHR.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> GenericOphthalmologyModellerSide: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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the GAScreeningProtocolBronze protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
GAScreeningProtocolCharcoal
class GAScreeningProtocolCharcoal( *, algorithm: Sequence[RecordFilterAlgorithm | EHRPatientQueryAlgorithm | ModelInference | GATrialCalculationAlgorithmCharcoal | TrialInclusionCriteriaMatchAlgorithmCharcoal | _SimpleCSVAlgorithm | ReduceCSVAlgorithmCharcoal | S3UploadAlgorithm], 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
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.protocols.ophthalmology.ga_screening_protocol_charcoal._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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the GAScreeningProtocolCharcoal protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
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
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Subclasses
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> GenericOphthalmologyModellerSide: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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the GAScreeningProtocolJade protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
InSiteInsightsProtocol
class InSiteInsightsProtocol( *, algorithm: Sequence[Union[RecordFilterAlgorithm, ModelInference, GATrialCalculationAlgorithmBronze, CSVReportGeneratorOphthalmologyAlgorithm]], results_notification_email: Optional[bool] = False, **kwargs: Any,):Protocol for generating aggregated patient insights for clinics.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> GenericOphthalmologyModellerSide: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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the InSiteInsightsProtocol protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
InferenceAndCSVReport
class InferenceAndCSVReport( *, algorithm: Sequence[Union[_InferenceAndCSVReportCompatibleAlgoFactory_, _InferenceAndCSVReportCompatibleModelAlgoFactory, _InferenceAndCSVReportCompatibleHuggingFaceAlgoFactory]], **kwargs: Any,):Protocol for running a model inference generating a csv report.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the InferenceAndCSVReport protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
InferenceAndImageOutput
class InferenceAndImageOutput( *, algorithm: Sequence[Union[_InferenceAndImageOutputCompatibleAlgoFactory_, _InferenceAndImageOutputCompatibleModelAlgoFactory]], **kwargs: Any,):Protocol for running a model inference generating image outputs with masks.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.protocols.model_protocols.inference_image_output._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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the InferenceAndImageOutput protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
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
- InferenceAndCSVReport
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the InferenceAndReturnCSVReport protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
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
- InferenceAndCSVReport
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the InstrumentedInferenceAndCSVReport protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
NextGenSearchProtocol
class NextGenSearchProtocol( *, algorithm: Sequence[RecordFilterAlgorithm | EHRPatientQueryAlgorithm | _SimpleCSVAlgorithm], rename_columns: Optional[Mapping[str, str]] = None, **kwargs: Any,):Protocol for querying NextGen EHR data and generating CSV reports.
Initialize the protocol.
Arguments
algorithm: Sequence containing NextGen query and CSV report algorithmsrename_columns: Optional mapping of columns to rename in output- **
**kwargs**: Additional keyword arguments
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.protocols.ehr.nextgen_search_protocol._ModellerSide:Returns the Modeller side of the NextGenSearchProtocol 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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.protocols.ehr.nextgen_search_protocol._WorkerSide:Returns worker side of the NextGenSearchProtocol protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
ResultsOnly
class ResultsOnly( *, algorithm: Union[_ResultsOnlyCompatibleNonModelAlgoFactory, _ResultsOnlyCompatibleModelAlgoFactory], aggregator: Optional[_BaseAggregatorFactory] = None, secure_aggregation: bool = False, save_location: Optional[list[SaveLocation]] = None, save_path: Optional[Union[str, os.PathLike]] = None, primary_results_path: Optional[str] = None,):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 thesecure_aggregationargument.algorithm: The algorithm to run.secure_aggregation: Whether to use secure aggregation. This argument is overridden by theaggregatorargument.
Attributes
aggregator: The aggregator to use for updating the algorithm results.algorithm: The algorithm to run. This must be compatible with theResultsOnlyprotocol.fields_dict: A dictionary mapping all attributes that will be serialized in the class to their marshmallow 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 thealgorithmis not compatible with the protocol.
Ancestors
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Variables
- static
algorithm : Union[bitfount.federated.protocols.results_only._ResultsOnlyCompatibleNonModelAlgoFactory, bitfount.federated.protocols.results_only._ResultsOnlyCompatibleModelAlgoFactory]
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
- static
nested_fields : ClassVar[dict[str, collections.abc.Mapping[str, Any]]]
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- 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:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns the worker side of the ResultsOnly protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.
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
- BaseProtocolFactory
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
Subclasses
Variables
algorithms : list[BaseCompatibleAlgoFactoryWorkerStandard | BaseCompatibleAlgoFactoryWorkerHubNeeded]- Returns the algorithms in the protocol.
Methods
dump
def dump(self) ‑> SerializedProtocol:Inherited from:
Returns the JSON-serializable representation of the protocol.
modeller
def modeller( self, *, mailbox: _ModellerMailbox, context: ProtocolContext, **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, project_id: Optional[str] = None, batched_execution: Optional[bool] = None, test_run: bool = False, force_rerun_failed_files: bool = True,) ‑> Optional[Any]:Inherited from:
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.project_id: The project ID to run the task under.batched_execution: Whether to run the task in batched mode. Defaults to False.test_run: If True, runs the task in test mode, on a limited number of datapoints. Defaults to False.force_rerun_failed_files: If True, forces a rerun on files that the task previously failed on. If False, the task will skip files that have previously failed. Note: This option can only be enabled if both enable_batch_resilience and individual_file_retry_enabled are True. Defaults to True.
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 theDataStructuretable name is given as a string.
worker
def worker( self, *, mailbox: _WorkerMailbox, hub: BitfountHub, context: ProtocolContext, **kwargs: Any,) ‑> _WorkerSide:Returns worker side of the RetinalDiseaseProtocolCobalt protocol.
Arguments
mailbox: Worker mailbox instance to allow communication to the modeller.hub:BitfountHubobject to use for communication with the hub.context: Optional. Run-time protocol context details for running.- **
**kwargs**: Additional keyword arguments.