Commit
·
2b87392
1
Parent(s):
e19490a
chore: Update plot_datasets_growth to include growth rate option
Browse files
app.py
CHANGED
|
@@ -44,7 +44,7 @@ def generate_dashboard(data, grouped, framework):
|
|
| 44 |
return dashboard
|
| 45 |
|
| 46 |
|
| 47 |
-
def plot_datasets_growth(data, framework):
|
| 48 |
df = pd.DataFrame(data)
|
| 49 |
df["createdAt"] = pd.to_datetime(df["createdAt"])
|
| 50 |
df["month"] = df["createdAt"].dt.to_period("M").astype(str)
|
|
@@ -60,20 +60,28 @@ def plot_datasets_growth(data, framework):
|
|
| 60 |
fig.update_layout(
|
| 61 |
xaxis_title="Month",
|
| 62 |
yaxis_title="Cumulative Number of Datasets",
|
| 63 |
-
yaxis=dict(title=f"Cumulative Number of Datasets ({framework}"),
|
| 64 |
-
yaxis2=dict(
|
| 65 |
-
title="Month-over-Month Growth Rate",
|
| 66 |
-
overlaying="y",
|
| 67 |
-
side="right",
|
| 68 |
-
tickformat=",.0%",
|
| 69 |
-
),
|
| 70 |
legend=dict(
|
| 71 |
title="", orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1
|
| 72 |
),
|
| 73 |
)
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
fig.update_layout(
|
| 78 |
title={
|
| 79 |
"text": f"Dataset Growth for {framework} datasets",
|
|
@@ -89,7 +97,8 @@ def plot_datasets_growth(data, framework):
|
|
| 89 |
y=0.85,
|
| 90 |
xref="paper",
|
| 91 |
yref="paper",
|
| 92 |
-
text="Cumulative number of datasets
|
|
|
|
| 93 |
showarrow=False,
|
| 94 |
font=dict(size=14),
|
| 95 |
)
|
|
@@ -98,10 +107,10 @@ def plot_datasets_growth(data, framework):
|
|
| 98 |
return fig
|
| 99 |
|
| 100 |
|
| 101 |
-
def update_dashboard(framework):
|
| 102 |
data, grouped = fetch_data(framework)
|
| 103 |
dashboard = generate_dashboard(data, grouped, framework)
|
| 104 |
-
fig = plot_datasets_growth(data, framework)
|
| 105 |
return fig, dashboard
|
| 106 |
|
| 107 |
|
|
@@ -115,8 +124,14 @@ with gr.Blocks() as demo:
|
|
| 115 |
allow_custom_value=True,
|
| 116 |
label="Select a framework/tag",
|
| 117 |
)
|
|
|
|
| 118 |
plot = gr.Plot(label="Growth of datasets over time")
|
| 119 |
markdown = gr.Markdown(label="summary")
|
| 120 |
-
framework.change(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
demo.launch()
|
|
|
|
| 44 |
return dashboard
|
| 45 |
|
| 46 |
|
| 47 |
+
def plot_datasets_growth(data, framework, show_growth_rate=True):
|
| 48 |
df = pd.DataFrame(data)
|
| 49 |
df["createdAt"] = pd.to_datetime(df["createdAt"])
|
| 50 |
df["month"] = df["createdAt"].dt.to_period("M").astype(str)
|
|
|
|
| 60 |
fig.update_layout(
|
| 61 |
xaxis_title="Month",
|
| 62 |
yaxis_title="Cumulative Number of Datasets",
|
| 63 |
+
yaxis=dict(title=f"Cumulative Number of Datasets ({framework})"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
legend=dict(
|
| 65 |
title="", orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1
|
| 66 |
),
|
| 67 |
)
|
| 68 |
+
|
| 69 |
+
if show_growth_rate:
|
| 70 |
+
fig.update_layout(
|
| 71 |
+
yaxis2=dict(
|
| 72 |
+
title="Month-over-Month Growth Rate",
|
| 73 |
+
overlaying="y",
|
| 74 |
+
side="right",
|
| 75 |
+
tickformat=",.0%",
|
| 76 |
+
)
|
| 77 |
+
)
|
| 78 |
+
fig.add_scatter(
|
| 79 |
+
x=df_counts["month"],
|
| 80 |
+
y=df_counts["growth_rate"],
|
| 81 |
+
name="Growth Rate",
|
| 82 |
+
yaxis="y2",
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
fig.update_layout(
|
| 86 |
title={
|
| 87 |
"text": f"Dataset Growth for {framework} datasets",
|
|
|
|
| 97 |
y=0.85,
|
| 98 |
xref="paper",
|
| 99 |
yref="paper",
|
| 100 |
+
text="Cumulative number of datasets"
|
| 101 |
+
+ (" and month-over-month growth rate" if show_growth_rate else ""),
|
| 102 |
showarrow=False,
|
| 103 |
font=dict(size=14),
|
| 104 |
)
|
|
|
|
| 107 |
return fig
|
| 108 |
|
| 109 |
|
| 110 |
+
def update_dashboard(framework, show_growth_rate=True):
|
| 111 |
data, grouped = fetch_data(framework)
|
| 112 |
dashboard = generate_dashboard(data, grouped, framework)
|
| 113 |
+
fig = plot_datasets_growth(data, framework, show_growth_rate)
|
| 114 |
return fig, dashboard
|
| 115 |
|
| 116 |
|
|
|
|
| 124 |
allow_custom_value=True,
|
| 125 |
label="Select a framework/tag",
|
| 126 |
)
|
| 127 |
+
show_growth_rate = gr.Checkbox(True, label="Show growth rate")
|
| 128 |
plot = gr.Plot(label="Growth of datasets over time")
|
| 129 |
markdown = gr.Markdown(label="summary")
|
| 130 |
+
framework.change(
|
| 131 |
+
update_dashboard, inputs=[framework, show_growth_rate], outputs=[plot, markdown]
|
| 132 |
+
)
|
| 133 |
+
show_growth_rate.change(
|
| 134 |
+
update_dashboard, inputs=[framework, show_growth_rate], outputs=[plot, markdown]
|
| 135 |
+
)
|
| 136 |
|
| 137 |
demo.launch()
|