fdaudens HF Staff commited on
Commit
7847f35
·
1 Parent(s): c1c6f57
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -4,6 +4,7 @@ import pandas as pd
4
  import gradio as gr
5
  from huggingface_hub import HfApi
6
  from pathlib import Path
 
7
 
8
  def get_model_stats(search_term):
9
  # Initialize the API
@@ -87,7 +88,7 @@ with gr.Blocks(title="Hugging Face Model Statistics") as demo:
87
 
88
  with gr.Row():
89
  download_button = gr.Button("Download CSV")
90
- csv_file = gr.File(label="CSV File", visible=False)
91
 
92
  # Store the CSV file path in a state
93
  csv_path = gr.State()
@@ -99,6 +100,11 @@ with gr.Blocks(title="Hugging Face Model Statistics") as demo:
99
  )
100
  return df, status, csv_path
101
 
 
 
 
 
 
102
  search_button.click(
103
  fn=get_model_stats,
104
  inputs=search_input,
@@ -110,7 +116,7 @@ with gr.Blocks(title="Hugging Face Model Statistics") as demo:
110
  )
111
 
112
  download_button.click(
113
- fn=lambda x: x,
114
  inputs=csv_path,
115
  outputs=csv_file
116
  )
 
4
  import gradio as gr
5
  from huggingface_hub import HfApi
6
  from pathlib import Path
7
+ import os
8
 
9
  def get_model_stats(search_term):
10
  # Initialize the API
 
88
 
89
  with gr.Row():
90
  download_button = gr.Button("Download CSV")
91
+ csv_file = gr.File(label="CSV File", visible=True)
92
 
93
  # Store the CSV file path in a state
94
  csv_path = gr.State()
 
100
  )
101
  return df, status, csv_path
102
 
103
+ def get_csv_file(csv_path):
104
+ if csv_path and os.path.exists(csv_path):
105
+ return csv_path
106
+ return None
107
+
108
  search_button.click(
109
  fn=get_model_stats,
110
  inputs=search_input,
 
116
  )
117
 
118
  download_button.click(
119
+ fn=get_csv_file,
120
  inputs=csv_path,
121
  outputs=csv_file
122
  )