Attributes
Classes
ResearcherConfig
ResearcherConfig(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 researcher config
Source code in fedbiomed/researcher/config.py
def add_parameters(self):
"""Generate researcher config"""
grpc_host = os.getenv('RESEARCHER_SERVER_HOST', 'localhost')
grpc_port = os.getenv('RESEARCHER_SERVER_PORT', '50051')
# Generate certificate for gRPC server
key_file, pem_file = generate_certificate(
root=self.root,
prefix=SERVER_certificate_prefix,
component_id=self._cfg['default']['id'],
subject={'CommonName': grpc_host}
)
self._cfg['server'] = {
'host': grpc_host,
'port': grpc_port,
}
self._cfg["certificate"] = {
"private_key": os.path.relpath(key_file, os.path.join(self.root, CONFIG_FOLDER_NAME)),
"public_key": os.path.relpath(pem_file, os.path.join(self.root, CONFIG_FOLDER_NAME))
}
self._cfg['security'] = {
'secagg_insecure_validation': os.getenv('SECAGG_INSECURE_VALIDATION', True)
}