Server for orchestrating brain FL experiments
The server runs with Docker Compose as three containers:
vpn-server: a WireGuard server that the nodes and the researcher connect to, with Fed-BioMed'sconfigure_peertool. Files are invpnserver_config/.researcher-vpn: a WireGuard client for the researcher. Files are inresearcher_vpn_config/.researcher: the publishedfedbiomed/researcherimage, using the network of theresearcher-vpncontainer to reach the nodes, with Jupyter on http://localhost:8888. Files are infbm-researcher/.
- Docker with the Compose plugin (
docker compose) - Inbound UDP access to port 51820, for the nodes to reach the VPN server
-
Create the
.envfile and setCONTAINER_UID/CONTAINER_GIDto the output ofid -u/id -g:cp .env.example .env
-
Create the VPN server configuration. Set
VPN_SERVER_PUBLIC_ADDRto the public IP address or DNS name of this machine.cp vpnserver_config/config.env.sample vpnserver_config/config.env
-
Build and start the VPN server:
docker compose up -d --build vpn-server
-
Create the researcher peer and copy its configuration to the researcher VPN client:
docker compose exec vpn-server configure_peer genconf researcher researcher cp vpnserver_config/config_peers/researcher/researcher/config.env researcher_vpn_config/ -
Start the researcher:
docker compose up -d --build
-
Register the public key of the researcher on the VPN server:
docker compose exec vpn-server configure_peer add researcher researcher "$(docker compose exec -T researcher-vpn wg show wg0 public-key)"
-
Check that all containers are running and that the researcher can reach the VPN server:
scripts/vpn_status
-
Set the node ID
export NODE_ID=<NODE_ID>
-
Create the node peer:
docker compose exec vpn-server configure_peer genconf node $NODE_ID
-
Send
vpnserver_config/config_peers/node/${NODE_ID}/config.envto the site running the node via a secure channel. -
Once the site has started its node, register the WireGuard public key it sends back:
docker compose exec vpn-server configure_peer add node $NODE_ID <PUBLIC_KEY>
-
List the peers and their keys:
docker compose exec vpn-server configure_peer list
The nodes must first approve the training plans. Send them to the nodes with:
docker compose exec -u fedbiomed researcher python /brainflex-server/scripts/request_training_plan_approval.pyEach site then approves them on its node with docker compose exec -u fedbiomed node fedbiomed node -p /fbm-node training-plan approve. Run the script again to check that all nodes have approved them.
The experiment script can be invoked via e.g.:
docker compose exec -u fedbiomed researcher python /brainflex-server/scripts/run_experiments.py --helpThe output directory should be /fbm-researcher/results inside the container.
docker compose downTo start from scratch, delete everything in vpnserver_config/, researcher_vpn_config/ and fbm-researcher/ except .gitkeep and config.env.sample.
This project uses uv.
uv syncuv run prek install
uv run prek run -auv run pytest