OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 import logging | 2 import logging |
3 import subprocess | 3 import subprocess |
4 import json | 4 import json |
5 import os | 5 import os |
6 | 6 |
7 import systems.cassandra.setup as cas | 7 import systems.cassandra.setup as cas |
8 from systems.cassandra.launch_cassandra import launch_cassandras | 8 from systems.cassandra.launch_cassandra import launch_cassandras |
9 import systems.ycsb.ycsb_wrapper as ycsb | 9 import systems.ycsb.ycsb_wrapper as ycsb |
10 from systems.ycsb.setup import setup_ycsb | 10 from systems.ycsb.setup import setup_ycsb |
11 from pytools.experiments.exp_common import mkdir_unique_results_folder, setup_ex
periment_folder | 11 from pytools.experiments.exp_common import setup_experiment_folder |
12 from pytools.common.common import wait_with_message | 12 from ml.tools import train_model |
| 13 |
13 | 14 |
14 def experiment_cleanup(FLAGS, conf): | 15 def experiment_cleanup(FLAGS, conf): |
15 logging.info("CLEANUP START") | 16 logging.info("CLEANUP START") |
16 subprocess.check_call("sudo mn -c", shell=True) | 17 subprocess.check_call("sudo mn -c", shell=True) |
17 | 18 |
18 killname = os.path.join(conf["env"]["path_lx3"], "./common/lx3/killname") | 19 killname = os.path.join(conf["env"]["path_lx3"], "./common/lx3/killname") |
19 | 20 |
20 subprocess.check_call("%s xterm" % killname, shell=True) | 21 subprocess.check_call("%s xterm" % killname, shell=True) |
21 subprocess.check_call("%s mn" % killname, shell=True) | 22 subprocess.check_call("%s mn" % killname, shell=True) |
22 subprocess.check_call("%s pox" % killname, shell=True) | 23 subprocess.check_call("%s pox" % killname, shell=True) |
(...skipping 23 matching lines...) Expand all Loading... |
46 """ | 47 """ |
47 logging.info("PREPARE START") | 48 logging.info("PREPARE START") |
48 | 49 |
49 cas.setup_cassandra(FLAGS, conf) | 50 cas.setup_cassandra(FLAGS, conf) |
50 | 51 |
51 setup_ycsb(FLAGS, conf) | 52 setup_ycsb(FLAGS, conf) |
52 | 53 |
53 logging.info("PREPARE END") | 54 logging.info("PREPARE END") |
54 | 55 |
55 | 56 |
| 57 def prepare_ml_model(FLAGS, conf): |
| 58 """ |
| 59 This function will train the model for estimating |
| 60 speculative method and save the model to the file. |
| 61 """ |
| 62 logging.info("MODEL TRAINING START") |
| 63 |
| 64 upperbound = conf["env"]["upperbound"] |
| 65 data_path = conf["env"]["data_path"] |
| 66 # NB! This path should be the same as in predict.py |
| 67 model_save_path = conf["env"]["model_path"] |
| 68 train_model(model_save_path, data_path, upperbound) |
| 69 |
| 70 logging.info("MODEL TRAINING END") |
| 71 |
| 72 |
56 def experiment_launch_systems(FLAGS, conf, net): | 73 def experiment_launch_systems(FLAGS, conf, net): |
57 | 74 |
58 logging.info("LAUNCHING SYSTEMS START") | 75 logging.info("LAUNCHING SYSTEMS START") |
59 | 76 |
60 launch_cassandras(FLAGS, conf, net) | 77 launch_cassandras(FLAGS, conf, net) |
61 | 78 |
62 logging.info("LAUNCHING SYSTEMS END") | 79 logging.info("LAUNCHING SYSTEMS END") |
63 | 80 |
64 | 81 |
65 | |
66 def experiment_run(FLAGS, conf, net, exp_name="sample"): | 82 def experiment_run(FLAGS, conf, net, exp_name="sample"): |
67 # Run experiment only if it configured to be run! | 83 # Run experiment only if it configured to be run! |
68 ···· | |
69 if not conf["cassandra"]["setup"]["cas_run_experiment"]: | 84 if not conf["cassandra"]["setup"]["cas_run_experiment"]: |
70 return | 85 return |
71 | 86 |
72 logging.info("EXPERIMENT START") | 87 logging.info("EXPERIMENT START") |
73 | 88 |
74 out_fldr = setup_experiment_folder( | 89 out_fldr = setup_experiment_folder( |
75 exp_name=exp_name, where=conf["env"]["out_exp_dir"]) | 90 exp_name=exp_name, where=conf["env"]["out_exp_dir"]) |
76 | 91 |
77 with open(os.path.join(out_fldr, "config.json"), "w") as jfile: | 92 with open(os.path.join(out_fldr, "config.json"), "w") as jfile: |
78 jfile.write(json.dumps(conf, indent=4)) | 93 jfile.write(json.dumps(conf, indent=4)) |
(...skipping 18 matching lines...) Expand all Loading... |
97 | 112 |
98 out_fldr = setup_experiment_folder( | 113 out_fldr = setup_experiment_folder( |
99 exp_name="ycsb_load", where=conf["env"]["out_exp_dir"]) | 114 exp_name="ycsb_load", where=conf["env"]["out_exp_dir"]) |
100 | 115 |
101 # If system just boots up some insertions might fail, hence we do it twice. | 116 # If system just boots up some insertions might fail, hence we do it twice. |
102 experiment_cleanup_ycsb(FLAGS, conf) | 117 experiment_cleanup_ycsb(FLAGS, conf) |
103 ycsb.load_ycsb(FLAGS, conf, net, out_fldr) | 118 ycsb.load_ycsb(FLAGS, conf, net, out_fldr) |
104 ycsb.load_ycsb(FLAGS, conf, net, out_fldr) | 119 ycsb.load_ycsb(FLAGS, conf, net, out_fldr) |
105 | 120 |
106 logging.info("YCSB Loading END") | 121 logging.info("YCSB Loading END") |
OLD | NEW |