Spaces:
Running
Running
Science: leave out single-account bulk uploads; charts fill spare card height
#3
by evijit HF Staff - opened
Files changed (3)
46 unmodified lines47484946 unmodified linesScience domains use the rules in `build/sci_rules.py` (with `build/data/lang_codes.json`), thesame rules as [evijit/hf-science-growth](https://huggingface.co/spaces/evijit/hf-science-growth).The Job fetches them from this Space when `build.py` runs from its URL.46 unmodified lines47484950515246 unmodified linesScience domains use the rules in `build/sci_rules.py` (with `build/data/lang_codes.json`), thesame rules as [evijit/hf-science-growth](https://huggingface.co/spaces/evijit/hf-science-growth).The Job fetches them from this Space when `build.py` runs from its URL.Bulk uploads are left out of the science numbers, as in that Space: when one account uploads 100or more models (or datasets) in a domain in one quarter, more than half of that domain's quarter,all of that account's repos in that domain are dropped, so one batch upload doesn't read as a field taking off.
17 unmodified lines181920212223586 unmodified lines61061161261361461517 unmodified lines63363463563663763817 unmodified linesimport jsonimport sysimport timefrom datetime import UTC, datetimefrom pathlib import Path586 unmodified linesif doms:found.append(("dataset", author, created, dl or 0, R.primary(sorted(doms), author)))# Every month from March 2022 (older repos share a placeholder date there) to the current one# so far, and the same rolling 90-day windows as the rest of the page.months, y, m = [], 2022, 317 unmodified linesby_dom: dict = {}monthly = {"model": [0] * n, "dataset": [0] * n}for repo, author, created, dl, dom in found:d = by_dom.setdefault(dom, {"key": dom, "name": SCIENCE_LABELS[dom], "core": dom in R.CORE, "model": 0, "dataset": 0,"authors": set(), "by": {}})# Per repo type: count, downloads, rolling windows and months, so models and datasets read separately.17 unmodified lines18192021222324586 unmodified lines61161261361461561661761861962062162262362462562662762817 unmodified lines64664764864965065165265317 unmodified linesimport jsonimport sysimport timefrom collections import Counterfrom datetime import UTC, datetimefrom pathlib import Path586 unmodified linesif doms:found.append(("dataset", author, created, dl or 0, R.primary(sorted(doms), author)))# Bulk uploads, same rule as the science Space: one account that uploads >= 100 repos of a type# in a domain in one quarter (from 2023-Q1), more than half of that domain's quarter, makes a# spike that says more about that account than about the field. All of that account's repos in# that domain are left out, not only the peak quarter, or the spike just moves to the next one.quarter = lambda c: f"{c.year}-Q{(c.month - 1) // 3 + 1}"per, cell = Counter(), Counter()for repo, author, created, _, dom in found:if quarter(created) >= "2023-Q1":per[repo, dom, quarter(created), author] += 1cell[repo, dom, quarter(created)] += 1bulk = {(r, d, a) for (r, d, q, a), k in per.items() if k >= 100 and k > 0.5 * cell[r, d, q]}# Every month from March 2022 (older repos share a placeholder date there) to the current one# so far, and the same rolling 90-day windows as the rest of the page.months, y, m = [], 2022, 317 unmodified linesby_dom: dict = {}monthly = {"model": [0] * n, "dataset": [0] * n}for repo, author, created, dl, dom in found:if (repo, dom, author) in bulk:continued = by_dom.setdefault(dom, {"key": dom, "name": SCIENCE_LABELS[dom], "core": dom in R.CORE, "model": 0, "dataset": 0,"authors": set(), "by": {}})# Per repo type: count, downloads, rolling windows and months, so models and datasets read separately.
108 unmodified lines109110111112113114519 unmodified lines63463563663763863964064164264343 unmodified lines6876886896906916926931025 unmodified lines171917201721172217231724108 unmodified lines/* ---------- charts ---------- */.chart { position: relative; width: 100%; }.chart svg { display: block; width: 100%; overflow: visible; }svg text { fill: var(--muted); font-size: 10.5px; font-family: inherit; }svg text.val { fill: var(--ink-2); font-weight: 500; }519 unmodified linesreturn svg;}// ---------- line chart ----------function lineChart(container, { xs, series, fmtX, fmtTip = dayLong, height = 220, endLabels = true, yTicks = 4, margin = {} }) {container.replaceChildren();const W = Math.max(200, container.clientWidth), H = height;const narrow = W < 460;const m = { t: 8, r: endLabels ? (narrow ? 48 : 104) : 6, b: 18, l: 38, ...margin };const iw = W - m.l - m.r, ih = H - m.t - m.b;43 unmodified lines// ---------- columns, single or stacked ----------function columns(container, { xs, series, fmtX, fmtTip = weekOf, share = false, height = 180, prevLabel = "vs prior week" }) {container.replaceChildren();const W = Math.max(200, container.clientWidth), H = height;const m = { t: 6, r: 2, b: 18, l: 38 };const iw = W - m.l - m.r, ih = H - m.t - m.b;const totals = xs.map((_, i) => series.reduce((a, s) => a + s.values[i], 0));1025 unmodified lines// ---------- charts that depend on width ----------function render() {renderModality();renderModalityChart();const cum = state.growth === "cumulative";108 unmodified lines109110111112113114115116519 unmodified lines63663763863964064164264364464564664764864943 unmodified lines6936946956966976986991025 unmodified lines17251726172717281729173017311732108 unmodified lines/* ---------- charts ---------- */.chart { position: relative; width: 100%; }/* A chart takes the card's spare height when a taller card sits beside it in the row (see fillHeight). */.c > .chart { flex: 1 0 auto; }.chart svg { display: block; width: 100%; overflow: visible; }svg text { fill: var(--muted); font-size: 10.5px; font-family: inherit; }svg text.val { fill: var(--ink-2); font-weight: 500; }519 unmodified linesreturn svg;}// The chart's height, or more when its card has room to spare: an emptied .chart grows (flex) into// whatever height the row gives the card beyond its other content.const fillHeight = (container, height) => Math.max(height, Math.floor(container.clientHeight));// ---------- line chart ----------function lineChart(container, { xs, series, fmtX, fmtTip = dayLong, height = 220, endLabels = true, yTicks = 4, margin = {} }) {container.replaceChildren();const W = Math.max(200, container.clientWidth), H = fillHeight(container, height);const narrow = W < 460;const m = { t: 8, r: endLabels ? (narrow ? 48 : 104) : 6, b: 18, l: 38, ...margin };const iw = W - m.l - m.r, ih = H - m.t - m.b;43 unmodified lines// ---------- columns, single or stacked ----------function columns(container, { xs, series, fmtX, fmtTip = weekOf, share = false, height = 180, prevLabel = "vs prior week" }) {container.replaceChildren();const W = Math.max(200, container.clientWidth), H = fillHeight(container, height);const m = { t: 6, r: 2, b: 18, l: 38 };const iw = W - m.l - m.r, ih = H - m.t - m.b;const totals = xs.map((_, i) => series.reduce((a, s) => a + s.values[i], 0));1025 unmodified lines// ---------- charts that depend on width ----------function render() {// Empty every chart first, so each one measures the room its row leaves, not the old charts' heights.for (const c of document.querySelectorAll(".c > .chart")) c.replaceChildren();renderModality();renderModalityChart();const cum = state.growth === "cumulative";
README.md+3
build/build.py+15
site/template.html+10-2