1414import plotly .graph_objects as go
1515from config import GM_FILTER_DROPDOWN_BGC_CLASS_OPTIONS
1616from config import GM_FILTER_DROPDOWN_MENU_OPTIONS
17+ from config import GM_RESULTS_TABLE_CHECKL_OPTIONAL_COLUMNS
1718from config import GM_RESULTS_TABLE_MANDATORY_COLUMNS
1819from config import GM_RESULTS_TABLE_OPTIONAL_COLUMNS
1920from config import MG_FILTER_DROPDOWN_MENU_OPTIONS
21+ from config import MG_RESULTS_TABLE_CHECKL_OPTIONAL_COLUMNS
2022from config import MG_RESULTS_TABLE_MANDATORY_COLUMNS
2123from config import MG_RESULTS_TABLE_OPTIONAL_COLUMNS
2224from config import SCORING_DROPDOWN_MENU_OPTIONS
5860# ------------------ Upload and Process Data ------------------ #
5961@du .callback (
6062 id = "dash-uploader" ,
61- output = [Output ("dash-uploader-output" , "children" ), Output ("file-store" , "data" )],
63+ output = [
64+ Output ("dash-uploader-output" , "children" ),
65+ Output ("file-store" , "data" ),
66+ Output ("loading-spinner-container" , "children" , allow_duplicate = True ),
67+ ],
6268)
63- def upload_data (status : du .UploadStatus ) -> tuple [str , str | None ]:
69+ def upload_data (status : du .UploadStatus ) -> tuple [str , str | None , None ]:
6470 """Handle file upload and validate pickle files.
6571
6672 Args:
@@ -77,22 +83,26 @@ def upload_data(status: du.UploadStatus) -> tuple[str, str | None]:
7783 return (
7884 f"Successfully uploaded: { os .path .basename (latest_file )} [{ round (status .uploaded_size_mb , 2 )} MB]" ,
7985 str (latest_file ),
86+ None ,
8087 )
8188 except (pickle .UnpicklingError , EOFError , AttributeError ):
82- return f"Error: { os .path .basename (latest_file )} is not a valid pickle file." , None
89+ return f"Error: { os .path .basename (latest_file )} is not a valid pickle file." , None , None
8390 except Exception as e :
8491 # Handle any other unexpected errors
85- return f"Error uploading file: { str (e )} " , None
86- return "No file uploaded" , None
92+ return f"Error uploading file: { str (e )} " , None , None
93+ return "No file uploaded" , None , None
8794
8895
8996@app .callback (
9097 Output ("processed-data-store" , "data" ),
9198 Output ("processed-links-store" , "data" ),
99+ Output ("loading-spinner-container" , "children" , allow_duplicate = True ),
92100 Input ("file-store" , "data" ),
93101 prevent_initial_call = True ,
94102)
95- def process_uploaded_data (file_path : Path | str | None ) -> tuple [str | None , str | None ]:
103+ def process_uploaded_data (
104+ file_path : Path | str | None ,
105+ ) -> tuple [str | None , str | None , str | None ]:
96106 """Process the uploaded pickle file and store the processed data.
97107
98108 Args:
@@ -102,7 +112,7 @@ def process_uploaded_data(file_path: Path | str | None) -> tuple[str | None, str
102112 JSON string of processed data or None if processing fails.
103113 """
104114 if file_path is None :
105- return None , None
115+ return None , None , None
106116
107117 try :
108118 with open (file_path , "rb" ) as f :
@@ -230,10 +240,10 @@ def process_mg_link(mf, gcf, methods_data):
230240 else :
231241 processed_links = {}
232242
233- return json .dumps (processed_data ), json .dumps (processed_links )
243+ return json .dumps (processed_data ), json .dumps (processed_links ), None
234244 except Exception as e :
235245 print (f"Error processing file: { str (e )} " )
236- return None , None
246+ return None , None , None
237247
238248
239249@app .callback (
@@ -249,6 +259,11 @@ def process_mg_link(mf, gcf, methods_data):
249259 Output ("gm-scoring-blocks-id" , "data" , allow_duplicate = True ),
250260 Output ("gm-scoring-blocks-container" , "children" , allow_duplicate = True ),
251261 Output ("gm-results-button" , "disabled" ),
262+ Output ("gm-table" , "selected_rows" , allow_duplicate = True ),
263+ Output ("gm-table-select-all-checkbox" , "value" , allow_duplicate = True ),
264+ Output ("gm-filter-accordion-component" , "value" , allow_duplicate = True ),
265+ Output ("gm-scoring-accordion-component" , "value" , allow_duplicate = True ),
266+ Output ("gm-results-table-column-toggle" , "value" , allow_duplicate = True ),
252267 # MG tab outputs
253268 Output ("mg-tab" , "disabled" ),
254269 Output ("mg-filter-accordion-control" , "disabled" ),
@@ -260,6 +275,11 @@ def process_mg_link(mf, gcf, methods_data):
260275 Output ("mg-scoring-blocks-id" , "data" , allow_duplicate = True ),
261276 Output ("mg-scoring-blocks-container" , "children" , allow_duplicate = True ),
262277 Output ("mg-results-button" , "disabled" ),
278+ Output ("mg-table" , "selected_rows" , allow_duplicate = True ),
279+ Output ("mg-table-select-all-checkbox" , "value" , allow_duplicate = True ),
280+ Output ("mg-filter-accordion-component" , "value" , allow_duplicate = True ),
281+ Output ("mg-scoring-accordion-component" , "value" , allow_duplicate = True ),
282+ Output ("mg-results-table-column-toggle" , "value" , allow_duplicate = True ),
263283 ],
264284 [Input ("file-store" , "data" )],
265285 prevent_initial_call = True ,
@@ -275,6 +295,16 @@ def disable_tabs_and_reset_blocks(
275295 Returns:
276296 Tuple containing boolean values for disabling tabs, styles, and new block data.
277297 """
298+ default_gm_column_value = (
299+ [GM_RESULTS_TABLE_CHECKL_OPTIONAL_COLUMNS [0 ]]
300+ if GM_RESULTS_TABLE_CHECKL_OPTIONAL_COLUMNS
301+ else []
302+ )
303+ default_mg_column_value = (
304+ [MG_RESULTS_TABLE_CHECKL_OPTIONAL_COLUMNS [0 ]]
305+ if MG_RESULTS_TABLE_CHECKL_OPTIONAL_COLUMNS
306+ else []
307+ )
278308 if file_path is None :
279309 # Disable all tabs and controls when no file is uploaded
280310 return (
@@ -289,6 +319,11 @@ def disable_tabs_and_reset_blocks(
289319 [],
290320 [],
291321 True ,
322+ [],
323+ [],
324+ [],
325+ [],
326+ default_gm_column_value ,
292327 # MG tab - disabled
293328 True ,
294329 True ,
@@ -300,6 +335,11 @@ def disable_tabs_and_reset_blocks(
300335 [],
301336 [],
302337 True ,
338+ [],
339+ [],
340+ [],
341+ [],
342+ default_mg_column_value ,
303343 )
304344
305345 # Enable the tabs and reset blocks
@@ -327,6 +367,11 @@ def disable_tabs_and_reset_blocks(
327367 gm_scoring_initial_block_id ,
328368 gm_scoring_new_blocks ,
329369 False ,
370+ [],
371+ [],
372+ [],
373+ [],
374+ default_gm_column_value ,
330375 # MG tab - enabled with initial blocks
331376 False ,
332377 False ,
@@ -338,6 +383,11 @@ def disable_tabs_and_reset_blocks(
338383 mg_scoring_initial_block_id ,
339384 mg_scoring_new_blocks ,
340385 False ,
386+ [],
387+ [],
388+ [],
389+ [],
390+ default_mg_column_value ,
341391 )
342392
343393
0 commit comments