-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils.py
55 lines (46 loc) · 1.59 KB
/
utils.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
"""
Author: Sonu Prasad
Email: sonu.prasad@mycit.ie
file: utils.py
"""
import logging
import plotly as py
import plotly.graph_objs as go
from plotly import tools
def print_multi_line_graph(data, file_name, graph_title):
# Create and style traces
trace0 = go.Scatter(
x=data,
y=list(map(lambda x: x/len(data), range(len(data)))),
line=dict(
color='rgb(251, 212, 138)',
width=4)
)
new_data = [trace0]
# Edit the layout
layout = dict(title=graph_title,
xaxis=dict(title='Run Time'),
yaxis=dict(title='Iteration COunt'),
)
fig = dict(data=new_data, layout=layout)
py.offline.plot(fig, filename=file_name)
def initialize_loggers(file_name):
"""
Initialize Logging
:return:
- log_array: Which consists of multiple objects of Logging
- logging- Besic logging which can be used at the root level
"""
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='{}.log'.format(file_name),
filemode='a')
console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
logging.info('*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-Initializing*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-')
logging.info('Setting up Loggers')
return logging