better execption handling
Browse files12345156 unmodified lines16216316416516616716873 unmodified lines24224324424524624724824925025125213 unmodified lines26626726826927027127220 unmodified lines29329429529629729829910 unmodified lines3103113123133143153163 unmodified lines32032132232332432532632732832933033133233333433533633733812 unmodified lines35135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344421 unmodified lines4664674684694704714724734744754764774782 unmodified lines4814824834844854864874884894904914924934944954964974983 unmodified lines5025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335342 unmodified lines537538539540541# --- START OF FILE app.py ---import jsonimport gradio as grimport pandas as pd156 unmodified linesdef load_models_data(force_refresh=False, tqdm_cls=None): # tqdm_cls for Gradio progress# ... (initial part of load_models_data for loading pre-processed parquet is the same) ...if tqdm_cls is None: tqdm_cls = tqdm # Default to standard tqdm if Noneoverall_start_time = time.time()print(f"Gradio load_models_data called with force_refresh={force_refresh}")73 unmodified linesif output_filesize_col_name in df_raw.columns and pd.api.types.is_numeric_dtype(df_raw[output_filesize_col_name]):df[output_filesize_col_name] = pd.to_numeric(df_raw[output_filesize_col_name], errors='coerce').fillna(0.0)elif 'safetensors' in df.columns:# Use tqdm_cls for progress tracking if available (Gradio's gr.Progress.tqdm)safetensors_iter = df['safetensors']if tqdm_cls and tqdm_cls != tqdm: # Check if it's Gradio's progress trackersafetensors_iter = tqdm_cls(df['safetensors'], desc="Extracting model sizes (GB)", unit="row")elif tqdm_cls == tqdm: # For direct console tqdm if passedsafetensors_iter = tqdm(df['safetensors'], desc="Extracting model sizes (GB)", unit="row", leave=False)df[output_filesize_col_name] = [extract_model_size(s) for s in safetensors_iter]13 unmodified lineselse: return "Small (<1GB)" # Defaultdf['size_category'] = df[output_filesize_col_name].apply(get_size_category_gradio)# >>> USE THE CORRECTED process_tags_for_series HERE <<<df['tags'] = process_tags_for_series(df['tags'], tqdm_cls=tqdm_cls)df['temp_tags_joined'] = df['tags'].apply(20 unmodified linesdf['is_biomed'] = df['has_bio'] | df['has_med']df['organization'] = df['id'].apply(extract_org_from_id)# Drop safetensors if params was calculated from it, and params didn't pre-exist as numericif 'safetensors' in df.columns and \not (output_filesize_col_name in df_raw.columns and pd.api.types.is_numeric_dtype(df_raw[output_filesize_col_name])):df = df.drop(columns=['safetensors'], errors='ignore')10 unmodified linesreturn df, True, final_msg# ... (make_treemap_data, create_treemap functions remain unchanged) ...def make_treemap_data(df, count_by, top_k=25, tag_filter=None, pipeline_filter=None, size_filter=None, skip_orgs=None):if df is None or df.empty: return pd.DataFrame()filtered_df = df.copy()3 unmodified linesif 'has_robot' in filtered_df.columns:initial_robot_count = filtered_df['has_robot'].sum()# print(f"DIAGNOSTIC (make_treemap_data entry): Input df has {initial_robot_count} 'has_robot' models.") # Can be noisy# else:# print("DIAGNOSTIC (make_treemap_data entry): 'has_robot' column NOT in input df.")if tag_filter and tag_filter in col_map:target_col = col_map[tag_filter]if target_col in filtered_df.columns:# if tag_filter == "Robotics":# count_before_robot_filter = filtered_df[target_col].sum()# print(f"DIAGNOSTIC (make_treemap_data): Applying 'Robotics' filter. Models with '{target_col}'=True: {count_before_robot_filter}")filtered_df = filtered_df[filtered_df[target_col]]# if tag_filter == "Robotics":# print(f"DIAGNOSTIC (make_treemap_data): After 'Robotics' filter ({target_col}), df rows: {len(filtered_df)}")else:print(f"Warning: Tag filter column '{col_map[tag_filter]}' not found in DataFrame.")if pipeline_filter:12 unmodified lineselse:print("Warning: 'organization' column not found for filtering.")if filtered_df.empty: return pd.DataFrame()# Ensure count_by column is numeric, coercing if necessaryif count_by not in filtered_df.columns or not pd.api.types.is_numeric_dtype(filtered_df[count_by]):# print(f"Warning: Column '{count_by}' for treemap values is not numeric or missing. Coercing to numeric, filling NaNs with 0.")filtered_df[count_by] = pd.to_numeric(filtered_df.get(count_by), errors="coerce").fillna(0.0)org_totals = filtered_df.groupby("organization")[count_by].sum().nlargest(top_k, keep='first') # Default keep='first'top_orgs_list = org_totals.index.tolist()treemap_data = filtered_df[filtered_df["organization"].isin(top_orgs_list)][["id", "organization", count_by]].copy()treemap_data["root"] = "models" # For treemap structuretreemap_data[count_by] = pd.to_numeric(treemap_data[count_by], errors="coerce").fillna(0.0) # Ensure numeric again after subsettingreturn treemap_datadef create_treemap(treemap_data, count_by, title=None):if treemap_data.empty:fig = px.treemap(names=["No data matches filters"], parents=[""], values=[1]) # Placeholder for empty datafig.update_layout(title="No data matches the selected filters", margin=dict(t=50, l=25, r=25, b=25))return figfig = px.treemap(treemap_data, path=["root", "organization", "id"], values=count_by,title=title or f"HuggingFace Models - {count_by.capitalize()} by Organization",color_discrete_sequence=px.colors.qualitative.Plotly # Example color sequence)fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))fig.update_traces(textinfo="label+value+percent root", hovertemplate="<b>%{label}</b><br>%{value:,} " + count_by + "<br>%{percentRoot:.2%} of total<extra></extra>")return fig# --- Gradio UI and Controllers ---with gr.Blocks(title="HuggingFace Model Explorer") as demo:models_data_state = gr.State(pd.DataFrame())loading_complete_state = gr.State(False) # To control button interactivitywith gr.Row():gr.Markdown("# HuggingFace Models TreeMap Visualization")with gr.Row():with gr.Column(scale=1): # Controls columncount_by_dropdown = gr.Dropdown(label="Metric", choices=[("Downloads (last 30 days)", "downloads"), ("Downloads (All Time)", "downloadsAllTime"), ("Likes", "likes")], value="downloads")filter_choice_radio = gr.Radio(label="Filter Type", choices=["None", "Tag Filter", "Pipeline Filter"], value="None")tag_filter_dropdown = gr.Dropdown(label="Select Tag", choices=TAG_FILTER_CHOICES, value=None, visible=False)pipeline_filter_dropdown = gr.Dropdown(label="Select Pipeline Tag", choices=PIPELINE_TAGS, value=None, visible=False)size_filter_dropdown = gr.Dropdown(label="Model Size Filter", choices=["None"] + list(MODEL_SIZE_RANGES.keys()), value="None")top_k_slider = gr.Slider(label="Number of Top Organizations", minimum=5, maximum=50, value=25, step=5)skip_orgs_textbox = gr.Textbox(label="Organizations to Skip (comma-separated)", value="TheBloke,MaziyarPanahi,unsloth,modularai,Gensyn,bartowski") # Common large orgsgenerate_plot_button = gr.Button(value="Generate Plot", variant="primary", interactive=False) # Starts disabledrefresh_data_button = gr.Button(value="Refresh Data from Hugging Face", variant="secondary")with gr.Column(scale=3): # Plot and info columnplot_output = gr.Plot()status_message_md = gr.Markdown("Initializing...") # For general status updatesdata_info_md = gr.Markdown("") # For detailed data stats# Enable generate button only after data is loadeddef _update_button_interactivity(is_loaded_flag):return gr.update(interactive=is_loaded_flag)loading_complete_state.change(fn=_update_button_interactivity, inputs=loading_complete_state, outputs=generate_plot_button)# Show/hide tag/pipeline filters based on radio choicedef _toggle_filters_visibility(choice):return gr.update(visible=choice == "Tag Filter"), gr.update(visible=choice == "Pipeline Filter")filter_choice_radio.change(fn=_toggle_filters_visibility, inputs=filter_choice_radio, outputs=[tag_filter_dropdown, pipeline_filter_dropdown])def ui_load_data_controller(force_refresh_ui_trigger=False, progress=gr.Progress(track_tqdm=True)): # Gradio progress trackerprint(f"ui_load_data_controller called with force_refresh_ui_trigger={force_refresh_ui_trigger}")status_msg_ui = "Loading data..."data_info_text = ""current_df = pd.DataFrame()load_success_flag = Falsedata_as_of_date_display = "N/A"try:# Pass gr.Progress.tqdm to load_models_data if it's a Gradio callcurrent_df, load_success_flag, status_msg_from_load = load_models_data(force_refresh=force_refresh_ui_trigger, tqdm_cls=progress.tqdm if progress else tqdm)if load_success_flag:if force_refresh_ui_trigger: # Data was just fetched by Gradiodata_as_of_date_display = pd.Timestamp.now(tz='UTC').strftime('%B %d, %Y, %H:%M:%S %Z')# If loaded from pre-processed parquet, check for its timestamp columnelif 'data_download_timestamp' in current_df.columns and not current_df.empty and pd.notna(current_df['data_download_timestamp'].iloc[0]):timestamp_from_parquet = pd.to_datetime(current_df['data_download_timestamp'].iloc[0])if timestamp_from_parquet.tzinfo is None: # If no timezone, assume UTC from preprocessortimestamp_from_parquet = timestamp_from_parquet.tz_localize('UTC')data_as_of_date_display = timestamp_from_parquet.strftime('%B %d, %Y, %H:%M:%S %Z')else: # Pre-processed data but no timestamp column or it's NaTdata_as_of_date_display = "Pre-processed (date unavailable)"# Build data info stringsize_dist_lines = []if 'size_category' in current_df.columns:21 unmodified linesstatus_msg_ui = "Data loaded successfully. Ready to generate plot."else: # load_success_flag is Falsedata_info_text = f"### Data Load Failed\n- {status_msg_from_load}"status_msg_ui = status_msg_from_load # Pass error message from load_models_dataexcept Exception as e:status_msg_ui = f"An unexpected error occurred in ui_load_data_controller: {str(e)}"data_info_text = f"### Critical Error\n- {status_msg_ui}"print(f"Critical error in ui_load_data_controller: {e}")load_success_flag = False # Ensure this is false on errorreturn current_df, load_success_flag, data_info_text, status_msg_ui2 unmodified linesif df_current_models is None or df_current_models.empty:empty_fig = create_treemap(pd.DataFrame(), metric_choice, "Error: Model Data Not Loaded")error_msg = "Model data is not loaded or is empty. Please load or refresh data first."gr.Warning(error_msg) # Display a Gradio warningreturn empty_fig, error_msgtag_to_use = tag_choice if filter_type == "Tag Filter" else Nonepipeline_to_use = pipeline_choice if filter_type == "Pipeline Filter" else Nonesize_to_use = size_choice if size_choice != "None" else None # Handle "None" stringorgs_to_skip = [org.strip() for org in skip_orgs_input.split(',') if org.strip()] if skip_orgs_input else []# if 'has_robot' in df_current_models.columns:# robot_count_before_treemap = df_current_models['has_robot'].sum()# print(f"DIAGNOSTIC (ui_generate_plot_controller): df_current_models entering make_treemap_data has {robot_count_before_treemap} 'has_robot' models.")treemap_df = make_treemap_data(df_current_models, metric_choice, k_orgs, tag_to_use, pipeline_to_use, size_to_use, orgs_to_skip)title_labels = {"downloads": "Downloads (last 30 days)", "downloadsAllTime": "Downloads (All Time)", "likes": "Likes"}3 unmodified linesif treemap_df.empty:plot_stats_md = "No data matches the selected filters. Try adjusting your filters."else:total_items_in_plot = len(treemap_df['id'].unique()) # Count unique models in plottotal_value_in_plot = treemap_df[metric_choice].sum() # Sum of metric in plotplot_stats_md = (f"## Plot Statistics\n- **Models shown**: {total_items_in_plot:,}\n- **Total {metric_choice}**: {int(total_value_in_plot):,}")return plotly_fig, plot_stats_md# --- Event Handlers ---# Initial data load on app startdemo.load(fn=lambda progress=gr.Progress(track_tqdm=True): ui_load_data_controller(force_refresh_ui_trigger=False, progress=progress),inputs=[], # No inputs for initial loadoutputs=[models_data_state, loading_complete_state, data_info_md, status_message_md])# Refresh data buttonrefresh_data_button.click(fn=lambda progress=gr.Progress(track_tqdm=True): ui_load_data_controller(force_refresh_ui_trigger=True, progress=progress),inputs=[],outputs=[models_data_state, loading_complete_state, data_info_md, status_message_md])# Generate plot buttongenerate_plot_button.click(fn=ui_generate_plot_controller,inputs=[count_by_dropdown, filter_choice_radio, tag_filter_dropdown, pipeline_filter_dropdown,size_filter_dropdown, top_k_slider, skip_orgs_textbox, models_data_state],outputs=[plot_output, status_message_md] # Update plot and status message)if __name__ == "__main__":2 unmodified linesprint("It is highly recommended to run the preprocessing script (preprocess.py) first.")else:print(f"Found pre-processed data file: '{PROCESSED_PARQUET_FILE_PATH}'.")demo.launch()# --- END OF FILE app.py ---123156 unmodified lines16016116216316416573 unmodified lines23924024124224324424524624724813 unmodified lines26226326426526626720 unmodified lines28828929029129229310 unmodified lines3043053063073083093 unmodified lines31331431531631731831932032132212 unmodified lines33533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444521 unmodified lines4674684694704714724734744754764774784792 unmodified lines4824834844854864874884894904914924934944953 unmodified lines4995005015025035045055065075085095105115125135145155165175185195205215225235245255265272 unmodified lines530531532533import jsonimport gradio as grimport pandas as pd156 unmodified linesdef load_models_data(force_refresh=False, tqdm_cls=None): # tqdm_cls for Gradio progressif tqdm_cls is None: tqdm_cls = tqdm # Default to standard tqdm if Noneoverall_start_time = time.time()print(f"Gradio load_models_data called with force_refresh={force_refresh}")73 unmodified linesif output_filesize_col_name in df_raw.columns and pd.api.types.is_numeric_dtype(df_raw[output_filesize_col_name]):df[output_filesize_col_name] = pd.to_numeric(df_raw[output_filesize_col_name], errors='coerce').fillna(0.0)elif 'safetensors' in df.columns:safetensors_iter = df['safetensors']if tqdm_cls and tqdm_cls != tqdm:safetensors_iter = tqdm_cls(df['safetensors'], desc="Extracting model sizes (GB)", unit="row")elif tqdm_cls == tqdm:safetensors_iter = tqdm(df['safetensors'], desc="Extracting model sizes (GB)", unit="row", leave=False)df[output_filesize_col_name] = [extract_model_size(s) for s in safetensors_iter]13 unmodified lineselse: return "Small (<1GB)" # Defaultdf['size_category'] = df[output_filesize_col_name].apply(get_size_category_gradio)df['tags'] = process_tags_for_series(df['tags'], tqdm_cls=tqdm_cls)df['temp_tags_joined'] = df['tags'].apply(20 unmodified linesdf['is_biomed'] = df['has_bio'] | df['has_med']df['organization'] = df['id'].apply(extract_org_from_id)if 'safetensors' in df.columns and \not (output_filesize_col_name in df_raw.columns and pd.api.types.is_numeric_dtype(df_raw[output_filesize_col_name])):df = df.drop(columns=['safetensors'], errors='ignore')10 unmodified linesreturn df, True, final_msgdef make_treemap_data(df, count_by, top_k=25, tag_filter=None, pipeline_filter=None, size_filter=None, skip_orgs=None):if df is None or df.empty: return pd.DataFrame()filtered_df = df.copy()3 unmodified linesif 'has_robot' in filtered_df.columns:initial_robot_count = filtered_df['has_robot'].sum()if tag_filter and tag_filter in col_map:target_col = col_map[tag_filter]if target_col in filtered_df.columns:filtered_df = filtered_df[filtered_df[target_col]]else:print(f"Warning: Tag filter column '{col_map[tag_filter]}' not found in DataFrame.")if pipeline_filter:12 unmodified lineselse:print("Warning: 'organization' column not found for filtering.")if filtered_df.empty: return pd.DataFrame()if count_by not in filtered_df.columns or not pd.api.types.is_numeric_dtype(filtered_df[count_by]):filtered_df[count_by] = pd.to_numeric(filtered_df.get(count_by), errors="coerce").fillna(0.0)org_totals = filtered_df.groupby("organization")[count_by].sum().nlargest(top_k, keep='first')top_orgs_list = org_totals.index.tolist()treemap_data = filtered_df[filtered_df["organization"].isin(top_orgs_list)][["id", "organization", count_by]].copy()treemap_data["root"] = "models"treemap_data[count_by] = pd.to_numeric(treemap_data[count_by], errors="coerce").fillna(0.0)return treemap_datadef create_treemap(treemap_data, count_by, title=None):if treemap_data.empty:fig = px.treemap(names=["No data matches filters"], parents=[""], values=[1])fig.update_layout(title="No data matches the selected filters", margin=dict(t=50, l=25, r=25, b=25))return figfig = px.treemap(treemap_data, path=["root", "organization", "id"], values=count_by,title=title or f"HuggingFace Models - {count_by.capitalize()} by Organization",color_discrete_sequence=px.colors.qualitative.Plotly)fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))fig.update_traces(textinfo="label+value+percent root", hovertemplate="<b>%{label}</b><br>%{value:,} " + count_by + "<br>%{percentRoot:.2%} of total<extra></extra>")return figwith gr.Blocks(title="HuggingFace Model Explorer") as demo:models_data_state = gr.State(pd.DataFrame())loading_complete_state = gr.State(False)with gr.Row():gr.Markdown("# HuggingFace Models TreeMap Visualization")with gr.Row():with gr.Column(scale=1):count_by_dropdown = gr.Dropdown(label="Metric", choices=[("Downloads (last 30 days)", "downloads"), ("Downloads (All Time)", "downloadsAllTime"), ("Likes", "likes")], value="downloads")filter_choice_radio = gr.Radio(label="Filter Type", choices=["None", "Tag Filter", "Pipeline Filter"], value="None")tag_filter_dropdown = gr.Dropdown(label="Select Tag", choices=TAG_FILTER_CHOICES, value=None, visible=False)pipeline_filter_dropdown = gr.Dropdown(label="Select Pipeline Tag", choices=PIPELINE_TAGS, value=None, visible=False)size_filter_dropdown = gr.Dropdown(label="Model Size Filter", choices=["None"] + list(MODEL_SIZE_RANGES.keys()), value="None")top_k_slider = gr.Slider(label="Number of Top Organizations", minimum=5, maximum=50, value=25, step=5)skip_orgs_textbox = gr.Textbox(label="Organizations to Skip (comma-separated)", value="TheBloke,MaziyarPanahi,unsloth,modularai,Gensyn,bartowski")generate_plot_button = gr.Button(value="Generate Plot", variant="primary", interactive=False)refresh_data_button = gr.Button(value="Refresh Data from Hugging Face", variant="secondary")with gr.Column(scale=3):plot_output = gr.Plot()status_message_md = gr.Markdown("Initializing...")data_info_md = gr.Markdown("")def _update_button_interactivity(is_loaded_flag):return gr.update(interactive=is_loaded_flag)loading_complete_state.change(fn=_update_button_interactivity, inputs=loading_complete_state, outputs=generate_plot_button)def _toggle_filters_visibility(choice):return gr.update(visible=choice == "Tag Filter"), gr.update(visible=choice == "Pipeline Filter")filter_choice_radio.change(fn=_toggle_filters_visibility, inputs=filter_choice_radio, outputs=[tag_filter_dropdown, pipeline_filter_dropdown])def ui_load_data_controller(force_refresh_ui_trigger=False, progress=gr.Progress(track_tqdm=True)):print(f"ui_load_data_controller called with force_refresh_ui_trigger={force_refresh_ui_trigger}")status_msg_ui = "Loading data..."data_info_text = ""current_df = pd.DataFrame()load_success_flag = False# data_as_of_date_display = "N/A" # Will be set inside the logictry:current_df, load_success_flag, status_msg_from_load = load_models_data(force_refresh=force_refresh_ui_trigger, tqdm_cls=progress.tqdm if progress else tqdm)if load_success_flag:# Default value for data_as_of_date_displaydata_as_of_date_display = "Pre-processed (date unavailable or invalid)"if force_refresh_ui_trigger: # Data was just fetched by Gradiodata_as_of_date_display = pd.Timestamp.now(tz='UTC').strftime('%B %d, %Y, %H:%M:%S %Z')# If loaded from pre-processed parquet, check for its timestamp columnelif 'data_download_timestamp' in current_df.columns and not current_df.empty:try:# Step 1: Safely get the value from the DataFrame's first row for the timestamp columnraw_val_from_df = current_df['data_download_timestamp'].iloc[0]# Step 2: Process if raw_val_from_df is a list/arrayscalar_timestamp_val = Noneif isinstance(raw_val_from_df, (list, tuple, np.ndarray)):if len(raw_val_from_df) > 0:scalar_timestamp_val = raw_val_from_df[0]else:scalar_timestamp_val = raw_val_from_df# Step 3: Check for NA and convert the scalar value to datetimeif pd.notna(scalar_timestamp_val):dt_obj = pd.to_datetime(scalar_timestamp_val)if pd.notna(dt_obj):if dt_obj.tzinfo is None:dt_obj = dt_obj.tz_localize('UTC')data_as_of_date_display = dt_obj.strftime('%B %d, %Y, %H:%M:%S %Z')except IndexError:print(f"DEBUG: IndexError encountered while processing 'data_download_timestamp'. DF empty: {current_df.empty}")if 'data_download_timestamp' in current_df.columns and not current_df.empty:print(f"DEBUG: Head of 'data_download_timestamp': {str(current_df['data_download_timestamp'].head(1))}") # Ensure string conversion for printexcept Exception as e_ts_proc:print(f"Error processing 'data_download_timestamp' from parquet: {e_ts_proc}")# Build data info stringsize_dist_lines = []if 'size_category' in current_df.columns:21 unmodified linesstatus_msg_ui = "Data loaded successfully. Ready to generate plot."else: # load_success_flag is Falsedata_info_text = f"### Data Load Failed\n- {status_msg_from_load}"status_msg_ui = status_msg_from_loadexcept Exception as e:status_msg_ui = f"An unexpected error occurred in ui_load_data_controller: {str(e)}"data_info_text = f"### Critical Error\n- {status_msg_ui}"print(f"Critical error in ui_load_data_controller: {e}") # This is the original error printload_success_flag = Falsereturn current_df, load_success_flag, data_info_text, status_msg_ui2 unmodified linesif df_current_models is None or df_current_models.empty:empty_fig = create_treemap(pd.DataFrame(), metric_choice, "Error: Model Data Not Loaded")error_msg = "Model data is not loaded or is empty. Please load or refresh data first."gr.Warning(error_msg)return empty_fig, error_msgtag_to_use = tag_choice if filter_type == "Tag Filter" else Nonepipeline_to_use = pipeline_choice if filter_type == "Pipeline Filter" else Nonesize_to_use = size_choice if size_choice != "None" else Noneorgs_to_skip = [org.strip() for org in skip_orgs_input.split(',') if org.strip()] if skip_orgs_input else []treemap_df = make_treemap_data(df_current_models, metric_choice, k_orgs, tag_to_use, pipeline_to_use, size_to_use, orgs_to_skip)title_labels = {"downloads": "Downloads (last 30 days)", "downloadsAllTime": "Downloads (All Time)", "likes": "Likes"}3 unmodified linesif treemap_df.empty:plot_stats_md = "No data matches the selected filters. Try adjusting your filters."else:total_items_in_plot = len(treemap_df['id'].unique())total_value_in_plot = treemap_df[metric_choice].sum()plot_stats_md = (f"## Plot Statistics\n- **Models shown**: {total_items_in_plot:,}\n- **Total {metric_choice}**: {int(total_value_in_plot):,}")return plotly_fig, plot_stats_mddemo.load(fn=lambda progress=gr.Progress(track_tqdm=True): ui_load_data_controller(force_refresh_ui_trigger=False, progress=progress),inputs=[],outputs=[models_data_state, loading_complete_state, data_info_md, status_message_md])refresh_data_button.click(fn=lambda progress=gr.Progress(track_tqdm=True): ui_load_data_controller(force_refresh_ui_trigger=True, progress=progress),inputs=[],outputs=[models_data_state, loading_complete_state, data_info_md, status_message_md])generate_plot_button.click(fn=ui_generate_plot_controller,inputs=[count_by_dropdown, filter_choice_radio, tag_filter_dropdown, pipeline_filter_dropdown,size_filter_dropdown, top_k_slider, skip_orgs_textbox, models_data_state],outputs=[plot_output, status_message_md])if __name__ == "__main__":2 unmodified linesprint("It is highly recommended to run the preprocessing script (preprocess.py) first.")else:print(f"Found pre-processed data file: '{PROCESSED_PARQUET_FILE_PATH}'.")demo.launch()
app.py+57-65