@@ -114,17 +114,23 @@ def bracketParse(parsethis):
114114
115115
116116def updateAggregation (df ):
117+ #print(f"\nStarting DF:\n{df}")
117118 filelist = []
118119 columns = ['title' , 'description' , 'count' ]
119120 agg_df = pd .DataFrame (columns = columns )
120121 for index , row in df .iterrows ():
121- if row ['title' ] == 'Updating existing data' :
122- if "file_id" in row ['description' ]:
123- filelist .append (row ['description' ])
122+ #print(f"\nRow:\n{row}")
123+ #if row['title'] == 'Updating existing data':
124+ if 'Updating' in row ['title' ]:
125+ #if "file_id" in row['description']:
126+ filelist .append (row ['description' ])
124127 else :
125128 agg_df .loc [len (agg_df )] = row
129+ #print(f"\nFinal aggregation:\n{agg_df}\n")
130+ #print(f"File list: {filelist}")
126131 if len (filelist ) > 0 :
127132 agg_df .loc [len (agg_df )] = {'title' : 'Updating existing data' , 'description' : 'File update' , 'count' : len (filelist )}
133+ #print(f"\nReturned dataframe:\n{agg_df}")
128134 return agg_df
129135
130136
@@ -146,15 +152,21 @@ def updateSubmissionClock(subid, tier):
146152 return updatejson
147153
148154
149- def buildBasicTable (df ):
155+ def buildBasicTable (df , diffstyle = None ):
156+ if diffstyle is None :
157+ styles = [{'if' :{'row_index' :'odd' }, 'backgroundColor' : 'rgb(220,220,220)' }]
158+ else :
159+ styles = diffstyle
160+
161+ print (f"Using styles: { styles } " )
150162
151163 return dash_table .DataTable (
152164 data = df .to_dict ('records' ),
153165 columns = [{"name" : e , "id" : e } for e in (df .columns )],
154166 style_table = {'overflowX' :'auto' },
155167 style_cell = {'overflow' :'hidden' , 'textOverflow' :'ellipsis' , 'maxWidth' :10 , 'textAlign' :'center' },
156168 style_data = {'color' :'black' , 'backgroundColor' :'white' },
157- style_data_conditional = [{ 'if' :{ 'row_index' : 'odd' }, 'backgroundColor' : 'rgb(220,220,220)' }] ,
169+ style_data_conditional = styles ,
158170 style_header = {'backgroundColor' : 'rgb(210,210,210)' , 'color' :'black' , 'fontWeight' :'bold' , 'textAlign' :'center' },
159171 tooltip_data = [
160172 {
@@ -167,6 +179,26 @@ def buildBasicTable(df):
167179 )
168180
169181
182+ def warningStyle (df ):
183+ styles = [{'if' :{'row_index' :'odd' }, 'backgroundColor' : 'rgb(220,220,220)' }]
184+ for i in range (1 , len (df ), 2 ):
185+ curr_row = df .iloc [i ]
186+ prev_row = df .iloc [i - 1 ]
187+ for col in df .columns :
188+ if col != 'EntryType' :
189+ #print(f"Comparing column {col}")
190+ if curr_row [col ] != prev_row [col ]:
191+ #print(f"Current: {curr_row[col]} DOES NOT match Prev: {prev_row[col]}")
192+ styles .append ({
193+ 'if' : {'row_index' : i , 'column_id' : f"{ col } " }, 'backgroundColor' : '#3498DB' , 'color' :'black'
194+ })
195+ #else:
196+ # print(f"Current: {curr_row[col]} MATCHES Prev: {prev_row[col]}")
197+ #print(f"Sending: {styles}")
198+ #styles = None
199+ return styles
200+
201+
170202
171203def diffDataFrame (subid , nodetype , nodeID , tier , query ):
172204 # This is used to create a df for data update warnings
@@ -198,6 +230,39 @@ def diffDataFrame(subid, nodetype, nodeID, tier, query):
198230 return report_df
199231
200232
233+
234+ def buildUpdateDataframe (subid , tier ):
235+ final_report_df = pd .DataFrame ()
236+ #Get a list of the nodes in the submission
237+ subvars = {"submissionID" : subid }
238+ sub_summary_res = apiQuery (tier = tier , query = dhq .submission_summary_query , variables = subvars )
239+ #print(f"Sub Summary Query results:\n{sub_summary_res}\n")
240+ nodelist = []
241+ if 'getSubmissionSummary' in sub_summary_res ['data' ]:
242+ #print("Valid getSubmissionSummary")
243+ for entry in sub_summary_res ['data' ]['getSubmissionSummary' ]:
244+ nodelist .append (entry ['nodeType' ])
245+ # Now get the node ID for each of the nodes:
246+ node_data = {}
247+ #print(f"Nodelist:\n{nodelist}\n")
248+ for node in nodelist :
249+ vars = {"_id" :subid , "nodeType" :node , "status" :"Warning" , "first" :- 1 , "offset" :0 , "orderBy" :"nodes" , "sortDirection" :"Desc" }
250+ node_res = apiQuery (tier = tier , query = dhq .submission_nodes_query , variables = vars )
251+ #print(f"Vars: {vars}\nNode results:\n{node_res}\n")
252+ if 'nodes' in node_res ['data' ]['getSubmissionNodes' ]:
253+ for entry in node_res ['data' ]['getSubmissionNodes' ]['nodes' ]:
254+ node_data [node ] = entry ['nodeID' ]
255+ else :
256+ return None
257+ for node , nodeID in node_data .items ():
258+ report_df = diffDataFrame (subid = subid , nodetype = node , nodeID = nodeID , tier = tier , query = dhq .retrieve_released_data_query )
259+ #print(f"Report dataframe:\n{report_df}\n")
260+ final_report_df = pd .concat ([final_report_df , report_df ]).drop_duplicates (keep = False )
261+ #print(f"Final report df:\n{final_report_df}\n")
262+ return final_report_df
263+ else :
264+ return None
265+
201266############################################
202267# #
203268# Styles #
@@ -831,6 +896,7 @@ def updateInactiveTime(n_clicks, tierselector, selectedsubmissionstore, selected
831896def populateStudyInfoTable (modified_timestamp , selectedsubmissionstore ):
832897 sub_df = pd .read_json (io .StringIO (selectedsubmissionstore ),orient = 'split' )
833898 data = sub_df .to_dict ('records' )
899+ #colors = {'new':'#3498DB' , 'error': '#E74C3C', 'warning': '#F4D03F', 'passed': '#16A085'}
834900 columns = [{"name" :e , "id" :e } for e in (sub_df .columns )]
835901 return dash_table .DataTable (id = 'selectedstudytable' ,
836902 data = data ,
@@ -839,9 +905,9 @@ def populateStudyInfoTable(modified_timestamp, selectedsubmissionstore):
839905 style_cell = {'overflow' :'hidden' , 'textOverflow' :'ellipsis' , 'maxWidth' :10 , 'textAlign' :'center' },
840906 style_data = {'color' :'black' , 'backgroundColor' :'white' },
841907 style_data_conditional = [{'if' :{'row_index' :'odd' }, 'backgroundColor' : 'rgb(220,220,220)' },
842- {'if' :{'filter_query' :'{inactiveDays} <= 45' , 'column_id' :'inactiveDays' }, 'backgroundColor' :'green ' , 'color' :'white ' },
843- {'if' :{'filter_query' :'{inactiveDays} >= 46 && {inactiveDays} <=59' , 'column_id' :'inactiveDays' }, 'backgroundColor' :'yellow ' , 'color' :'black' },
844- {'if' :{'filter_query' :'{inactiveDays} >= 60' , 'column_id' :'inactiveDays' }, 'backgroundColor' :'red ' , 'color' :'white ' }],
908+ {'if' :{'filter_query' :'{inactiveDays} <= 45' , 'column_id' :'inactiveDays' }, 'backgroundColor' :'#16A085 ' , 'color' :'black ' },
909+ {'if' :{'filter_query' :'{inactiveDays} >= 46 && {inactiveDays} <=59' , 'column_id' :'inactiveDays' }, 'backgroundColor' :'#F4D03F ' , 'color' :'black' },
910+ {'if' :{'filter_query' :'{inactiveDays} >= 60' , 'column_id' :'inactiveDays' }, 'backgroundColor' :'#E74C3C ' , 'color' :'black ' }],
845911 style_header = {'backgroundColor' : 'rgb(210,210,210)' , 'color' :'black' , 'fontWeight' :'bold' , 'textAlign' :'center' },
846912 row_selectable = "multi" ,
847913 sort_action = 'native' ,
@@ -933,21 +999,32 @@ def warningDetailTable(warningselector, submissionstore, subselector, tierselect
933999 sub_df = pd .read_json (io .StringIO (submissionstore ), orient = 'split' )
9341000 #print(sub_df)
9351001 idlist = sub_df .query ("name == @subselector" )["_id" ].tolist ()
936- #print(f"WarningSelector: {warningselector}\nIDList: {idlist}")
1002+ #print(f"WarningSelector: {warningselector}\nIDList: {idlist}\n ")
9371003 if len (idlist ) >= 1 :
9381004 subvars = {"submissionID" :idlist [0 ], "severity" :"Warning" , "first" :- 1 , "offset" :0 , "sortDirection" : "desc" , "orderBy" : "displayID" }
9391005 sub_res = apiQuery (tierselector , dhq .summaryQuery , subvars )
1006+ #print(f"Sub results:\n{sub_res}\n")
9401007 if sub_res ['data' ]['aggregatedSubmissionQCResults' ]['total' ] == 0 :
9411008 return dash_table .DataTable ()
9421009 else :
9431010 errorvars = {"id" : idlist [0 ], "severities" :"Warning" , "first" : - 1 , "offset" : 0 , "orderBy" :"displayID" , "sortDirection" :"desc" }
9441011 detail_res = apiQuery (tierselector , dhq .detailedQCQuery , errorvars )
1012+ #print(f"Detailed results:\n{detail_res}\n")
9451013 # TODO: for replacement warnings need to build in special handling
9461014 if warningselector == 'Updating existing data' :
947- print ('Update' )
1015+ #print("calling buildUpdateDataFrame")
1016+ update_df = buildUpdateDataframe (subid = idlist [0 ], tier = tierselector )
1017+ #print(f"Updating DF: \n{update_df}\n")
1018+ if update_df is not None :
1019+ styles = warningStyle (update_df )
1020+ print (f"Sending style: { styles } " )
1021+ return buildBasicTable (update_df , styles )
1022+ else :
1023+ return dash_table .DataTable ()
9481024 else :
9491025 columns = ['type' , 'title' , 'description' ]
9501026 warning_df = pd .DataFrame (columns = columns )
1027+ #print(f"Other warnings:\n{warning_df}\n")
9511028 for result in detail_res ['data' ]['submissionQCResults' ]['results' ]:
9521029 for warning in result ['warnings' ]:
9531030 if warning ['title' ] == warningselector :
@@ -1027,20 +1104,25 @@ def validationWarningSummaryTable(subselector, submissionstore, tierselector):
10271104 if len (idlist ) >= 1 :
10281105 subvars = {"submissionID" :idlist [0 ], "severity" :"Warning" , "first" :- 1 , "offset" :0 , "sortDirection" : "desc" , "orderBy" : "displayID" }
10291106 sub_res = apiQuery (tierselector , dhq .summaryQuery , subvars )
1107+ #print(f"Warning query results:\n{sub_res}")
10301108 if sub_res ['data' ]['aggregatedSubmissionQCResults' ]['total' ] == 0 :
10311109 return dash_table .DataTable ()
10321110 else :
10331111 columns = ['type' , 'title' , 'description' ]
10341112 error_df = pd .DataFrame (columns = columns )
10351113 errorvars = {"id" : idlist [0 ], "severities" :"Warning" , "first" : - 1 , "offset" : 0 , "orderBy" :"displayID" , "sortDirection" :"desc" }
10361114 detail_res = apiQuery (tierselector , dhq .detailedQCQuery , errorvars )
1115+ #print(f"Warnign detail:\n{detail_res}")
10371116 for result in detail_res ['data' ]['submissionQCResults' ]['results' ]:
10381117 for error in result ['warnings' ]:
10391118 message = bracketParse (error ['description' ])
10401119 error_df .loc [len (error_df )] = {'type' :'Error' , 'title' :error ['title' ], 'description' :message }
1120+ #print(f"Error dataframe:\n{error_df}")
10411121 temp_df = error_df .groupby (['title' , 'description' ]).size ().reset_index ().rename (columns = {0 :'count' }).sort_values (by = 'count' , ascending = False )
1122+ #print(f"Temp dataframe:\n{temp_df}")
10421123 summary_df = updateAggregation (temp_df )
10431124 summary_df = summary_df .sort_values (by = 'count' , ascending = False )
1125+ #print(f"Summary dataframe:\n{summary_df}")
10441126 return buildBasicTable (summary_df )
10451127 else :
10461128 return dash_table .DataTable ()
@@ -1104,7 +1186,9 @@ def validationWarningPieChart(subselector, submissionstore, tierselector):
11041186def subStatusChart (subselector , submissionstore , tierselector ):
11051187 sub_df = pd .read_json (io .StringIO (submissionstore ),orient = 'split' )
11061188 idlist = sub_df .query ("name == @subselector" )["_id" ].tolist ()
1107- colors = {'new' :'blue' , 'error' : 'red' , 'warning' :'yellow' , 'passed' :'green' }
1189+ #colors = {'new':'blue', 'error': 'red', 'warning':'yellow', 'passed':'green'}
1190+ #colors = {'new':'#74D4FF' , 'error': '#FFA2A2', 'warning': '#FFF085', 'passed': '#7BF1A8'}
1191+ colors = {'new' :'#3498DB' , 'error' : '#E74C3C' , 'warning' : '#F4D03F' , 'passed' : '#16A085' }
11081192 if len (idlist ) >= 1 :
11091193 qvars = {'id' : idlist [0 ]}
11101194 query_res = apiQuery (tierselector , dhq .submission_stats_query , qvars )
@@ -1127,7 +1211,9 @@ def subStatusChart(subselector, submissionstore, tierselector):
11271211def subStatusPercentageChart (subselector , submissionstore , tierselector ):
11281212 sub_df = pd .read_json (io .StringIO (submissionstore ),orient = 'split' )
11291213 idlist = sub_df .query ("name == @subselector" )["_id" ].tolist ()
1130- colors = {'new' :'blue' , 'error' : 'red' , 'warning' :'yellow' , 'passed' :'green' }
1214+ #colors = {'new':'blue', 'error': 'red', 'warning':'yellow', 'passed':'green'}
1215+ #colors = {'new':'#74D4FF' , 'error': '#FFA2A2', 'warning': '#FFF085', 'passed': '#7BF1A8'}
1216+ colors = {'new' :'#3498DB' , 'error' : '#E74C3C' , 'warning' : '#F4D03F' , 'passed' : '#16A085' }
11311217 if len (idlist ) >= 1 :
11321218 qvars = {'id' :idlist [0 ]}
11331219 query_res = apiQuery (tierselector , dhq .submission_stats_query , qvars )
0 commit comments