Spaces:
Sleeping
Sleeping
Benjamin Bossan
commited on
Commit
Β·
0e7cb64
1
Parent(s):
4d3a31e
First commit, need to backfill yet
Browse files- README.md +4 -4
- app.py +147 -0
- metrics.csv +3 -0
- requirements.txt +3 -0
README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
---
|
| 2 |
title: Diffusers Repo Metrics
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.49.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
short_description:
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
title: Diffusers Repo Metrics
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.49.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
short_description: Diffusers Repo Metrics
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import plotly.express as px
|
| 6 |
+
import plotly.graph_objects as go
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
CSV_PATH = Path("metrics.csv")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def load_data() -> pd.DataFrame:
|
| 13 |
+
df = pd.read_csv(CSV_PATH)
|
| 14 |
+
# Normalize/parse columns
|
| 15 |
+
if "date" not in df.columns:
|
| 16 |
+
raise ValueError("Expected a 'date' column in metrics.csv")
|
| 17 |
+
df["date"] = pd.to_datetime(df["date"], errors="coerce")
|
| 18 |
+
df = df.sort_values("date").reset_index(drop=True)
|
| 19 |
+
# Ensure numeric columns are numeric
|
| 20 |
+
for c in df.columns:
|
| 21 |
+
if c == "date":
|
| 22 |
+
continue
|
| 23 |
+
df[c] = pd.to_numeric(df[c], errors="coerce")
|
| 24 |
+
return df
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def line_figure(df: pd.DataFrame, cols: list[str], title: str, yaxis_title: str = "") -> go.Figure:
|
| 28 |
+
if not cols:
|
| 29 |
+
# Empty placeholder so the UI doesn't error
|
| 30 |
+
fig = go.Figure()
|
| 31 |
+
fig.update_layout(title=f"{title} (no series selected)")
|
| 32 |
+
return fig
|
| 33 |
+
fig = px.line(
|
| 34 |
+
df,
|
| 35 |
+
x="date",
|
| 36 |
+
y=cols,
|
| 37 |
+
markers=True,
|
| 38 |
+
title=title,
|
| 39 |
+
)
|
| 40 |
+
# Improve layout for time series
|
| 41 |
+
fig.update_layout(
|
| 42 |
+
legend_title_text="Series",
|
| 43 |
+
xaxis_title="Date",
|
| 44 |
+
yaxis_title=yaxis_title,
|
| 45 |
+
hovermode="x unified",
|
| 46 |
+
margin={"l": 50, "r": 20, "t": 50, "b": 40},
|
| 47 |
+
)
|
| 48 |
+
return fig
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
TAB_SPEC = {
|
| 52 |
+
"Docstrings": [
|
| 53 |
+
"docstring coverage",
|
| 54 |
+
"docstring missing",
|
| 55 |
+
],
|
| 56 |
+
"Size (Lines/Statements/Expressions/Parameters)": [
|
| 57 |
+
"lines mean",
|
| 58 |
+
"lines max",
|
| 59 |
+
"lines 90th-percentile",
|
| 60 |
+
"statements mean",
|
| 61 |
+
"statements max",
|
| 62 |
+
"statements 90th-percentile",
|
| 63 |
+
"expressions mean",
|
| 64 |
+
"expressions max",
|
| 65 |
+
"expressions 90th-percentile",
|
| 66 |
+
"parameters mean",
|
| 67 |
+
"parameters max",
|
| 68 |
+
"parameters 90th-percentile",
|
| 69 |
+
],
|
| 70 |
+
"Complexity": [
|
| 71 |
+
"cyclomatic_complexity mean",
|
| 72 |
+
"cyclomatic_complexity max",
|
| 73 |
+
"cyclomatic_complexity 90th-percentile",
|
| 74 |
+
],
|
| 75 |
+
"Typing": [
|
| 76 |
+
"type_coverage mean",
|
| 77 |
+
"type_coverage min",
|
| 78 |
+
"type_coverage 50th-percentile",
|
| 79 |
+
],
|
| 80 |
+
"Duplication": [
|
| 81 |
+
"duplication.score mean",
|
| 82 |
+
"duplication.score max",
|
| 83 |
+
"duplication.score 90th-percentile",
|
| 84 |
+
"duplication.score 50th-percentile",
|
| 85 |
+
"duplication.duplicated-lines total",
|
| 86 |
+
],
|
| 87 |
+
"TODOs": [
|
| 88 |
+
"todo_comments total",
|
| 89 |
+
],
|
| 90 |
+
"CLOC (Repository scope)": [
|
| 91 |
+
"files",
|
| 92 |
+
"lines blank",
|
| 93 |
+
"lines comment",
|
| 94 |
+
"lines code",
|
| 95 |
+
],
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
Y_LABELS = {
|
| 99 |
+
"Docstrings": "value",
|
| 100 |
+
"Size (Lines/Statements/Expressions/Parameters)": "count",
|
| 101 |
+
"Complexity": "complexity",
|
| 102 |
+
"Typing": "fraction / coverage",
|
| 103 |
+
"Duplication": "score / lines",
|
| 104 |
+
"TODOs": "count",
|
| 105 |
+
"CLOC (Repository scope)": "lines / files",
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
DF = load_data()
|
| 109 |
+
|
| 110 |
+
with gr.Blocks(title="Code Metrics β Time Series", fill_height=True) as demo:
|
| 111 |
+
gr.Markdown(
|
| 112 |
+
"## Diffusers Code Metrics Over Time\n"
|
| 113 |
+
f"Loaded **{CSV_PATH}** with {len(DF)} rows spanning "
|
| 114 |
+
f"{DF['date'].min().date()} β {DF['date'].max().date()}.\n\n"
|
| 115 |
+
"Use each tab to pick the series you want to plot."
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
with gr.Tabs():
|
| 119 |
+
tab_controls = []
|
| 120 |
+
tab_plots = []
|
| 121 |
+
|
| 122 |
+
for tab_name, series in TAB_SPEC.items():
|
| 123 |
+
available = [s for s in series if s in DF.columns] # guard against missing cols
|
| 124 |
+
with gr.Tab(tab_name):
|
| 125 |
+
with gr.Row():
|
| 126 |
+
sel = gr.CheckboxGroup(
|
| 127 |
+
choices=available,
|
| 128 |
+
value=available,
|
| 129 |
+
label="Series",
|
| 130 |
+
)
|
| 131 |
+
plot = gr.Plot(
|
| 132 |
+
value=line_figure(DF, available, tab_name, Y_LABELS.get(tab_name, "")),
|
| 133 |
+
show_label=False,
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
sel.change(
|
| 137 |
+
fn=lambda cols, t=tab_name: line_figure(DF, cols, t, Y_LABELS.get(t, "")),
|
| 138 |
+
inputs=sel,
|
| 139 |
+
outputs=plot,
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
tab_controls.append(sel)
|
| 143 |
+
tab_plots.append(plot)
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
if __name__ == "__main__":
|
| 147 |
+
demo.launch()
|
metrics.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
date,docstring coverage,docstring missing,lines mean,lines max,lines 90th-percentile,statements mean,statements max,statements 90th-percentile,expressions mean,expressions max,expressions 90th-percentile,cyclomatic_complexity mean,cyclomatic_complexity max,cyclomatic_complexity 90th-percentile,parameters mean,parameters max,parameters 90th-percentile,type_coverage mean,type_coverage min,type_coverage 50th-percentile,todo_comments total,duplication.score mean,duplication.score max,duplication.score 90th-percentile,duplication.score 50th-percentile,duplication.duplicated-lines total,files,lines blank,lines comment,lines code
|
| 2 |
+
2025-09-01,0.2527,7049,33.2391,752,78,11.7655,237,26,89.943,1755,214,4.7291,116,11,4.2413,49,10,0.3836,0,0,294,0.4461,1.0,1.0,0.0,206111,702,57342,88980,248807
|
| 3 |
+
2025-10-01,0.247,7389,32.5103,752,75,11.5869,237,26,88.5426,1755,211,4.6568,116,11,4.1776,49,10,0.3906,0,0,299,0.458,1.0,1.0,0.357,209376,724,58371,88520,256988
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
pandas
|
| 3 |
+
plotly
|