-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_experiments.py
158 lines (110 loc) · 5.87 KB
/
run_experiments.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
from run_experiment import run_experiment
import os
import subprocess
import sys
import time
import json
from update_json import update
from pathlib import Path
from setup_network_delay_test import setup_network_delay
from set_config import set_config
######### Main Script for running the experiments. #################
# This will call all of the other scripts/function that setup nodes,
# add latency and adjust configs.
####################################################################
# Replaces fig4 with fig4a fig4b fig4c
def replace_fig4(config_paths):
last_slash_index = config_paths[0].rfind("/")
parent_path = config_paths[0][:last_slash_index + 1]
for config_path in config_paths:
if "fig4.json" in config_path:
# remove fig4
config_paths.remove(config_path)
# add fig4a fig4b fig4c
for x in ["a", "b", "c"]:
config_paths.append(parent_path + "fig4" + x + ".json")
return config_paths
def run():
now_string = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime())
parent_path = Path("/root/go/src/gus-automation/")
base_config_file = open("configs/config.json")
base_config = json.load(base_config_file)
results_parent_path = Path(base_config["base_control_experiment_directory"]) / now_string
config_paths = sys.argv[1:]
# Adjusts for fig4
config_paths = replace_fig4(config_paths)
print("Here are config_paths: " , config_paths)
# Need to adjust for figure 11 and figure 8 which just runs gus, but changes n ( =3, =5, =7, =9)
for config_path in config_paths:
# adjust user name
set_config(config_path)
# adjusts conflict rate - NEED TO FIX PATHING - fig4a not showing up
if "fig4a" in config_path:
update(config_path,"conflict_percentage", 2)
elif "fig4b" in config_path:
update(config_path,"conflict_percentage", 10)
elif "fig4c" in config_path:
update(config_path,"conflict_percentage", 25)
# default is all protocols
protocols = ["gus", "epaxos", "gryff"]
# Figs 8 and 9 plotting is combined gus and giza only
if "fig9" in config_path or "fig8" in config_path:
protocols = ["gus", "giza"]
# Fig 11 and 8 is just gus
if "fig11" in config_path:
protocols = ["gus"]
print("Config path = " , config_path)
# Get final fig name:
trimmed_fig = config_path.split("/")[-1].replace(".json", "")
temp_path = results_parent_path / (trimmed_fig)
for protocol in protocols:
print("\nRunning", protocol, config_path, "...\n")
update(config_path, "replication_protocol", protocol)
results_extension = Path(temp_path) / Path(protocol)
# NOT SURE WHY - Gryff not working
# For fig 7 (old fig 9 thought it was fig8), for each protocol, change throughput
if "fig7" in trimmed_fig:
write_percentages = [.1, .3, .5, .7, .9]
for wr in write_percentages:
update(config_path, "write_percentage", wr)
# For fig7, now results file structure is: TIMESTAMP/FIG7/PROTOCOL-WRITE_PERCENTAGE/CLIENT/...
results_extension_fig7 = Path(str(results_extension) + "-" +(str(wr)))
setup_network_delay(config_path)
run_experiment(results_extension_fig7, config_path)
# This is the Cloudlab experiment that should really be run with 3 and 5 replicas
elif "fig8n5.json" in config_path:
num_replicas = [3,5]
for n in num_replicas:
update(config_path, "number_of_replicas", n)
# For fig 8, now results file stricture is: TIMESTAMP/FIG8/PROTOCOL-NUM_REPLICAS/CLIENT/...
results_extension_fig8 = Path(str(results_extension) + "-" +(str(n)))
setup_network_delay(config_path)
run_experiment(results_extension_fig8, config_path)
# For fig8 and fig11 This is the Cloudlab experiment that should really be run with 7 and 9 replicas
elif "fig8" in config_path or "fig11" in config_path:
num_replicas = [7,9]
for n in num_replicas:
update(config_path, "number_of_replicas", n)
# For fig 8 or fig 11, now results file stricture is: TIMESTAMP/FIG#/PROTOCOL-NUM_REPLICAS/CLIENT/...
results_extension_add = Path(str(results_extension) + "-" +(str(n)))
setup_network_delay(config_path)
run_experiment(results_extension_add, config_path)
# for fig9, data size is altered between trials
elif "fig9" in config_path:
sizes = [4000, 40000, 400000, 4000000] # size of data packets in MB
for size in sizes:
update(config_path, "size", size)
# For fig9, now results file structure is TIMESTAMP/FIG9/PROTOCL-size/Client ...
results_extension_add = Path(str(results_extension) + "-" +(str(size)))
setup_network_delay(config_path)
run_experiment(results_extension_add, config_path)
else:
setup_network_delay(config_path)
run_experiment(results_extension, config_path)
# Must be run as:
# python run_n_experiments <config#> <config#> ...
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.stderr.write('Usage: python3 run_n_experiments <fig#> <fig#> ...\n' )
sys.exit(1)
run()