saladday1 commited on
Commit
2eaa456
·
verified ·
1 Parent(s): f355fe3

code: sync from git

Browse files
code/README.md CHANGED
@@ -2,7 +2,10 @@
2
 
3
  每天扫一遍 Hugging Face,找出 MiniMax 开源模型的下游仓库,判断每个仓库真正属于哪个官方模型、是什么关系,记录下载量,生成看板。
4
 
5
- - 看板:私有 Space `MiniMaxAI/ecosystem`(静态页面,数据每天更新)
 
 
 
6
  - 数据:私有数据集 `MiniMaxAI/oss-ecosystem-data`
7
  - 定时任务:HF Jobs,`MiniMaxAI` 名下,每天 00:30 UTC
8
 
@@ -17,12 +20,14 @@ hfeco/ 通用流水线,不含任何具体模型的知识
17
  classify.py 三档证据判定:属于哪个成员、什么关系、base_model 声明对不对
18
  metrics.py 每日下载(相邻快照相减)和看板数据(会公开,只放页面用到的字段)
19
  authors.py 作者头像和名字(缓存,只查新作者)
 
20
  store.py 存储布局
21
  scripts/daily.py 每日任务入口(本地和 HF Jobs 一样跑)
22
  scripts/build_reference.py 生成某个家族的官方参考数据
23
  scripts/push_code.py 把代码同步到数据集的 code/(每日任务从那里取代码)
24
  scripts/deploy_space.py 构建 web/ 并上传到 Space(只在页面改动时需要)
25
- web/ 看板页面源码(React + Tailwind + shadcn/ui + Recharts,生态全景用 d3-force)
 
26
  octo-hf/ Octo-patch 新场景:给下游仓库提 base_model PR
27
  eval/ 分类准确率评估(独立标注 + 对比)
28
  ```
@@ -34,6 +39,7 @@ raw/<family>/YYYY-MM-DD.parquet 每天一份,只追加不修改;每日下
34
  labels/<family>/latest.parquet 当前分类结果,带规则版本号,可随时重算
35
  cache/<family>/enrich.jsonl 每个仓库的证据,按仓库 sha 缓存,没变的仓库不重复读
36
  cache/authors.json 作者头像和显示名
 
37
  ```
38
 
39
  ## 加一个模型家族
@@ -43,7 +49,11 @@ cache/authors.json 作者头像和显示名
43
  3. `python scripts/build_reference.py --family <key>` 生成官方参考数据。
44
  4. `python scripts/daily.py --family <key>` 试跑,用 `eval/` 的方法抽样核对准确率。
45
 
46
- 定时任务会自动带上新家族;看板目前只读第一个家族,加第二个时要在 `web/src/App.tsx` 加切换。
 
 
 
 
47
 
48
  ## 公开前要注意
49
 
@@ -52,8 +62,9 @@ cache/authors.json 作者头像和显示名
52
  ## 本地运行
53
 
54
  ```bash
55
- python scripts/daily.py --family h3 # 只在本地生成,不推送
56
- python scripts/daily.py --family h3 --push # 推送到数据集和 Space
 
57
  python scripts/push_code.py # 代码改动后同步给每日任务
58
  python scripts/deploy_space.py # 页面改动后重新构建上传
59
  cd web && npm run dev # 本地看页面(数据放 web/public/data/,不会上传)
 
2
 
3
  每天扫一遍 Hugging Face,找出 MiniMax 开源模型的下游仓库,判断每个仓库真正属于哪个官方模型、是什么关系,记录下载量,生成看板。
4
 
5
+ - 看板:私有 Space `MiniMaxAI/ecosystem`,英文落地页(静态页面,数据每天更新)
6
+ - 首页:全部开源发布的社区规模曲线(发布节点钉在曲线上)、发布卡片、按模态分块(Video / Language / Image / Music)
7
+ - 分类页 `#/<模态>/<发布>`:社区模型增长、类型、作者、全部模型列表、气泡图
8
+ - H3、H3-Image 用本仓库的全量扫描和分类(含没声明 base_model 的仓库);其余发布沿 HF 的 base_model 标签逐层往下找(和 Model tree 一样,只算声明了的)
9
  - 数据:私有数据集 `MiniMaxAI/oss-ecosystem-data`
10
  - 定时任务:HF Jobs,`MiniMaxAI` 名下,每天 00:30 UTC
11
 
 
20
  classify.py 三档证据判定:属于哪个成员、什么关系、base_model 声明对不对
21
  metrics.py 每日下载(相邻快照相减)和看板数据(会公开,只放页面用到的字段)
22
  authors.py 作者头像和名字(缓存,只查新作者)
23
+ org.py 全组织:公开发布怎么分组和归模态(RELEASES)、声明的社区模型、落地页数据
24
  store.py 存储布局
25
  scripts/daily.py 每日任务入口(本地和 HF Jobs 一样跑)
26
  scripts/build_reference.py 生成某个家族的官方参考数据
27
  scripts/push_code.py 把代码同步到数据集的 code/(每日任务从那里取代码)
28
  scripts/deploy_space.py 构建 web/ 并上传到 Space(只在页面改动时需要)
29
+ web/ 页面源码(React + Tailwind + shadcn/ui + Recharts + d3-shape,气泡图用 d3-force)
30
+ space/README.md Space 的模型卡(英文,Space 公开后会被看到)
31
  octo-hf/ Octo-patch 新场景:给下游仓库提 base_model PR
32
  eval/ 分类准确率评估(独立标注 + 对比)
33
  ```
 
39
  labels/<family>/latest.parquet 当前分类结果,带规则版本号,可随时重算
40
  cache/<family>/enrich.jsonl 每个仓库的证据,按仓库 sha 缓存,没变的仓库不重复读
41
  cache/authors.json 作者头像和显示名
42
+ raw/org/YYYY-MM-DD.parquet 全组织快照:官方仓库和声明的社区模型,带累计下载
43
  ```
44
 
45
  ## 加一个模型家族
 
49
  3. `python scripts/build_reference.py --family <key>` 生成官方参考数据。
50
  4. `python scripts/daily.py --family <key>` 试跑,用 `eval/` 的方法抽样核对准确率。
51
 
52
+ 定时任务会自动带上新家族。要让落地页用上它,在 `hfeco/org.py` 的 `RELEASES` 里把对应发布的最后一项写成 `(<key>, <lineage>)`。
53
+
54
+ ## 新发布
55
+
56
+ 官方新开源一个模型时不用改代码:`org.py` 按 `RELEASES` 的名字规则归组,匹配不上的公开仓库自成一个发布、按 pipeline tag 归模态,日志里会提示。想合并进已有发布或换模态,就在 `RELEASES` 加一行。社区模型满 10 个(`PAGE_MIN`)的发布才有自己的分类页 tab。私有仓库永远不会出现:只取 `private is False` 的仓库,写出前 `check_public` 还会再查一遍。
57
 
58
  ## 公开前要注意
59
 
 
62
  ## 本地运行
63
 
64
  ```bash
65
+ python scripts/daily.py # 只在本地生成,不推送
66
+ python scripts/daily.py --push # 推送到数据集和 Space
67
+ python scripts/daily.py --family --push # 只跑全组织那一步(落地页)
68
  python scripts/push_code.py # 代码改动后同步给每日任务
69
  python scripts/deploy_space.py # 页面改动后重新构建上传
70
  cd web && npm run dev # 本地看页面(数据放 web/public/data/,不会上传)
code/hfeco/hub.py CHANGED
@@ -49,9 +49,12 @@ def full_text(q, kind, page=100, cap=5000):
49
  out, skip = [], 0
50
  h = {"Authorization": f"Bearer {get_token()}"} if get_token() else {}
51
  while skip < cap:
52
- r = retry(requests.get, "https://huggingface.co/api/search/full-text",
53
- params={"q": q, "type": kind, "limit": page, "skip": skip}, headers=h, timeout=60)
54
- r.raise_for_status()
 
 
 
55
  hits = r.json().get("hits", [])
56
  if not hits:
57
  break
 
49
  out, skip = [], 0
50
  h = {"Authorization": f"Bearer {get_token()}"} if get_token() else {}
51
  while skip < cap:
52
+ def get():
53
+ r = requests.get("https://huggingface.co/api/search/full-text",
54
+ params={"q": q, "type": kind, "limit": page, "skip": skip}, headers=h, timeout=60)
55
+ r.raise_for_status() # inside retry, so a 5xx/429 from the search backend is retried
56
+ return r
57
+ r = retry(get)
58
  hits = r.json().get("hits", [])
59
  if not hits:
60
  break
code/hfeco/org.py ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """MiniMaxAI's public releases and the community built on them (the landing page and the
2
+ per-category pages).
3
+
4
+ Releases with a full scan (the H3 family) take their numbers from that family's dashboard
5
+ data, so every page shows the same count. For every other release we follow HF's base_model
6
+ tags downward (children, grandchildren, ...), the same links the Hub's Model tree uses.
7
+
8
+ Each run also stores raw/org/YYYY-MM-DD.parquet (official and community repos with their
9
+ all-time downloads) so daily downloads can be differenced later, as for the families.
10
+ """
11
+ import datetime as dt
12
+ import re
13
+ import time
14
+ from collections import Counter, defaultdict
15
+ from concurrent.futures import ThreadPoolExecutor
16
+
17
+ import pandas as pd
18
+
19
+ from . import classify, metrics, store
20
+ from .hub import api, retry
21
+
22
+ ORG = "MiniMaxAI"
23
+ CATEGORY_NAME = {"video": "Video", "language": "Language", "image": "Image", "music": "Music",
24
+ "audio": "Speech & Audio"}
25
+
26
+ # Official repos grouped into releases: (key, name, category, repo-name pattern, deep lineage).
27
+ # First match wins. Public repos that match nothing become their own release, with a category
28
+ # from their pipeline tag, so a new launch shows up without a code change.
29
+ RELEASES = [
30
+ ("h3-image", "MiniMax-H3-Image", "image", r"MiniMax-H3-Image", ("h3", "H3-Image")),
31
+ ("h3", "MiniMax-H3", "video", r"MiniMax-H3", ("h3", "H3")),
32
+ ("music3", "MiniMax-Music3", "music", r"MiniMax-Music3(-.+)?", None),
33
+ ("m3.1-flash", "MiniMax-M3.1-Flash", "language", r"MiniMax-M3\.1-Flash(-.+)?", None),
34
+ ("m3", "MiniMax-M3", "language", r"MiniMax-M3(-.+)?", None),
35
+ ("m2.7", "MiniMax-M2.7", "language", r"MiniMax-M2\.7(-.+)?", None),
36
+ ("m2.5", "MiniMax-M2.5", "language", r"MiniMax-M2\.5(-.+)?", None),
37
+ ("m2.1", "MiniMax-M2.1", "language", r"MiniMax-M2\.1(-.+)?", None),
38
+ ("m2", "MiniMax-M2", "language", r"MiniMax-M2(-.+)?", None),
39
+ ("m1", "MiniMax-M1", "language", r"MiniMax-M1-.+", None),
40
+ ("text-01", "MiniMax-Text-01", "language", r"MiniMax-Text-01(-.+)?", None),
41
+ ("vl-01", "MiniMax-VL-01", "language", r"MiniMax-VL-01(-.+)?", None),
42
+ ("synlogic", "SynLogic", "language", r"SynLogic-.+", None),
43
+ ("vtp", "VTP", "image", r"VTP-.+", None),
44
+ ]
45
+ # Public, but not shown (the user asked for only H3 and H3-Image from the H3 family).
46
+ HIDDEN = {"MiniMaxAI/MiniMax-H3-Image-PE"}
47
+ PIPELINE_CATEGORY = {"text-to-video": "video", "image-to-video": "video", "video-text-to-text": "language",
48
+ "text-to-image": "image", "image-to-image": "image", "text-to-audio": "music",
49
+ "text-to-speech": "audio", "automatic-speech-recognition": "audio"}
50
+ # A release gets its own page once it has this many community models.
51
+ PAGE_MIN = 10
52
+
53
+ OFFICIAL_EXPAND = ["createdAt", "private", "downloads", "downloadsAllTime", "likes", "pipeline_tag"]
54
+ CHILD_EXPAND = ["createdAt", "private", "downloads", "downloadsAllTime", "likes", "tags"]
55
+
56
+
57
+ def public_models():
58
+ """The org's public models. `private` must be exactly False: with an admin token the
59
+ listing also returns private repos, and a missing field must not count as public."""
60
+ ms = retry(lambda: list(api.list_models(author=ORG, expand=OFFICIAL_EXPAND)))
61
+ return [m for m in ms if m.private is False and m.id not in HIDDEN]
62
+
63
+
64
+ def group(models, log=print):
65
+ """Release spec per key, in the order of RELEASES, then the unmatched ones."""
66
+ out, extra = {}, {}
67
+ for m in models:
68
+ name = m.id.split("/", 1)[1]
69
+ hit = next((r for r in RELEASES if re.fullmatch(r[3], name)), None)
70
+ if hit:
71
+ key, title, cat, _, deep = hit
72
+ else:
73
+ key, title, cat, deep = name.lower(), name, PIPELINE_CATEGORY.get(m.pipeline_tag or "", "language"), None
74
+ extra[key] = m.id
75
+ r = out.setdefault(key, {"key": key, "name": title, "cat": cat, "deep": deep, "models": []})
76
+ r["models"].append(m)
77
+ for key, mid in extra.items():
78
+ log(f"org: {mid} matches no release rule; shown as its own release ({out[key]['cat']})")
79
+ for r in out.values():
80
+ r["models"].sort(key=lambda m: -(getattr(m, "downloads_all_time", None) or 0))
81
+ r["base"] = r["models"][0].id
82
+ r["date"] = min(str(m.created_at)[:10] for m in r["models"])
83
+ return out
84
+
85
+
86
+ def _children(parent):
87
+ return parent, retry(lambda: list(api.list_models(filter=f"base_model:{parent}", expand=CHILD_EXPAND, limit=10000)))
88
+
89
+
90
+ def _relation(tags, parent):
91
+ for t in tags or []:
92
+ parts = t.split(":", 2)
93
+ if len(parts) == 3 and parts[0] == "base_model" and parts[2] == parent:
94
+ return parts[1] if parts[1] in ("adapter", "finetune", "quantized", "merge") else "finetune"
95
+ return "finetune"
96
+
97
+
98
+ def crawl(roots, skip=frozenset(), log=print, workers=8):
99
+ """Community models declared on `roots` ({official id: release key}) and on their
100
+ descendants. Each repo gets one parent: the first one found, level by level, in sorted
101
+ order, so a repo naming two MiniMax models lands in the same release every day."""
102
+ owner = dict(roots)
103
+ found, frontier, depth, t0 = {}, sorted(roots), 0, time.time()
104
+ while frontier:
105
+ with ThreadPoolExecutor(workers) as ex:
106
+ res = list(ex.map(_children, frontier))
107
+ nxt = []
108
+ for parent, kids in res:
109
+ for m in sorted(kids, key=lambda m: m.id):
110
+ if (m.id in owner or m.id in skip or m.id.startswith(ORG + "/") or m.private is not False):
111
+ continue
112
+ owner[m.id] = owner[parent]
113
+ found[m.id] = {"repo_id": m.id, "release": owner[parent], "up": parent, "depth": depth,
114
+ "relation": _relation(m.tags, parent),
115
+ "created_at": str(m.created_at)[:19] if m.created_at else None,
116
+ "downloads_30d": m.downloads,
117
+ "downloads_all_time": getattr(m, "downloads_all_time", None),
118
+ "likes": m.likes, "nsfw": bool(classify.NSFW.search(m.id.lower())
119
+ or "not-for-all-audiences" in (m.tags or []))}
120
+ nxt.append(m.id)
121
+ frontier, depth = sorted(nxt), depth + 1
122
+ log(f"org: {len(found)} declared community models in {depth} levels ({time.time() - t0:.0f}s)")
123
+ return found
124
+
125
+
126
+ def snapshot(rels, found, day=None):
127
+ """raw/org/<day>.parquet: one row per official and community repo."""
128
+ now = dt.datetime.now(dt.timezone.utc)
129
+ day = day or now.date().isoformat()
130
+ rows = [{"repo_id": m.id, "kind": "model", "release": r["key"], "official": True, "up": None, "depth": None,
131
+ "relation": None, "created_at": str(m.created_at)[:19], "downloads_30d": m.downloads,
132
+ "downloads_all_time": getattr(m, "downloads_all_time", None), "likes": m.likes, "nsfw": False}
133
+ for r in rels.values() for m in r["models"]]
134
+ rows += [{**v, "kind": "model", "official": False} for v in found.values()]
135
+ df = pd.DataFrame(rows).assign(fetched_at=now.isoformat())
136
+ p = store.LOCAL / "raw" / "org" / f"{day}.parquet"
137
+ p.parent.mkdir(parents=True, exist_ok=True)
138
+ df.to_parquet(p, index=False)
139
+ return p
140
+
141
+
142
+ def read_snapshots():
143
+ files = sorted((store.LOCAL / "raw" / "org").glob("*.parquet"))
144
+ return pd.concat([pd.read_parquet(f).assign(day=f.stem) for f in files], ignore_index=True)
145
+
146
+
147
+ def _declared_lineage(r, comm, d1, today):
148
+ """The family dashboard's lineage record, for a release followed through base_model tags."""
149
+ rel_order = metrics.REL_ORDER
150
+ off = r["models"]
151
+ lin = {
152
+ "base": r["base"],
153
+ "official": {"dl30": sum(m.downloads or 0 for m in off),
154
+ "dlall": sum(getattr(m, "downloads_all_time", None) or 0 for m in off),
155
+ "likes": sum(m.likes or 0 for m in off)},
156
+ "n_models": int(len(comm)),
157
+ "n_authors": int(comm.repo_id.str.split("/").str[0].nunique()) if len(comm) else 0,
158
+ "dl30": int(comm.downloads_30d.fillna(0).sum()),
159
+ "dlall": int(comm.downloads_all_time.fillna(0).sum()),
160
+ "by_relation": {k: {"n": int((comm.relation == k).sum()),
161
+ "dl30": int(comm[comm.relation == k].downloads_30d.fillna(0).sum()),
162
+ "dlall": int(comm[comm.relation == k].downloads_all_time.fillna(0).sum())}
163
+ for k in rel_order},
164
+ "hf_tree": {k: int(((comm.depth == 0) & (comm.relation == k)).sum())
165
+ for k in metrics.HF_ORDER},
166
+ }
167
+ if len(comm):
168
+ g = comm.assign(date=comm.created_at.str[:10]).groupby(["date", "relation"]).size()
169
+ lin["growth"] = [{"date": k[0], "rel": k[1], "n": int(v)} for k, v in g.items()]
170
+ dd = d1[d1.repo_id.isin(set(comm.repo_id))].dropna(subset=["daily"])
171
+ dd = dd.merge(comm[["repo_id", "relation"]], on="repo_id").groupby(["day", "relation"]).daily.sum()
172
+ lin["daily"] = [{"day": k[0], "rel": k[1], "n": int(round(v))} for k, v in dd.items()]
173
+ own = comm[~comm.nsfw]
174
+ ta = (own.assign(a=own.repo_id.str.split("/").str[0]).groupby("a")
175
+ .agg(n=("repo_id", "size"), dlall=("downloads_all_time", "sum"))
176
+ .sort_values(["n", "dlall"], ascending=False).head(12))
177
+ lin["top_authors"] = [{"a": k, "n": int(v.n), "dlall": int(v.dlall or 0)} for k, v in ta.iterrows()]
178
+ else:
179
+ lin.update(growth=[], daily=[], top_authors=[])
180
+ return lin
181
+
182
+
183
+ def build(rels, found, deep_data, who):
184
+ """(site, {category: page data}). `deep_data` maps a family key to its dashboard dict."""
185
+ snaps = read_snapshots()
186
+ days = sorted(snaps.day.unique())
187
+ today = days[-1]
188
+ d1 = metrics.daily_downloads(snaps.assign(kind="model"))
189
+ last = d1[d1.day == today].set_index("repo_id").daily.to_dict()
190
+ comm_all = pd.DataFrame(list(found.values())) if found else pd.DataFrame(
191
+ columns=["repo_id", "release", "up", "depth", "relation", "created_at", "downloads_30d",
192
+ "downloads_all_time", "likes", "nsfw"])
193
+
194
+ lineages, repos = {}, defaultdict(list)
195
+ for key, r in rels.items():
196
+ if r["deep"]:
197
+ fam, lk = r["deep"]
198
+ src = deep_data[fam]
199
+ lin = dict(src["lineages"][lk])
200
+ off = r["models"]
201
+ lin["official"] = {"dl30": sum(m.downloads or 0 for m in off),
202
+ "dlall": sum(getattr(m, "downloads_all_time", None) or 0 for m in off),
203
+ "likes": sum(m.likes or 0 for m in off)}
204
+ lineages[key] = lin
205
+ repos[key] = [{**x, "lin": key} for x in src["repos"] if x["lin"] == lk]
206
+ continue
207
+ comm = comm_all[comm_all.release == key]
208
+ lineages[key] = _declared_lineage(r, comm, d1, today)
209
+ hidden = set(comm[comm.nsfw].repo_id)
210
+ up_of = dict(zip(comm.repo_id, comm.up))
211
+ for x in comm[~comm.nsfw].itertuples():
212
+ p = x.up
213
+ while p in hidden: # hidden repos stay in the totals, not in the bubbles
214
+ p = up_of[p]
215
+ if p.startswith(ORG + "/"):
216
+ p = r["base"] # one centre per release
217
+ v = last.get(x.repo_id)
218
+ repos[key].append({"id": x.repo_id, "lin": key, "rel": x.relation, "up": p,
219
+ "dl30": metrics._i(x.downloads_30d), "dlall": metrics._i(x.downloads_all_time),
220
+ "d1": None if v is None or pd.isna(v) else int(round(v)),
221
+ "likes": metrics._i(x.likes), "created": (x.created_at or "")[:10]})
222
+
223
+ def has_page(k):
224
+ return lineages[k]["n_models"] >= PAGE_MIN
225
+
226
+ by_cat = defaultdict(list)
227
+ for key, r in sorted(rels.items(), key=lambda kv: kv[1]["date"], reverse=True):
228
+ by_cat[r["cat"]].append(key)
229
+ size = {c: sum(lineages[k]["n_models"] for k in ks) for c, ks in by_cat.items()}
230
+ cats = sorted(by_cat, key=lambda c: (c != "video", -size[c]))
231
+
232
+ def author_entry(n):
233
+ return who.get(n, {"a": None, "n": n})
234
+
235
+ everyone = {x["id"].split("/")[0] for rs in repos.values() for x in rs}
236
+ site = {"today": today, "org": author_entry(ORG), "builders": len(everyone), "categories": [], "releases": []}
237
+ for key, r in sorted(rels.items(), key=lambda kv: kv[1]["date"]):
238
+ L = lineages[key]
239
+ g = Counter()
240
+ for x in L["growth"]:
241
+ g[x["date"]] += x["n"]
242
+ site["releases"].append({
243
+ "key": key, "name": r["name"], "cat": r["cat"], "date": r["date"], "base": r["base"],
244
+ "page": has_page(key),
245
+ "models": [{"id": m.id, "created": str(m.created_at)[:10], "dl30": m.downloads,
246
+ "dlall": getattr(m, "downloads_all_time", None), "likes": m.likes} for m in r["models"]],
247
+ "official": L["official"], "n": L["n_models"], "dl30": L["dl30"], "dlall": L["dlall"],
248
+ "authors": L["n_authors"], "growth": sorted([d, n] for d, n in g.items()),
249
+ })
250
+ pages = {}
251
+ for c in cats:
252
+ ks = by_cat[c]
253
+ top = Counter()
254
+ for k in ks:
255
+ for t in lineages[k].get("top_authors", []):
256
+ top[t["a"]] += t["n"]
257
+ builders = set()
258
+ for k in ks:
259
+ builders |= {x["id"].split("/")[0] for x in repos[k]}
260
+ site["categories"].append({
261
+ "key": c, "name": CATEGORY_NAME.get(c, c.title()), "releases": ks,
262
+ "builders": len(builders),
263
+ "top_authors": [{"id": a, **author_entry(a)} for a, _ in top.most_common(8)],
264
+ })
265
+ members = [k for k in ks if has_page(k)]
266
+ if not members:
267
+ continue
268
+ page_repos = [x for k in members for x in repos[k]]
269
+ names = {x["id"].split("/")[0] for x in page_repos} | {ORG}
270
+ pages[c] = {
271
+ "today": today, "snapshot_days": days,
272
+ "family": {"key": c, "title": CATEGORY_NAME.get(c, c.title()),
273
+ "members": [{"lineage": k, "base": rels[k]["base"]} for k in members]},
274
+ "rel_order": metrics.REL_ORDER,
275
+ "lineages": {k: lineages[k] for k in members},
276
+ "repos": page_repos,
277
+ "authors": {n: author_entry(n) for n in sorted(names)},
278
+ }
279
+ return site, pages
280
+
281
+
282
+ def check_public(obj, public_ids):
283
+ """Every MiniMaxAI/... id in data bound for the Space must be a public, shown repo."""
284
+ bad = set()
285
+
286
+ def walk(o):
287
+ if isinstance(o, dict):
288
+ for v in o.values():
289
+ walk(v)
290
+ elif isinstance(o, list):
291
+ for v in o:
292
+ walk(v)
293
+ elif isinstance(o, str) and o.startswith(ORG + "/") and o not in public_ids:
294
+ bad.add(o)
295
+ walk(obj)
296
+ if bad:
297
+ raise ValueError(f"non-public {ORG} repos in page data: {sorted(bad)}")
code/scripts/daily.py CHANGED
@@ -1,6 +1,8 @@
1
  """Daily job: snapshot -> probe new/changed repos -> classify -> dashboard data -> push.
 
 
2
 
3
- python scripts/daily.py [--family h3 ...] [--push] [--skip-snapshot]
4
 
5
  Runs the same way locally and on HF Jobs. With --push it first mirrors the dataset repo,
6
  stores each family's raw snapshot before anything else (the one step that cannot be
@@ -17,7 +19,7 @@ import pandas as pd
17
 
18
  ROOT = Path(__file__).resolve().parent.parent
19
  sys.path.insert(0, str(ROOT))
20
- from hfeco import authors, classify, discover, families, metrics, pipeline, store # noqa: E402
21
  from hfeco.hub import api # noqa: E402
22
 
23
  SPACE_REPO = "MiniMaxAI/ecosystem"
@@ -25,6 +27,7 @@ ap = argparse.ArgumentParser()
25
  ap.add_argument("--family", nargs="*", default=list(families.FAMILIES))
26
  ap.add_argument("--push", action="store_true")
27
  ap.add_argument("--skip-snapshot", action="store_true")
 
28
  args = ap.parse_args()
29
  t0 = time.time()
30
 
@@ -64,12 +67,38 @@ for key in args.family:
64
  log(f"{fam.key}: {len(labels)} labels, {len(data['repos'])} repos on the dashboard")
65
  if args.push:
66
  store.push([lab_path, cache_path, who_path], f"{fam.key}: labels {data['today']}")
67
- api.upload_file(path_or_fileobj=str(data_path), path_in_repo=f"data/{fam.key}.json",
68
- repo_id=SPACE_REPO, repo_type="space", commit_message=f"{fam.key}: data {data['today']}")
69
 
70
- idx_path = store.LOCAL / "dashboard" / "index.json"
71
- metrics.dump({"families": [{"key": f.key, "title": f.title} for f in families.FAMILIES.values()]}, idx_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  if args.push:
73
- api.upload_file(path_or_fileobj=str(idx_path), path_in_repo="data/index.json", repo_id=SPACE_REPO,
74
- repo_type="space", commit_message="index")
 
 
 
75
  log("pushed")
 
1
  """Daily job: snapshot -> probe new/changed repos -> classify -> dashboard data -> push.
2
+ Then the org-wide pass for the landing page: every public MiniMaxAI release, the community
3
+ models declared on it, and one data file per category page.
4
 
5
+ python scripts/daily.py [--family h3 ...] [--push] [--skip-snapshot] [--skip-org]
6
 
7
  Runs the same way locally and on HF Jobs. With --push it first mirrors the dataset repo,
8
  stores each family's raw snapshot before anything else (the one step that cannot be
 
19
 
20
  ROOT = Path(__file__).resolve().parent.parent
21
  sys.path.insert(0, str(ROOT))
22
+ from hfeco import authors, classify, discover, families, metrics, org, pipeline, store # noqa: E402
23
  from hfeco.hub import api # noqa: E402
24
 
25
  SPACE_REPO = "MiniMaxAI/ecosystem"
 
27
  ap.add_argument("--family", nargs="*", default=list(families.FAMILIES))
28
  ap.add_argument("--push", action="store_true")
29
  ap.add_argument("--skip-snapshot", action="store_true")
30
+ ap.add_argument("--skip-org", action="store_true")
31
  args = ap.parse_args()
32
  t0 = time.time()
33
 
 
67
  log(f"{fam.key}: {len(labels)} labels, {len(data['repos'])} repos on the dashboard")
68
  if args.push:
69
  store.push([lab_path, cache_path, who_path], f"{fam.key}: labels {data['today']}")
 
 
70
 
71
+ if args.skip_org:
72
+ sys.exit(0)
73
+
74
+ # ---- org-wide pass: the landing page and one data file per category -------------------------
75
+ log("== MiniMaxAI")
76
+ pub = org.public_models()
77
+ rels = org.group(pub, log=log)
78
+ deep = {}
79
+ for key in {r["deep"][0] for r in rels.values() if r["deep"]}:
80
+ deep[key] = json.loads((store.LOCAL / "dashboard" / f"{key}.json").read_text())
81
+ in_families = {x["id"] for d in deep.values() for x in d["repos"]}
82
+ roots = {m.id: k for k, r in rels.items() if not r["deep"] for m in r["models"]}
83
+ found = org.crawl(roots, skip=in_families, log=log)
84
+ snap_path = org.snapshot(rels, found)
85
+ if args.push:
86
+ store.push([snap_path], f"org: snapshot {snap_path.stem}")
87
+ who, who_path = authors.update({i.split("/")[0] for i in found} | {org.ORG}, log=log)
88
+ site, pages = org.build(rels, found, deep, who)
89
+ public_ids = {m.id for m in pub}
90
+ out = [("site", site)] + list(pages.items())
91
+ paths = []
92
+ for name, obj in out:
93
+ org.check_public(obj, public_ids)
94
+ paths.append(store.LOCAL / "dashboard" / f"{name}.json")
95
+ metrics.dump(obj, paths[-1])
96
+ log(f"org: {len(rels)} releases, {sum(r['n'] for r in site['releases'])} community models, "
97
+ f"pages: {', '.join(pages)}")
98
  if args.push:
99
+ from huggingface_hub import CommitOperationAdd
100
+ store.push([who_path], f"org: authors {site['today']}")
101
+ api.create_commit(SPACE_REPO, [CommitOperationAdd(path_in_repo=f"data/{p.name}", path_or_fileobj=str(p))
102
+ for p in paths],
103
+ commit_message=f"data {site['today']}", repo_type="space")
104
  log("pushed")
code/scripts/deploy_space.py CHANGED
@@ -1,10 +1,12 @@
1
- """Build the dashboard page (web/) and upload it to the Space, leaving data/ alone.
2
 
3
  python scripts/deploy_space.py
4
 
5
- The page is static: it reads data/index.json and data/<family>.json, which the daily job
6
- replaces. This only needs re-running when the page itself changes.
 
7
  """
 
8
  import subprocess
9
  import sys
10
  from pathlib import Path
@@ -17,6 +19,7 @@ from hfeco.hub import api # noqa: E402
17
 
18
  SPACE = "MiniMaxAI/ecosystem"
19
  KEEP = ("data/", "README.md", ".gitattributes")
 
20
 
21
  subprocess.run(["npm", "run", "build"], cwd=ROOT / "web", check=True)
22
  dist = ROOT / "web" / "dist"
@@ -24,6 +27,7 @@ files = [p for p in dist.rglob("*") if p.is_file() and not p.relative_to(dist).a
24
  local = {p.relative_to(dist).as_posix() for p in files}
25
  remote = set(api.list_repo_files(SPACE, repo_type="space"))
26
  ops = [CommitOperationAdd(path_in_repo=p.relative_to(dist).as_posix(), path_or_fileobj=str(p)) for p in files]
27
- ops += [CommitOperationDelete(path_in_repo=f) for f in sorted(remote - local) if not f.startswith(KEEP)]
 
28
  api.create_commit(SPACE, ops, repo_type="space", commit_message="dashboard page")
29
  print(f"uploaded {len(local)} files, removed {len(ops) - len(local)}")
 
1
+ """Build the page (web/) and upload it to the Space, leaving the daily data alone.
2
 
3
  python scripts/deploy_space.py
4
 
5
+ The page is static: it reads data/site.json and data/<category>.json, which the daily job
6
+ replaces. This only needs re-running when the page itself changes. Data files the page no
7
+ longer reads (DATA_FILES lists the ones it does) are removed from the Space.
8
  """
9
+ import re
10
  import subprocess
11
  import sys
12
  from pathlib import Path
 
19
 
20
  SPACE = "MiniMaxAI/ecosystem"
21
  KEEP = ("data/", "README.md", ".gitattributes")
22
+ DATA_FILES = re.compile(r"data/(site|video|language|image|music|audio)\.json")
23
 
24
  subprocess.run(["npm", "run", "build"], cwd=ROOT / "web", check=True)
25
  dist = ROOT / "web" / "dist"
 
27
  local = {p.relative_to(dist).as_posix() for p in files}
28
  remote = set(api.list_repo_files(SPACE, repo_type="space"))
29
  ops = [CommitOperationAdd(path_in_repo=p.relative_to(dist).as_posix(), path_or_fileobj=str(p)) for p in files]
30
+ ops += [CommitOperationDelete(path_in_repo=f) for f in sorted(remote - local)
31
+ if not f.startswith(KEEP) or (f.startswith("data/") and not DATA_FILES.fullmatch(f))]
32
  api.create_commit(SPACE, ops, repo_type="space", commit_message="dashboard page")
33
  print(f"uploaded {len(local)} files, removed {len(ops) - len(local)}")