saladday1 commited on
Commit
a52b517
·
verified ·
1 Parent(s): e20c2c1

code: sync from git

Browse files
Files changed (1) hide show
  1. code/hfeco/org.py +18 -23
code/hfeco/org.py CHANGED
@@ -273,22 +273,6 @@ def download_rates(groups, P):
273
  return out
274
 
275
 
276
- def aligned(rates, start):
277
- """{"days": [...], "cats": {key: [per day, ...]}} on the days any key has, from `start`. A key
278
- without a value that day takes the step that covers it (0 before it starts, its last after)."""
279
- days = sorted({d for r in rates.values() for d in r if d > start})
280
- out = {}
281
- for k, r in rates.items():
282
- ks = sorted(r)
283
- vals, j = [], 0
284
- for d in days:
285
- while j < len(ks) and ks[j] < d:
286
- j += 1
287
- vals.append(int(round(r[ks[j]] if j < len(ks) else (r[ks[-1]] if ks else 0))))
288
- out[k] = vals
289
- return {"days": days, "cats": out}
290
-
291
-
292
  def build(rels, found, deep_data, who):
293
  """(site, {category: page data}). `deep_data` maps a family key to its dashboard dict."""
294
  snaps = read_snapshots()
@@ -343,7 +327,7 @@ def build(rels, found, deep_data, who):
343
  return lineages[k]["n_models"] >= PAGE_MIN
344
 
345
  P = download_points(labels)
346
- dl_daily = None
347
  if P:
348
  pages_k = [k for k in rels if has_page(k)]
349
  hist = download_history({k: (rels[k]["date"], *ids[k], (today, lineages[k]["official"]["dlall"] or 0, lineages[k]["dlall"]))
@@ -356,14 +340,25 @@ def build(rels, found, deep_data, who):
356
  for rel in metrics.REL_ORDER if rel in set(rel_of[k].values())}, P)
357
  lineages[k]["daily"] = [{"day": d, "rel": rel, "n": int(round(n))}
358
  for rel, rr in rates.items() for d, n in sorted(rr.items())]
359
- # the landing page: MiniMax models and their communities, per day, by modality
360
- cat_ids = defaultdict(set)
361
- cat_start = {}
362
  for k, r in rels.items():
363
  cat_ids[r["cat"]] |= ids[k][0] | ids[k][1]
364
  cat_start[r["cat"]] = min(cat_start.get(r["cat"], r["date"]), r["date"])
 
365
  first = min(cat_start.values())
366
- dl_daily = aligned(download_rates({c: (cat_start[c], cat_ids[c]) for c in cat_ids}, P), first)
 
 
 
 
 
 
 
 
 
 
367
 
368
  by_cat = defaultdict(list)
369
  for key, r in sorted(rels.items(), key=lambda kv: kv[1]["date"], reverse=True):
@@ -376,8 +371,8 @@ def build(rels, found, deep_data, who):
376
 
377
  everyone = {x["id"].split("/")[0] for rs in repos.values() for x in rs}
378
  site = {"today": today, "org": author_entry(ORG), "builders": len(everyone), "categories": [], "releases": []}
379
- if dl_daily:
380
- site["dl_daily"] = dl_daily
381
  for key, r in sorted(rels.items(), key=lambda kv: kv[1]["date"]):
382
  L = lineages[key]
383
  g = Counter()
 
273
  return out
274
 
275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  def build(rels, found, deep_data, who):
277
  """(site, {category: page data}). `deep_data` maps a family key to its dashboard dict."""
278
  snaps = read_snapshots()
 
327
  return lineages[k]["n_models"] >= PAGE_MIN
328
 
329
  P = download_points(labels)
330
+ dl_total = None
331
  if P:
332
  pages_k = [k for k in rels if has_page(k)]
333
  hist = download_history({k: (rels[k]["date"], *ids[k], (today, lineages[k]["official"]["dlall"] or 0, lineages[k]["dlall"]))
 
340
  for rel in metrics.REL_ORDER if rel in set(rel_of[k].values())}, P)
341
  lineages[k]["daily"] = [{"day": d, "rel": rel, "n": int(round(n))}
342
  for rel, rr in rates.items() for d, n in sorted(rr.items())]
343
+ # the landing page: all-time downloads of MiniMax models and everything built on them, by
344
+ # modality, about weekly, ending with today's totals; never going down
345
+ cat_ids, cat_start, now_total = defaultdict(set), {}, Counter()
346
  for k, r in rels.items():
347
  cat_ids[r["cat"]] |= ids[k][0] | ids[k][1]
348
  cat_start[r["cat"]] = min(cat_start.get(r["cat"], r["date"]), r["date"])
349
+ now_total[r["cat"]] += (lineages[k]["official"]["dlall"] or 0) + lineages[k]["dlall"]
350
  first = min(cat_start.values())
351
+ cum = {c: cumulative(P, cat_ids[c]) for c in cat_ids}
352
+ days = sorted({d for v in cum.values() for d in v if first < d < today})
353
+ totals = {}
354
+ for c, v in cum.items():
355
+ run, vals = 0.0, []
356
+ for d in days:
357
+ if d >= cat_start[c] and d in v:
358
+ run = max(run, v[d])
359
+ vals.append(int(round(run)))
360
+ totals[c] = vals + [int(max(run, now_total[c]))]
361
+ dl_total = {"days": days + [today], "cats": totals}
362
 
363
  by_cat = defaultdict(list)
364
  for key, r in sorted(rels.items(), key=lambda kv: kv[1]["date"], reverse=True):
 
371
 
372
  everyone = {x["id"].split("/")[0] for rs in repos.values() for x in rs}
373
  site = {"today": today, "org": author_entry(ORG), "builders": len(everyone), "categories": [], "releases": []}
374
+ if dl_total:
375
+ site["dl_total"] = dl_total
376
  for key, r in sorted(rels.items(), key=lambda kv: kv[1]["date"]):
377
  L = lineages[key]
378
  g = Counter()