Config

Attributes

component_root module-attribute

component_root = get('FBM_NODE_COMPONENT_ROOT', None)

node_component module-attribute

node_component = NodeComponent()

Classes

NodeComponent

NodeComponent()

Bases: Component

Fed-BioMed Node Component Class

This class is used for creating and validating components by given component root directory

Source code in fedbiomed/common/config.py
def __init__(self):
    """Test"""
    self._reference = '.fedbiomed'

Attributes

config_cls class-attribute instance-attribute
config_cls = NodeConfig

Functions

initiate
initiate(root=None)
Source code in fedbiomed/node/config.py
def initiate(self, root: Optional[str] = None) -> NodeConfig:
    config = super().initiate(root)
    node_data_path = os.path.join(config.root, NODE_DATA_FOLDER)
    os.makedirs(node_data_path, exist_ok=True)
    return config

NodeConfig

NodeConfig(root)

Bases: Config

Parameters:

Name Type Description Default
root str

Root directory for the component

required
Source code in fedbiomed/common/config.py
def __init__(
    self, root: str
) -> None:
    """Initializes configuration

    Args:
        root: Root directory for the component
    """
    self._cfg = configparser.ConfigParser()
    self.load(root)

Attributes

COMPONENT_TYPE class-attribute instance-attribute
COMPONENT_TYPE = 'NODE'

Functions

add_parameters
add_parameters()

Generate Node config

Source code in fedbiomed/node/config.py
def add_parameters(self):
    """Generate `Node` config"""

    # Security variables
    self._cfg['security'] = {
        'hashing_algorithm': HashingAlgorithms.SHA256.value,
        'allow_default_training_plans': os.getenv('FBM_SECURITY_ALLOW_DEFAULT_TRAINING_PLANS', 'True'),
        'training_plan_approval': os.getenv('FBM_SECURITY_TRAINING_PLAN_APPROVAL', 'False'),
        'secure_aggregation': os.getenv('FBM_SECURITY_SECURE_AGGREGATION', 'True'),
        'force_secure_aggregation': os.getenv('FBM_SECURITY_FORCE_SECURE_AGGREGATION', 'False'),
        'secagg_insecure_validation': os.getenv('FBM_SECURITY_SECAGG_INSECURE_VALIDATION', 'True'),
    }
    # Generate self-signed certificates
    key_file, pem_file = generate_certificate(
        root=self.root, component_id=self._cfg["default"]["id"], prefix=DEFAULT_CERT_NAME
    )

    self._cfg["certificate"] = {
        "private_key": os.path.relpath(key_file, os.path.join(self.root, "etc")),
        "public_key": os.path.relpath(pem_file, os.path.join(self.root, "etc"))
    }

    # gRPC server host and port
    self._cfg["researcher"] = {
        'ip': os.getenv('FBM_RESEARCHER_IP', 'localhost'),
        'port': os.getenv('FBM_RESEARCHER_PORT', '50051')
    }

Functions