Fed-BioMed constants/enums
Attributes
CACHE_FOLDER_NAME module-attribute
CACHE_FOLDER_NAME = 'cache'
Directory/folder name where cache files are saved
CERTS_FOLDER_NAME module-attribute
CERTS_FOLDER_NAME = join(CONFIG_FOLDER_NAME, 'certs')
FOLDER name for Certs directory
CONFIG_FOLDER_NAME module-attribute
CONFIG_FOLDER_NAME = 'etc'
Directory/folder name where configurations are saved
DB_FOLDER_NAME module-attribute
DB_FOLDER_NAME = VAR_FOLDER_NAME
Directory/folder name where DB files are saved
DB_PREFIX module-attribute
DB_PREFIX = 'db_'
Prefix for database files name
DEFAULT_CERT_NAME module-attribute
DEFAULT_CERT_NAME = 'FBM_certificate'
EXPERIMENT_PREFIX module-attribute
EXPERIMENT_PREFIX = 'exper_'
Prefix for experiment ID
MAX_MESSAGE_BYTES_LENGTH module-attribute
MAX_MESSAGE_BYTES_LENGTH = 4000000 - getsizeof(bytes('', encoding='UTF-8'))
MAX_RETRIEVE_ERROR_RETRIES module-attribute
MAX_RETRIEVE_ERROR_RETRIES = 5
MAX_SEND_RETRIES module-attribute
MAX_SEND_RETRIES = 5
NODE_PREFIX module-attribute
NODE_PREFIX = 'node_'
Prefix for node ID
NODE_STATE_PREFIX module-attribute
NODE_STATE_PREFIX = 'node_state_'
Prefix for Node state ID
REQUEST_PREFIX module-attribute
REQUEST_PREFIX = 'request_'
Prefix for request ID
SERVER_certificate_prefix module-attribute
SERVER_certificate_prefix = 'server_certificate'
TENSORBOARD_FOLDER_NAME module-attribute
TENSORBOARD_FOLDER_NAME = 'runs'
Directory/folder name where tensorboard logs are saved
TIMEOUT_NODE_TO_NODE_REQUEST module-attribute
TIMEOUT_NODE_TO_NODE_REQUEST = 30
TMP_FOLDER_NAME module-attribute
TMP_FOLDER_NAME = 'tmp'
Directory/folder name where temporary files are saved
TRACEBACK_LIMIT module-attribute
TRACEBACK_LIMIT = 20
VAR_FOLDER_NAME module-attribute
VAR_FOLDER_NAME = 'var'
Directory/folder name where variable files are saved
Classes
ComponentType
Bases: _BaseEnum
Enumeration class, used to characterize the type of component of the fedbiomed architecture
Attributes:
Name | Type | Description |
---|---|---|
RESEARCHER | int | Researcher component |
NODE | int | Node component |
Attributes
NODE class-attribute
instance-attribute
NODE = 2
RESEARCHER class-attribute
instance-attribute
RESEARCHER = 1
DataLoadingBlockTypes
DataLoadingBlockTypes(*args)
Bases: _BaseEnum
Base class for typing purposes.
Concrete enumeration types should be defined within the scope of their implementation or application. To define a concrete enumeration type, one must subclass this class as follows:
class MyLoadingBlockTypes(DataLoadingBlockTypes, Enum):
MY_KEY: str 'myKey'
MY_OTHER_KEY: str 'myOtherKey'
Subclasses must respect the following conditions: - All fields must be str; - All field values must be unique.
Warning
This class must always be empty as it is not allowed to contain any fields!
Source code in fedbiomed/common/constants.py
def __init__(self, *args):
cls = self.__class__
if not isinstance(self.value, str):
raise ValueError("all fields of DataLoadingBlockTypes subclasses"
" must be of str type")
if any(self.value == e.value for e in cls):
a = self.name
e = cls(self.value).name
raise ValueError(
f"duplicate values not allowed in DataLoadingBlockTypes and "
f"its subclasses: {a} --> {e}")
DatasetTypes
Bases: _BaseEnum
Types of Datasets implemented in Fed-BioMed
Attributes
DEFAULT class-attribute
instance-attribute
DEFAULT = 'default'
FLAMBY class-attribute
instance-attribute
FLAMBY = 'flamby'
IMAGES class-attribute
instance-attribute
IMAGES = 'images'
MEDICAL_FOLDER class-attribute
instance-attribute
MEDICAL_FOLDER = 'medical-folder'
MEDNIST class-attribute
instance-attribute
MEDNIST = 'mednist'
NONE class-attribute
instance-attribute
NONE = 'none'
TABULAR class-attribute
instance-attribute
TABULAR = 'csv'
TEST class-attribute
instance-attribute
TEST = 'test'
ErrorNumbers
Bases: _BaseEnum
List of all error messages types
Attributes
FB100 class-attribute
instance-attribute
FB100 = 'FB100: undetermined messaging server error'
FB300 class-attribute
instance-attribute
FB300 = 'FB300: undetermined node error'
FB301 class-attribute
instance-attribute
FB301 = 'FB301: Protocol error'
FB302 class-attribute
instance-attribute
FB302 = 'FB302: TrainingPlan class does not load'
FB303 class-attribute
instance-attribute
FB303 = 'FB303: TrainingPlan class does not contain expected methods'
FB304 class-attribute
instance-attribute
FB304 = 'FB304: TrainingPlan method crashes'
FB309 class-attribute
instance-attribute
FB309 = 'FB309: bad model params (.mpk)'
FB310 class-attribute
instance-attribute
FB310 = 'FB310: bad data format'
FB312 class-attribute
instance-attribute
FB312 = 'FB312: Node stopped in SIGTERM signal handler'
FB313 class-attribute
instance-attribute
FB313 = 'FB313: no dataset matching request'
FB314 class-attribute
instance-attribute
FB314 = 'FB314: Node round error'
FB315 class-attribute
instance-attribute
FB315 = 'FB315: Error while loading the data '
FB316 class-attribute
instance-attribute
FB316 = 'FB316: Data loading plan error'
FB317 class-attribute
instance-attribute
FB317 = 'FB317: FLamby package import error'
FB318 class-attribute
instance-attribute
FB318 = 'FB318: Secure aggregation setup error'
FB319 class-attribute
instance-attribute
FB319 = 'FB319: Command not found error'
FB320 class-attribute
instance-attribute
FB320 = 'FB320: bad model type'
FB321 class-attribute
instance-attribute
FB321 = 'FB321: Secure aggregation delete error'
FB322 class-attribute
instance-attribute
FB322 = 'FB322: Dataset registration error'
FB323 class-attribute
instance-attribute
FB323 = 'FB323: Node State error'
FB324 class-attribute
instance-attribute
FB324 = 'FB324: Node to node overlay communication error'
FB400 class-attribute
instance-attribute
FB400 = 'FB400: undetermined application error'
FB401 class-attribute
instance-attribute
FB401 = 'FB401: aggregation crashes or returns an error'
FB402 class-attribute
instance-attribute
FB402 = 'FB402: strategy method crashes or sends an error'
FB407 class-attribute
instance-attribute
FB407 = 'FB407: list of nodes became empty when training (all nodes failed training or did not answer)'
FB408 class-attribute
instance-attribute
FB408 = 'FB408: training failed on node or node did not answer during training'
FB409 class-attribute
instance-attribute
FB409 = 'FB409: node sent Status=Error during training'
FB410 class-attribute
instance-attribute
FB410 = 'FB410: bad type or value for experiment argument'
FB411 class-attribute
instance-attribute
FB411 = 'FB411: cannot train an experiment that is not fully defined'
FB412 class-attribute
instance-attribute
FB412 = 'FB412: cannot do model checking for experiment'
FB413 class-attribute
instance-attribute
FB413 = 'FB413: cannot save or load breakpoint for experiment'
FB414 class-attribute
instance-attribute
FB414 = 'FB414: bad type or value for training arguments'
FB415 class-attribute
instance-attribute
FB415 = 'FB415: secure aggregation handling error'
FB416 class-attribute
instance-attribute
FB416 = 'FB416: federated dataset error'
FB417 class-attribute
instance-attribute
FB417 = 'FB417: secure aggregation error'
FB419 class-attribute
instance-attribute
FB419 = 'FB419: node state agent error'
FB600 class-attribute
instance-attribute
FB600 = 'FB600: environ error'
FB601 class-attribute
instance-attribute
FB601 = 'FB601: message error'
FB603 class-attribute
instance-attribute
FB603 = 'FB603: task queue error'
FB605 class-attribute
instance-attribute
FB605 = 'FB605: training plan error'
FB606 class-attribute
instance-attribute
FB606 = 'FB606: model manager error'
FB607 class-attribute
instance-attribute
FB607 = 'FB607: data manager error'
FB608 class-attribute
instance-attribute
FB608 = 'FB608: torch data manager error'
FB609 class-attribute
instance-attribute
FB609 = 'FB609: scikit-learn data manager error'
FB610 class-attribute
instance-attribute
FB610 = 'FB610: Torch based tabular dataset creation error'
FB611 class-attribute
instance-attribute
FB611 = 'FB611: Error while trying to evaluate using the specified metric'
FB612 class-attribute
instance-attribute
FB612 = 'FB612: Torch based NIFTI dataset error'
FB613 class-attribute
instance-attribute
FB613 = 'FB613: Medical Folder dataset error'
FB614 class-attribute
instance-attribute
FB614 = 'FB614: data loading block error'
FB615 class-attribute
instance-attribute
FB615 = 'FB615: data loading plan error'
FB616 class-attribute
instance-attribute
FB616 = 'FB616: differential privacy controller error'
FB617 class-attribute
instance-attribute
FB617 = 'FB617: FLamby dataset error'
FB618 class-attribute
instance-attribute
FB618 = 'FB618: FLamby data transformation error'
FB619 class-attribute
instance-attribute
FB619 = 'FB619: Certificate error'
FB620 class-attribute
instance-attribute
FB620 = 'FB620: MPC protocol error'
FB621 class-attribute
instance-attribute
FB621 = 'FB621: declearn optimizer error'
FB622 class-attribute
instance-attribute
FB622 = 'FB622: Model error'
FB623 class-attribute
instance-attribute
FB623 = 'FB623: Secure aggregation database error'
FB624 class-attribute
instance-attribute
FB624 = 'FB624: Secure aggregation crypter error'
FB625 class-attribute
instance-attribute
FB625 = 'FB625: Component version error'
FB626 class-attribute
instance-attribute
FB626 = 'FB626: Fed-BioMed optimizer error'
FB627 class-attribute
instance-attribute
FB627 = 'FB627: Utility function error'
FB628 class-attribute
instance-attribute
FB628 = 'FB628: Communication error'
FB629 class-attribute
instance-attribute
FB629 = 'FB629: Diffie-Hellman KA error'
FB630 class-attribute
instance-attribute
FB630 = 'FB630: Additive Secret Sharing error'
FB631 class-attribute
instance-attribute
FB631 = 'FB631: Node to node channels database error'
FB999 class-attribute
instance-attribute
FB999 = 'FB999: unknown error code sent by the node'
HashingAlgorithms
Bases: _BaseEnum
Enumeration class, used to characterize the hashing algorithms
Attributes
BLAKE2B class-attribute
instance-attribute
BLAKE2B = 'BLAKE2B'
BLAKE2S class-attribute
instance-attribute
BLAKE2S = 'BLAKE2S'
SHA256 class-attribute
instance-attribute
SHA256 = 'SHA256'
SHA384 class-attribute
instance-attribute
SHA384 = 'SHA384'
SHA3_256 class-attribute
instance-attribute
SHA3_256 = 'SHA3_256'
SHA3_384 class-attribute
instance-attribute
SHA3_384 = 'SHA3_384'
SHA3_512 class-attribute
instance-attribute
SHA3_512 = 'SHA3_512'
SHA512 class-attribute
instance-attribute
SHA512 = 'SHA512'
MessageType
Bases: _BaseEnum
Types of messages received by researcher
Attributes:
Name | Type | Description |
---|---|---|
REPLY | reply messages (TrainReply, SearchReply, etc.) | |
LOG | 'log' message (LogMessage) | |
SCALAR | 'add_scalar' message (Scalar) |
Attributes
LOG class-attribute
instance-attribute
LOG = 'LOG'
REPLY class-attribute
instance-attribute
REPLY = 'REPLY'
SCALAR class-attribute
instance-attribute
SCALAR = 'SCALAR'
Functions
convert classmethod
convert(type_)
Converts given text message to to MessageType instance
Source code in fedbiomed/common/constants.py
@classmethod
def convert(cls, type_):
"""Converts given text message to to MessageType instance"""
try:
return getattr(cls, type_.upper())
except AttributeError as exp:
raise FedbiomedError(f"There is no MessageType as {type_}") from exp
ProcessTypes
Bases: _BaseEnum
Enumeration class for Preprocess types
Attributes:
Name | Type | Description |
---|---|---|
DATA_LOADER | Preprocess for DataLoader | |
PARAMS | Preprocess for model parameters |
Attributes
DATA_LOADER class-attribute
instance-attribute
DATA_LOADER = 0
PARAMS class-attribute
instance-attribute
PARAMS = 1
SAParameters
Attributes
CLIPPING_RANGE class-attribute
instance-attribute
CLIPPING_RANGE = 3
KEY_SIZE class-attribute
instance-attribute
KEY_SIZE = 2048
TARGET_RANGE class-attribute
instance-attribute
TARGET_RANGE = 2 ** 13
WEIGHT_RANGE class-attribute
instance-attribute
WEIGHT_RANGE = 2 ** 17
SecaggElementTypes
Bases: _BaseEnum
Enumeration class for secure aggregation element types
Attributes:
Name | Type | Description |
---|---|---|
SERVER_KEY | int | server key split between the parties |
DIFFIE_HELLMAN | int | one pair of DH key for each node party, public key shared with other node parties |
Attributes
DIFFIE_HELLMAN class-attribute
instance-attribute
DIFFIE_HELLMAN = 1
SERVER_KEY class-attribute
instance-attribute
SERVER_KEY = 0
Functions
get_element_from_value staticmethod
get_element_from_value(element_value)
Source code in fedbiomed/common/constants.py
@staticmethod
def get_element_from_value(element_value: int):
for element in SecaggElementTypes:
if element.value == element_value:
return element
SecureAggregationSchemes
Bases: _BaseEnum
Enumeration class for secure aggregation schemes
Attributes
JOYE_LIBERT class-attribute
instance-attribute
JOYE_LIBERT = 1
LOM class-attribute
instance-attribute
LOM = 2
NONE class-attribute
instance-attribute
NONE = 0
TrainingPlanApprovalStatus
Bases: _BaseEnum
Enumeration class for training plan approval status of a training plan on a node when training plan approval is active.
Attributes:
Name | Type | Description |
---|---|---|
APPROVED | training plan was accepted for this node, can be executed now | |
REJECTED | training plan was disapproved for this node, cannot be executed | |
PENDING | training plan is waiting for review and approval, cannot be executed yet |
Attributes
APPROVED class-attribute
instance-attribute
APPROVED = 'Approved'
PENDING class-attribute
instance-attribute
PENDING = 'Pending'
REJECTED class-attribute
instance-attribute
REJECTED = 'Rejected'
Functions
str2enum
str2enum(name)
Source code in fedbiomed/common/constants.py
def str2enum(name: str):
for e in TrainingPlanApprovalStatus:
if e.value == name:
return e
return None
TrainingPlanStatus
Bases: _BaseEnum
Constant values for training plan type that will be saved into db
Attributes:
Name | Type | Description |
---|---|---|
REQUESTED | means training plan submitted in-application by the researcher | |
REGISTERED | means training plan added by a hospital/node | |
DEFAULT | means training plan is default training plan provided by Fed-BioMed |
Attributes
DEFAULT class-attribute
instance-attribute
DEFAULT = 'default'
REGISTERED class-attribute
instance-attribute
REGISTERED = 'registered'
REQUESTED class-attribute
instance-attribute
REQUESTED = 'requested'
TrainingPlans
Bases: _BaseEnum
Enumeration class for Training plans
Attributes
SkLearnTrainingPlan class-attribute
instance-attribute
SkLearnTrainingPlan = 'SkLearnTrainingPlan'
TorchTrainingPlan class-attribute
instance-attribute
TorchTrainingPlan = 'TorchTrainingPlan'
UserRequestStatus
Bases: str
, _BaseEnum
Enumeration class, used to characterize the status for user registration requests
Attributes:
Name | Type | Description |
---|---|---|
NEW | New user registration | |
REJECTED | Rejected status |
Attributes
NEW class-attribute
instance-attribute
NEW = 'NEW'
REJECTED class-attribute
instance-attribute
REJECTED = 'REJECTED'
UserRoleType
Bases: int
, _BaseEnum
Enumeration class, used to characterize the type of component of the fedbiomed architecture
Attributes:
Name | Type | Description |
---|---|---|
ADMIN | User with Admin role | |
USER | Simple user |
Attributes
ADMIN class-attribute
instance-attribute
ADMIN = 1
USER class-attribute
instance-attribute
USER = 2