-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmarking_tool.py
More file actions
70 lines (54 loc) · 1.92 KB
/
benchmarking_tool.py
File metadata and controls
70 lines (54 loc) · 1.92 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
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
import argparse
from src.deployer.deployer import deploy,destroy
from src.invoker.scriptExperiment import runExperiment
from src.mongo_to_csv_converter.mongoDB import returnDataframe
from pathlib import Path
import time
from src.utils.utils import handle_error
import pandas as pd
import subprocess
def parse_input():
parser = argparse.ArgumentParser()
parser.add_argument("--mode","--mode", choices=['destroy','deploy','analyze','invoke','convertToCsv','all'],
help="If you choose all it will be first deployed,invoked,and and the analyzer will be started",required=True)
return parser.parse_args().mode
def tool():
mode = parse_input()
dir_path = Path(__file__).parent
terr_path = dir_path / 'terraform/'
df = pd.DataFrame({})
if mode == 'destroy':
try:
print(terr_path)
destroy(dest_terraform_path_folder=terr_path)
return
except Exception as e:
handle_error(e)
return
if mode == 'deploy' or mode=='all':
try:
deploy(dest_terraform_path_folder=terr_path)
except Exception as e:
handle_error(e)
return
if mode == 'invoke' or mode=='all':
try:
runExperiment()
except Exception as e:
handle_error(e)
return
if mode == "convertToCsv" or mode == "all":
try:
output_dir = 'experiments'
output_file = f'experiments{time.strftime("%Y%m%d-%H%M%S")}.csv'
output_path = dir_path / output_dir / output_file
df = returnDataframe()
df.to_csv(f'{output_path}')
except Exception as e:
handle_error(e)
return
if mode=='analyze' or mode=='all':
command = ["streamlit", "run", "./src/anaylzer/analyzer.py"]
subprocess.run(command, check=True)
if __name__ == "__main__":
tool()