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

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