Skip to content
Snippets Groups Projects
Commit 1528a598 authored by huongdm1896's avatar huongdm1896
Browse files

fix bug log dir

parent 057b13d7
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ This framework requires:
```bash
pip install -r requirements.txt
```
*Note:* You also need to install `tensorflow`, `tensorflow-datasets` `scikit-learn` and `numpy` if you want to run the provided Flower example.
*Note:* `requirements.txt` includes `tensorflow`, `tensorflow-datasets` `scikit-learn` and `numpy` using for the provided Flower example.
Navigate to `Run` directory:
......@@ -91,6 +91,7 @@ Configure instances of experiment in a json format, structure is shown below.
"args": [
],
"ip": "",
"modules": ["logger"],
"port": 8080
},
"clients": [
......@@ -205,7 +206,7 @@ python3 measure_instance.py -c config_instances.json -i 1 -x SingleTest -r 2
Run a campaign with all instances (`1` and `2`), and 2 repetitions:
```bash
python3 measure_instance.py -x CampaignTest -r 2
python3 measure_campaign.py -x CampaignTest -c config_instances.json -r 2
```
### Step 5. Output
......@@ -225,6 +226,7 @@ Output dir structure:
│ ├── Flwr_<timestamp>: Flower log
│ │ ├── Client_<ip>
│ │ ├── Server_<ip>
│ │ ├── training_results_<instance_name>_<time>.csv
│ ├── Flwr_<timestamp>
│ │ ├── Client_<ip>
│ │ ├── Server_<ip>
......
......@@ -2,7 +2,7 @@
"instances": {
"1": {
"instance": "fedAvg_cifar10",
"output_dir": "./eflwr/Log",
"output_dir": "./Log",
"dvfs_cpu": {
"dummy": true,
"baseline": false,
......@@ -11,11 +11,12 @@
"server": {
"command": "python3",
"args": [
"./eflwr/Flower_v1/server_1.py",
"./Flower_v1/server_1.py",
"-r 1",
"-s fedAvg"
],
"ip": "172.16.66.76",
"modules": ["logger"],
"port": 8080
},
"clients": [
......@@ -23,7 +24,7 @@
"name": "client1",
"command": "python3",
"args": [
"./eflwr/Flower_v1/client_1.py",
"./Flower_v1/client_1.py",
"cifar10",
"1",
"3"
......@@ -34,7 +35,7 @@
"name": "client2",
"command": "python3",
"args": [
"./eflwr/Flower_v1/client_1.py",
"./Flower_v1/client_1.py",
"cifar10",
"2",
"3"
......@@ -45,7 +46,7 @@
"name": "client3",
"command": "python3",
"args": [
"./eflwr/Flower_v1/client_1.py",
"./Flower_v1/client_1.py",
"cifar10",
"3",
"3"
......@@ -56,7 +57,7 @@
},
"2": {
"instance": "fedAvg2Clients_cifar10",
"output_dir": "./eflwr/Log",
"output_dir": "./Log",
"dvfs_cpu": {
"dummy": true,
"baseline": false,
......@@ -65,11 +66,12 @@
"server": {
"command": "python3",
"args": [
"./eflwr/Flower_v1/server_1.py",
"./Flower_v1/server_1.py",
"-r 1",
"-s fedAvg2Clients"
],
"ip": "172.16.66.76",
"modules": ["logger"],
"port": 8080
},
"clients": [
......@@ -77,7 +79,7 @@
"name": "client1",
"command": "python3",
"args": [
"./eflwr/Flower_v1/client_1.py",
"./Flower_v1/client_1.py",
"cifar10",
"1",
"3"
......@@ -88,7 +90,7 @@
"name": "client2",
"command": "python3",
"args": [
"./eflwr/Flower_v1/client_1.py",
"./Flower_v1/client_1.py",
"cifar10",
"2",
"3"
......@@ -99,7 +101,7 @@
"name": "client3",
"command": "python3",
"args": [
"./eflwr/Flower_v1/client_1.py",
"./Flower_v1/client_1.py",
"cifar10",
"3",
"3"
......
......@@ -20,8 +20,8 @@ parser.add_argument("-r", "--repeat", type=int, default=1, required=True, help="
args = parser.parse_args()
config_path = os.path.abspath(args.config)
config_dir = os.path.dirname(config_path)
root_dir = os.path.abspath(os.path.join(os.path.dirname(config_path), "..")) # Get root eflwr directory
print(root_dir)
try:
with open(args.config, "r") as file:
config_data = json.load(file)
......@@ -64,11 +64,13 @@ else:
# Log directory
# log_dir = config["output_dir"]
log_dir = os.path.abspath(config["output_dir"])
log_dir = os.path.abspath(os.path.join(root_dir, config["output_dir"])) if config["output_dir"].startswith("./") else config["output_dir"]
instance_name = config.get("instance", "default_instance")
flower_log_dir = os.path.join(log_dir, f"Flower_{args.suffix}", f"Flower_instance_{instance_name}", "Expetator")
os.makedirs(flower_log_dir, exist_ok=True)
print(flower_log_dir)
# Add the configure file to log directory
config_instance_path = os.path.join(flower_log_dir, f"config_instance_{instance_key}.json")
with open(config_instance_path, "w", encoding="utf-8") as file:
......
# python3 run_flwr_1.py -c config_instances.json -i 1 -x 1
# python3 run_flwr.py -c config_instances.json -i 1 -x 1
import os
import sys
......@@ -13,7 +13,7 @@ def main(config_path, instance, suffix):
print(f"Running Flower instance with instance: {instance} and suffix: {suffix}")
config_path = os.path.abspath(config_path)
config_dir = os.path.dirname(config_path)
root_dir = os.path.abspath(os.path.join(os.path.dirname(config_path), "..")) # Get root eflwr directory
# read json
try:
......@@ -33,14 +33,14 @@ def main(config_path, instance, suffix):
sys.exit(1)
# get server/client info
output_dir = os.path.abspath(os.path.join(config_dir, instance_config["output_dir"])) if instance_config["output_dir"].startswith("./") else instance_config["output_dir"]
output_dir = os.path.abspath(os.path.join(root_dir, instance_config["output_dir"])) if instance_config["output_dir"].startswith("./") else instance_config["output_dir"]
instance_name = instance_config.get("instance", f"default_instance_{instance}")
server_ip = instance_config["server"]["ip"]
server_port = instance_config["server"]["port"]
# Convert server args to absolute paths if needed
server_args = [
os.path.abspath(os.path.join(config_dir, arg)) if arg.startswith("./") else arg
os.path.abspath(os.path.join(root_dir, arg)) if arg.startswith("./") else arg
for arg in instance_config["server"]["args"]
]
server_command = [instance_config["server"]["command"], *server_args]
......@@ -51,15 +51,13 @@ def main(config_path, instance, suffix):
for client in clients:
client_ip = client["ip"]
client_args = [
os.path.abspath(os.path.join(config_dir, arg)) if arg.startswith("./") else arg
os.path.abspath(os.path.join(root_dir, arg)) if arg.startswith("./") else arg
for arg in client["args"]
]
client_command = [client["command"], *client_args, f'"{server_ip}:{server_port}"']
client_commands.append({"ip": client_ip, "command": client_command})
# print(server_command, client_commands)
# print(output_dir)
# return
# Create log for experiment Flower
current_time = datetime.now().strftime("%Y%m%d_%H%M%S")
flower_dir = os.path.join(output_dir, f"Flower_{suffix}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment