Spaces:
Running
Running
Refresh Diffusers dashboard snapshot
Browse filesFiles changed (4)
32 unmodified lines333435363738394 unmodified lines444546474849505132 unmodified linesOptional environment variables:- `DASHBOARD_HF_TOKEN` (or `HF_TOKEN`) for Hub API access.- `DASHBOARD_GITHUB_TOKEN` for a higher GitHub API rate limit and, when authorized for the repository, timestamped star history.Tokens are read only by the collector; they are never written into the snapshot. No token is required for public data. To update a running local app, rerun the collector and restart the app.4 unmodified lines- **Publishers** are account names from model repository IDs, not a verified list of institutions.- **Organizations** are a curated subset of verified Hub organization accounts. Their kind and country are reviewed manually, with the review date shown in the tab. Model counts and download totals come only from Diffusers-tagged models in the current snapshot.- **Model percentages** compare the current tagged model inventory with the cohort published before the last 90 days. The label says “models published in the past 3 months” because downloads and likes on newly published models are a cohort contribution, not an observed change in those counters over time.- **GitHub stars, issues and PR percentages** are measured across saved snapshots, with the actual comparison period shown. They appear after enough snapshots exist. Contributor percentages use the full commit-author history when available.- **GitHub star history** is backfilled for up to two years only when `DASHBOARD_GITHUB_TOKEN` has access to timestamped stargazers. Without that access, the chart grows from scheduled snapshots. Contributor growth uses a complete local Diffusers checkout if one is available beside this project; set `DASHBOARD_DIFFUSERS_GIT_PATH` to use another checkout. In scheduled runs with a GitHub token, it walks the full default-branch commit history instead. Recent commits extend the local history, and the rolling 30-day activity line is omitted if an API-only scan is incomplete. Git commit authors and GitHub-linked accounts have different counts; the chart labels them accordingly.- **PyPI percentages** compare equal-length daily download windows 90 days apart, using the mirror-excluded daily series. The latest day, week, and month figures use the same series when it is available.- **Trends** start on the first day this dashboard records a snapshot. Publication charts use Hub repository creation dates and are separate from snapshot history.32 unmodified lines333435363738394 unmodified lines444546474849505132 unmodified linesOptional environment variables:- `DASHBOARD_HF_TOKEN` (or `HF_TOKEN`) for Hub API access.- `DASHBOARD_GITHUB_TOKEN` for a higher GitHub API rate limit and complete API-based contributor history.Tokens are read only by the collector; they are never written into the snapshot. No token is required for public data. To update a running local app, rerun the collector and restart the app.4 unmodified lines- **Publishers** are account names from model repository IDs, not a verified list of institutions.- **Organizations** are a curated subset of verified Hub organization accounts. Their kind and country are reviewed manually, with the review date shown in the tab. Model counts and download totals come only from Diffusers-tagged models in the current snapshot.- **Model percentages** compare the current tagged model inventory with the cohort published before the last 90 days. The label says “models published in the past 3 months” because downloads and likes on newly published models are a cohort contribution, not an observed change in those counters over time.- **GitHub star percentages** use the aggregate history when available; issue and PR percentages use saved snapshots. The actual comparison period is shown. Contributor percentages use the full commit-author history when available.- **GitHub star history** is backfilled for up to two years from GitHub's public aggregate weekly and daily star counts. It does not list stargazers or require a token. If the aggregate endpoint is unavailable, the chart grows from scheduled snapshots. GitHub does not guarantee that its week and day boundaries align with UTC. Contributor growth uses a complete local Diffusers checkout if one is available beside this project; set `DASHBOARD_DIFFUSERS_GIT_PATH` to use another checkout. In scheduled runs with a GitHub token, it walks the full default-branch commit history instead. Recent commits extend the local history, and the rolling 30-day activity line is omitted if an API-only scan is incomplete. Git commit authors and GitHub-linked accounts have different counts; the chart labels them accordingly.- **PyPI percentages** compare equal-length daily download windows 90 days apart, using the mirror-excluded daily series. The latest day, week, and month figures use the same series when it is available.- **Trends** start on the first day this dashboard records a snapshot. Publication charts use Hub repository creation dates and are separate from snapshot history.
2 unmodified lines345678936 unmodified lines464748495051525354555657585991 unmodified lines1511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992 unmodified linesfrom __future__ import annotationsimport jsonimport mathimport osimport subprocessfrom collections import Counter, defaultdict36 unmodified linesreturn response.json()def github_headers(token: str | None, *, stars: bool = False) -> dict[str, str]:headers = {"Accept": "application/vnd.github.star+json" if stars else "application/vnd.github+json","User-Agent": "diffusers-dashboard"}if token:headers["Authorization"] = f"Bearer {token}"return headersdef collect_contributors(token: str | None) -> list[dict]:contributors = []for page in range(1, 21):91 unmodified linesreturn resultdef collect_star_history(token: str | None, stars: int, *, days: int = 730) -> list[dict]:"""Backfill timestamped stars when the GitHub token can see them."""if not token or stars <= 0:return []last_page = math.ceil(stars / 100)cutoff = (datetime.now(timezone.utc) - timedelta(days=days)).date()def page(number: int) -> list[dict] | None:response = requests.get(f"https://api.github.com/repos/{GITHUB_REPO}/stargazers?per_page=100&page={number}",headers=github_headers(token, stars=True), timeout=30)if response.status_code in (403, 404):return Noneresponse.raise_for_status()rows = response.json()return rows if isinstance(rows, list) and (not rows or "starred_at" in rows[-1]) else Nonefirst = page(1)if not first:return []low, high = 1, last_pagewhile low < high:middle = (low + high) // 2rows = page(middle)if not rows:return []if datetime.fromisoformat(rows[-1]["starred_at"].replace("Z", "+00:00")).date() < cutoff:low = middle + 1else:high = middlefirst_page = lowif last_page - first_page + 1 > 250:return []timestamps = []for number in range(first_page, last_page + 1):rows = first if number == 1 else page(number)if rows is None:return []timestamps.extend(datetime.fromisoformat(row["starred_at"].replace("Z", "+00:00")).date() for row in rows)base_count = (first_page - 1) * 100 + sum(day < cutoff for day in timestamps)additions = Counter(day for day in timestamps if day >= cutoff)result = []total = base_countfor offset in range((datetime.now(timezone.utc).date() - cutoff).days + 1):day = cutoff + timedelta(days=offset)total += additions[day]result.append({"date": day.isoformat(), "stars": total})2 unmodified lines34567836 unmodified lines45464748495091 unmodified lines1421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791802 unmodified linesfrom __future__ import annotationsimport jsonimport osimport subprocessfrom collections import Counter, defaultdict36 unmodified linesreturn response.json()def collect_contributors(token: str | None) -> list[dict]:contributors = []for page in range(1, 21):91 unmodified linesreturn resultdef collect_star_history(token: str | None, stars: int, *, days: int = 730,now: datetime | None = None) -> list[dict]:"""Build daily cumulative stars from GitHub's aggregate history endpoint."""if stars <= 0:return []now = now or datetime.now(timezone.utc)cutoff = now.date() - timedelta(days=days)additions: Counter = Counter()for page in range(1, 101):rows = get_json(f"https://api.github.com/repos/{GITHUB_REPO}/stargazers/history?per_page=30&page={page}",token=token,)if not isinstance(rows, list):raise TypeError("Unexpected GitHub star history response")if page == 1 and not rows:return []for row in rows:week = datetime.fromtimestamp(row["week"], timezone.utc).date()daily = row["days"]if len(daily) != 7 or sum(daily) != row["total"]:raise ValueError("Invalid GitHub star history week")for offset, count in enumerate(daily):additions[week + timedelta(days=offset)] += countif len(rows) < 30:breakelse:raise RuntimeError("GitHub star history exceeded 100 pages")# GitHub's weekly boundaries are not guaranteed to align with UTC exactly.total = sum(count for day, count in additions.items() if day < cutoff)result = []for offset in range((now.date() - cutoff).days + 1):day = cutoff + timedelta(days=offset)total += additions[day]result.append({"date": day.isoformat(), "stars": total})
236 unmodified lines237238239240241242243244245246247248249250236 unmodified lineswith gr.Tab("GitHub & Community"):gr.Markdown("### 🚀 Project Momentum")gr.HTML(card_row(metric_card("GitHub Stars", github.get("stars"), stars_delta, "Growth across collected snapshots", stars_window),metric_card("PyPI Downloads", pypi.get("last_month"), pypi_30_delta, "Last 30 days compared with the same window three months earlier", pypi_30_window),))with gr.Row():gr.Plot(value=star_history_chart(github.get("star_history", []), history), show_label=False)gr.Plot(value=pypi_chart(pypi_daily), show_label=False)if not github.get("star_history"):gr.HTML(notice("Star history starts with saved snapshots. A maintainer token can backfill timestamped stars."))gr.Markdown("### 🤝 Community Health")activity = contributor_activitygr.HTML(card_row(236 unmodified lines237238239240241242243244245246247248249250236 unmodified lineswith gr.Tab("GitHub & Community"):gr.Markdown("### 🚀 Project Momentum")gr.HTML(card_row(metric_card("GitHub Stars", github.get("stars"), stars_delta, "Compared with historical star counts", stars_window),metric_card("PyPI Downloads", pypi.get("last_month"), pypi_30_delta, "Last 30 days compared with the same window three months earlier", pypi_30_window),))with gr.Row():gr.Plot(value=star_history_chart(github.get("star_history", []), history), show_label=False)gr.Plot(value=pypi_chart(pypi_daily), show_label=False)if not github.get("star_history"):gr.HTML(notice("Historical star counts are temporarily unavailable; the chart grows from saved snapshots."))gr.Markdown("### 🤝 Community Health")activity = contributor_activitygr.HTML(card_row(
README.md+3-3
dashboard/collect.py+30-49
dashboard/ui.py+2-2
data/snapshot.json