Attributes
component_root module-attribute
component_root = get('FBM_RESEARCHER_COMPONENT_ROOT', None)
config module-attribute
config = initiate(root=component_root)
researcher_component module-attribute
researcher_component = ResearcherComponent()
Classes
ResearcherComponent
ResearcherComponent()
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 = ResearcherConfig
Functions
initiate
initiate(root=None)
Creates or initiates existing component
Source code in fedbiomed/researcher/config.py
def initiate(self, root: Optional[str] = None) -> ResearcherConfig:
"""Creates or initiates existing component"""
config = super().initiate(root)
notebooks_path = os.path.join(config.root, NOTEBOOKS_FOLDER_NAME)
notebooks_share_path = os.path.join(SHARE_DIR, NOTEBOOKS_FOLDER_NAME)
docs_share_path = os.path.join(SHARE_DIR, DOCS_FOLDER_NAME)
if not os.path.isdir(notebooks_path):
shutil.copytree(notebooks_share_path, notebooks_path, symlinks=True)
shutil.copytree(
os.path.join(docs_share_path, TUTORIALS_FOLDER_NAME),
os.path.join(notebooks_path, TUTORIALS_FOLDER_NAME),
symlinks=True,
dirs_exist_ok=True,
)
return config
ResearcherConfig
ResearcherConfig(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 = 'RESEARCHER'
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("FBM_SERVER_HOST", "localhost")
grpc_port = os.getenv("FBM_SERVER_PORT", "50051")
node_disconnection_timeout = str(
os.getenv("FBM_SERVER_NODE_DISCONNECTION_TIMEOUT", "10")
)
# 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,
"node_disconnection_timeout": node_disconnection_timeout,
}
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(
"FBM_SECURITY_SECAGG_INSECURE_VALIDATION", True
)
}
migrate
migrate()
Please add migrated parameters for the new version.
See Config.migrate for more information
Source code in fedbiomed/researcher/config.py
def migrate(self):
"""Please add migrated parameters for the new version.
See [`Config.migrate`][fedbiomed.common.config.Config.migrate] for more information
"""
if "node_disconnection_timeout" not in self._cfg["server"]:
logger.warning(
"DEPRECATION: You are using an old configuration file for researcher. "
"Please add 'node_disconnection_timeout' value in `server` section "
"of the researcher configuration."
)
self._cfg["server"].update(
{
"node_disconnection_timeout": str(
os.getenv("FBM_SERVER_NODE_DISCONNECTION_TIMEOUT", "10")
)
}
)