-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadconfig.py
More file actions
78 lines (65 loc) · 3.68 KB
/
loadconfig.py
File metadata and controls
78 lines (65 loc) · 3.68 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
71
72
73
74
75
76
77
78
import yaml
import os
import logging
import datetime
import pytz
class Configuration(object):
"""
"""
def __init__(self, curr_dataset):
self.config_ = dict()
self.dataset = curr_dataset
def load_msr_yaml(self):
file_name = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'msr_config.yml')
config_file = open(file=file_name)
all_config_dict = yaml.load(config_file, Loader=yaml.FullLoader)
self.config_["HUNDREDS_OF_SECONDS"] = all_config_dict["CONSTANTS"]["HUNDREDS_OF_SECONDS"]
self.config_["EPOCH_AS_FILETIME"] = all_config_dict["CONSTANTS"]["EPOCH_AS_FILETIME"]
self.config_["HEADER_LIST"] = all_config_dict["CONSTANTS"]["HEADER_LIST"]
self.config_["DATASET_FOLDER"] = all_config_dict["CONSTANTS"]["DATASET_FOLDER"]
self.config_["LOGGING_FOLDER"] = all_config_dict["CONSTANTS"]["LOGGING_FOLDER"]
self.config_["GRAPH_FOLDER"] = all_config_dict["CONSTANTS"]["GRAPH_FOLDER"]
self.config_["FILE_CONSTANTS"] = dict()
kv_pairs = all_config_dict["FILE_CONSTANTS"]
for key in kv_pairs.keys():
self.config_["FILE_CONSTANTS"][key] = kv_pairs[key]
del kv_pairs
self.config_["FUNCTIONALITIES"] = dict()
kv_pairs = all_config_dict["FUNCTIONALITIES"]
for key in kv_pairs:
self.config_["FUNCTIONALITIES"][key] = kv_pairs[key]
def load_cp_yaml(self):
file_name = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'cp.yml')
config_file = open(file=file_name)
all_config_dict = yaml.load(config_file, Loader=yaml.FullLoader)
self.config_["DATASET_FOLDER"] = all_config_dict["CONSTANTS"]["DATASET_FOLDER"]
self.config_["LOGGING_FOLDER"] = all_config_dict["CONSTANTS"]["LOGGING_FOLDER"]
self.config_["GRAPH_FOLDER"] = all_config_dict["CONSTANTS"]["GRAPH_FOLDER"]
self.config_["RESULTS_FOLDER"] = all_config_dict["CONSTANTS"]["RESULTS_FOLDER"]
self.config_["READ_OPCODES"] = all_config_dict["READ_OPCODES"]
self.config_["WRITE_OPCODES"] = all_config_dict["WRITE_OPCODES"]
self.config_["TYPE_1_INDICES"] = all_config_dict["TYPE_1_INDICES"]
self.config_["TYPE_2_INDICES"] = all_config_dict["TYPE_2_INDICES"]
def load_cpb_yaml(self, ip_path, op_path, split_file, compute_stat=None, op_aggr=None, compare_days=None):
file_name = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'cpb.yml')
config_file = open(file=file_name)
all_config_dict = yaml.load(config_file, Loader=yaml.FullLoader)
self.config_["DATASET_FOLDER"] = all_config_dict["CONSTANTS"]["DATASET_FOLDER"]
self.config_["LOGGING_FOLDER"] = all_config_dict["CONSTANTS"]["LOGGING_FOLDER"]
self.config_["GRAPH_FOLDER"] = all_config_dict["CONSTANTS"]["GRAPH_FOLDER"]
self.config_["RESULTS_FOLDER"] = all_config_dict["CONSTANTS"]["RESULTS_FOLDER"]
self.config_["DAY_MS"] = all_config_dict["CONSTANTS"]["DAY_MS"]
self.config_["HEADERS"] = all_config_dict["HEADERS"]
self.config_["IP_PATH"] = ip_path
self.config_["OP_PATH"] = op_path
self.config_["SPLIT_PATH"] = split_file
self.config_["OP_AGGR"] = op_aggr
self.config_["COMPUTE_STAT"] = compute_stat
self.config_["COMPARE_DAYS"] = compare_days
def load_logging_config(self):
time_zone = pytz.timezone('US/Eastern')
curr_date = datetime.datetime.now(tz=time_zone)
date_as_string = curr_date.strftime('%Y-%m-%d_%H-%M-%S')
logging.basicConfig(filename="./{}/{}.log".format(self.config_["LOGGING_FOLDER"], date_as_string),
level=logging.INFO)
config = Configuration(curr_dataset="def")