Commit
·
cb8646a
1
Parent(s):
e8daabc
fix plot update button
Browse files- .gitignore +2 -1
- app.py +26 -11
- datasets_cache.pkl +2 -2
- plots/datasets_bar_plot_horizontal.png +0 -0
- plots/datasets_bar_plot_vertical.png +0 -0
- plots/datasets_pie_chart.png +0 -0
- plots/datasets_stack_area.png +0 -0
- plots/datasets_stack_area_en_es.png +0 -0
- plots/datasets_stack_area_es.png +0 -0
- plots/datasets_stack_area_es_ca_gl_eu.png +0 -0
- plots/datasets_time_series.png +0 -0
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
venv
|
|
|
|
|
|
| 1 |
+
venv/
|
| 2 |
+
__pycache__/
|
app.py
CHANGED
|
@@ -5,22 +5,37 @@ import gradio as gr
|
|
| 5 |
|
| 6 |
def run_scripts():
|
| 7 |
try:
|
| 8 |
-
# Execute
|
| 9 |
-
subprocess.run(
|
| 10 |
["python", "hub_datasets_by_language.py"],
|
| 11 |
capture_output=True,
|
| 12 |
text=True,
|
| 13 |
check=True,
|
| 14 |
)
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
# ["python", "hub_models_by_language.py"],
|
| 17 |
# capture_output=True,
|
| 18 |
# text=True,
|
| 19 |
# check=True,
|
| 20 |
# )
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
except subprocess.CalledProcessError as e:
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
def create_app():
|
|
@@ -43,14 +58,14 @@ def create_app():
|
|
| 43 |
|
| 44 |
with gr.Row():
|
| 45 |
with gr.Column():
|
| 46 |
-
gr.Image(
|
| 47 |
value="plots/datasets_bar_plot_horizontal.png",
|
| 48 |
label="Distribution of Datasets by Year (Horizontal)",
|
| 49 |
show_label=True,
|
| 50 |
show_download_button=True,
|
| 51 |
show_share_button=True,
|
| 52 |
)
|
| 53 |
-
gr.Image(
|
| 54 |
value="plots/datasets_stack_area_en_es.png",
|
| 55 |
label="Cumulative Growth of Datasets (Stacked)",
|
| 56 |
show_label=True,
|
|
@@ -58,14 +73,14 @@ def create_app():
|
|
| 58 |
show_share_button=True,
|
| 59 |
)
|
| 60 |
with gr.Column():
|
| 61 |
-
gr.Image(
|
| 62 |
value="plots/datasets_bar_plot_vertical.png",
|
| 63 |
label="Distribution of Datasets by Year (Vertical)",
|
| 64 |
show_label=True,
|
| 65 |
show_download_button=True,
|
| 66 |
show_share_button=True,
|
| 67 |
)
|
| 68 |
-
gr.Image(
|
| 69 |
value="plots/datasets_time_series.png",
|
| 70 |
label="Cumulative Growth of Datasets (Line)",
|
| 71 |
show_label=True,
|
|
@@ -89,7 +104,7 @@ def create_app():
|
|
| 89 |
# )
|
| 90 |
|
| 91 |
with gr.Row():
|
| 92 |
-
update_button = gr.Button("Update
|
| 93 |
output_label = gr.Label()
|
| 94 |
|
| 95 |
gr.Markdown(
|
|
@@ -120,7 +135,7 @@ def create_app():
|
|
| 120 |
|
| 121 |
update_button.click(
|
| 122 |
fn=run_scripts,
|
| 123 |
-
outputs=output_label,
|
| 124 |
)
|
| 125 |
|
| 126 |
return app
|
|
|
|
| 5 |
|
| 6 |
def run_scripts():
|
| 7 |
try:
|
| 8 |
+
# Execute datasets script
|
| 9 |
+
result = subprocess.run(
|
| 10 |
["python", "hub_datasets_by_language.py"],
|
| 11 |
capture_output=True,
|
| 12 |
text=True,
|
| 13 |
check=True,
|
| 14 |
)
|
| 15 |
+
|
| 16 |
+
# Uncomment this when models script is ready
|
| 17 |
+
# models_result = subprocess.run(
|
| 18 |
# ["python", "hub_models_by_language.py"],
|
| 19 |
# capture_output=True,
|
| 20 |
# text=True,
|
| 21 |
# check=True,
|
| 22 |
# )
|
| 23 |
+
|
| 24 |
+
# Return success message and updated image paths
|
| 25 |
+
return (
|
| 26 |
+
"✅ Scripts executed successfully! All plots have been updated.",
|
| 27 |
+
"plots/datasets_bar_plot_horizontal.png",
|
| 28 |
+
"plots/datasets_stack_area_en_es.png",
|
| 29 |
+
"plots/datasets_bar_plot_vertical.png",
|
| 30 |
+
"plots/datasets_time_series.png",
|
| 31 |
+
)
|
| 32 |
except subprocess.CalledProcessError as e:
|
| 33 |
+
error_msg = e.stderr if e.stderr else e.stdout if e.stdout else str(e)
|
| 34 |
+
# Return error message and keep current images
|
| 35 |
+
return (f"❌ Failed to execute scripts: {error_msg}", None, None, None, None)
|
| 36 |
+
except Exception as e:
|
| 37 |
+
# Return error message and keep current images
|
| 38 |
+
return (f"❌ Unexpected error: {str(e)}", None, None, None, None)
|
| 39 |
|
| 40 |
|
| 41 |
def create_app():
|
|
|
|
| 58 |
|
| 59 |
with gr.Row():
|
| 60 |
with gr.Column():
|
| 61 |
+
img1 = gr.Image(
|
| 62 |
value="plots/datasets_bar_plot_horizontal.png",
|
| 63 |
label="Distribution of Datasets by Year (Horizontal)",
|
| 64 |
show_label=True,
|
| 65 |
show_download_button=True,
|
| 66 |
show_share_button=True,
|
| 67 |
)
|
| 68 |
+
img2 = gr.Image(
|
| 69 |
value="plots/datasets_stack_area_en_es.png",
|
| 70 |
label="Cumulative Growth of Datasets (Stacked)",
|
| 71 |
show_label=True,
|
|
|
|
| 73 |
show_share_button=True,
|
| 74 |
)
|
| 75 |
with gr.Column():
|
| 76 |
+
img3 = gr.Image(
|
| 77 |
value="plots/datasets_bar_plot_vertical.png",
|
| 78 |
label="Distribution of Datasets by Year (Vertical)",
|
| 79 |
show_label=True,
|
| 80 |
show_download_button=True,
|
| 81 |
show_share_button=True,
|
| 82 |
)
|
| 83 |
+
img4 = gr.Image(
|
| 84 |
value="plots/datasets_time_series.png",
|
| 85 |
label="Cumulative Growth of Datasets (Line)",
|
| 86 |
show_label=True,
|
|
|
|
| 104 |
# )
|
| 105 |
|
| 106 |
with gr.Row():
|
| 107 |
+
update_button = gr.Button("Update plots with latest data (5 mins)")
|
| 108 |
output_label = gr.Label()
|
| 109 |
|
| 110 |
gr.Markdown(
|
|
|
|
| 135 |
|
| 136 |
update_button.click(
|
| 137 |
fn=run_scripts,
|
| 138 |
+
outputs=[output_label, img1, img2, img3, img4],
|
| 139 |
)
|
| 140 |
|
| 141 |
return app
|
datasets_cache.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b8573313007cdefe69256cd004c8a1b3d46b96dc2aed53cfe97fd9ae6235a6c9
|
| 3 |
+
size 45749835
|
plots/datasets_bar_plot_horizontal.png
CHANGED
|
|
plots/datasets_bar_plot_vertical.png
CHANGED
|
|
plots/datasets_pie_chart.png
CHANGED
|
|
plots/datasets_stack_area.png
CHANGED
|
|
plots/datasets_stack_area_en_es.png
CHANGED
|
|
plots/datasets_stack_area_es.png
CHANGED
|
|
plots/datasets_stack_area_es_ca_gl_eu.png
CHANGED
|
|
plots/datasets_time_series.png
CHANGED
|
|