Attributes
Classes
NodeConfig
NodeConfig(root=None, name=None, auto_generate=True)
Bases: Config
Source code in fedbiomed/common/config.py
def __init__(
self, root=None, name: Optional[str] = None, auto_generate: bool = True
) -> None:
"""Initializes config"""
# First try to get component specific config file name, then CONFIG_FILE
default_config = os.getenv(
f"{self._COMPONENT_TYPE}_CONFIG_FILE",
os.getenv("CONFIG_FILE", self._DEFAULT_CONFIG_FILE_NAME),
)
self.root = root
self._cfg = configparser.ConfigParser()
self.name = name if name else default_config
if self.root:
self.path = os.path.join(self.root, CONFIG_FOLDER_NAME, self.name)
self.root = self.root
else:
self.path = os.path.join(CONFIG_DIR, self.name)
self.root = ROOT_DIR
# Creates setup folders if not existing
create_fedbiomed_setup_folders(self.root)
if auto_generate:
self.generate()
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('ALLOW_DEFAULT_TRAINING_PLANS', 'True'),
'training_plan_approval': os.getenv('ENABLE_TRAINING_PLAN_APPROVAL', 'False'),
'secure_aggregation': os.getenv('SECURE_AGGREGATION', 'True'),
'force_secure_aggregation': os.getenv('FORCE_SECURE_AGGREGATION', 'False'),
'secagg_insecure_validation': os.getenv('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('RESEARCHER_SERVER_HOST', 'localhost'),
'port': os.getenv('RESEARCHER_SERVER_PORT', '50051')
}