-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_fl_experiment.sh
More file actions
executable file
·41 lines (31 loc) · 1.12 KB
/
run_fl_experiment.sh
File metadata and controls
executable file
·41 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# run_fl_experiment.sh
set -e
# Set Python path to include the project root
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
echo "[FL Experiment] Starting Federated Learning experiment..."
# Cleanup on exit
cleanup() {
echo "[FL Experiment] Cleaning up processes..."
kill $(jobs -p) 2>/dev/null || true
exit 0
}
trap cleanup EXIT INT TERM
# Start server in background
echo "[FL Experiment] Starting server on port 8080..."
python model_side/federated/server.py --server_address 127.0.0.1:8080 --num_rounds 10 --num_clients 3 --local_epochs 3 &
SERVER_PID=$!
# Wait for server to start
sleep 5
if ! ps -p $SERVER_PID > /dev/null; then
echo "[FL Experiment] ERROR: Server failed to start"
exit 1
fi
# Start clients
echo "[FL Experiment] Starting 3 clients..."
python model_side/federated/client.py --client_id 0 --server_address 127.0.0.1:8080 &
python model_side/federated/client.py --client_id 1 --server_address 127.0.0.1:8080 &
python model_side/federated/client.py --client_id 2 --server_address 127.0.0.1:8080 &
echo "[FL Experiment] All processes started. Monitoring..."
# Wait for all processes
wait