kpi_csv_sq.py : bug fix for different test-rigs

Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
Chuck SmileyRekiere
2021-08-04 14:29:38 -06:00
parent 525257401d
commit 5d27932036

View File

@@ -84,54 +84,55 @@ class csv_sqlite_dash():
test_tag_list = list(df3['test-tag']) test_tag_list = list(df3['test-tag'])
test_tag_list = list(set(test_tag_list)) test_tag_list = list(set(test_tag_list))
for test_tag in test_tag_list: test_rig_list = list(df3['test-rig'])
for group in graph_group_list: test_rig_list = list(set(test_rig_list))
df_tmp = df3.loc[(df3['Graph-Group'] == str(group)) & (df3['test-tag'] == str(test_tag))]
if df_tmp.empty == False:
kpi_fig = (px.scatter(df_tmp, x="Date", y="numeric-score",
color="short-description", hover_name="short-description",
size_max=60)).update_traces(mode='lines+markers')
# remove duplicates from for test_rig in test_rig_list:
test_rig_list = list(df_tmp['test-rig']) for test_tag in test_tag_list:
test_rig = list(set(test_rig_list)) for group in graph_group_list:
df_tmp = df3.loc[(df3['test-rig'] == test_rig) & (df3['Graph-Group'] == str(group)) & (df3['test-tag'] == str(test_tag))]
if df_tmp.empty == False:
kpi_fig = (px.scatter(df_tmp, x="Date", y="numeric-score",
color="short-description", hover_name="short-description",
size_max=60)).update_traces(mode='lines+markers')
test_id_list = list(df_tmp['test-id']) # remove duplicates from
test_id = list(set(test_id_list)) test_id_list = list(df_tmp['test-id'])
test_id = list(set(test_id_list))
kpi_path_list = list(df_tmp['kpi_path']) kpi_path_list = list(df_tmp['kpi_path'])
kpi_path = list(set(kpi_path_list)) kpi_path = list(set(kpi_path_list))
units_list = list(df_tmp['Units']) units_list = list(df_tmp['Units'])
units = list(set(units_list)) units = list(set(units_list))
kpi_fig.update_layout( kpi_fig.update_layout(
title="{} : {} : {} : {}".format(test_id[0], group, test_tag, test_rig[0]), title="{} : {} : {} : {}".format(test_id[0], group, test_tag, test_rig),
xaxis_title="Time", xaxis_title="Time",
yaxis_title="{}".format(units[0]), yaxis_title="{}".format(units[0]),
xaxis = {'type' : 'date'} xaxis = {'type' : 'date'}
) )
# save the figure - this may need to be re-written # save the figure - this may need to be re-written
print("kpi_path:{}".format(df_tmp['kpi_path'])) print("kpi_path:{}".format(df_tmp['kpi_path']))
png_path = os.path.join(kpi_path[0],"{}_{}_{}_{}_kpi.png".format(test_id[0], group, test_tag, test_rig[0])) png_path = os.path.join(kpi_path[0],"{}_{}_{}_{}_kpi.png".format(test_id[0], group, test_tag, test_rig))
print("png_path {}".format(png_path)) print("png_path {}".format(png_path))
kpi_fig.write_image(png_path,scale=1,width=1200,height=350) kpi_fig.write_image(png_path,scale=1,width=1200,height=350)
# use image from above to creat html display # use image from above to creat html display
self.children_div.append(dcc.Graph(figure=kpi_fig)) self.children_div.append(dcc.Graph(figure=kpi_fig))
#TODO the link must be to a server to display html #TODO the link must be to a server to display html
# WARNING: os.path.join will use the path for where the script is RUN which can be container. # WARNING: os.path.join will use the path for where the script is RUN which can be container.
# need to construct path to server manually. DO NOT USE os.path.join # need to construct path to server manually. DO NOT USE os.path.join
#TODO need to work out the reporting paths - pass in path adjust #TODO need to work out the reporting paths - pass in path adjust
index_html_path = self.server + kpi_path[0] + "index.html" index_html_path = self.server + kpi_path[0] + "index.html"
index_html_path = index_html_path.replace('/home/lanforge/','') index_html_path = index_html_path.replace('/home/lanforge/','')
self.children_div.append(html.A('{}_{}_{}_{}_index.html'.format(test_id[0], group, test_tag, test_rig[0]), self.children_div.append(html.A('{}_{}_{}_{}_index.html'.format(test_id[0], group, test_tag, test_rig),
href=index_html_path, target='_blank')) href=index_html_path, target='_blank'))
self.children_div.append(html.Br()) self.children_div.append(html.Br())
self.children_div.append(html.A('html_reports', href=self.server_html_reports, target='_blank')) self.children_div.append(html.A('html_reports', href=self.server_html_reports, target='_blank'))
self.children_div.append(html.Br()) self.children_div.append(html.Br())
self.children_div.append(html.Br()) self.children_div.append(html.Br())
# access from server # access from server
# https://stackoverflow.com/questions/61678129/how-to-access-a-plotly-dash-app-server-via-lan # https://stackoverflow.com/questions/61678129/how-to-access-a-plotly-dash-app-server-via-lan