code: sync from git
Browse files- code/hfeco/org.py +27 -1
- code/scripts/daily.py +1 -0
code/hfeco/org.py
CHANGED
|
@@ -78,7 +78,10 @@ def group(models, log=print):
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
r["date"] = min(str(m.created_at)[:10] for m in r["models"])
|
| 83 |
return out
|
| 84 |
|
|
@@ -279,6 +282,29 @@ def build(rels, found, deep_data, who):
|
|
| 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()
|
|
|
|
| 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 |
+
# The centre of a release is the repo named like it (MiniMax-M3, not its MXFP8 copy),
|
| 82 |
+
# else the most downloaded one.
|
| 83 |
+
named = [m for m in r["models"] if m.id.split("/", 1)[1] == r["name"]]
|
| 84 |
+
r["base"] = (named or r["models"])[0].id
|
| 85 |
r["date"] = min(str(m.created_at)[:10] for m in r["models"])
|
| 86 |
return out
|
| 87 |
|
|
|
|
| 282 |
return site, pages
|
| 283 |
|
| 284 |
|
| 285 |
+
def check_owned_public(objs):
|
| 286 |
+
"""Repos owned by the token's user or orgs are the only private ones a listing can return;
|
| 287 |
+
every such id in data bound for the Space must be public."""
|
| 288 |
+
me = api.whoami()
|
| 289 |
+
owners = {me["name"]} | {o["name"] for o in me.get("orgs", [])}
|
| 290 |
+
ids = set()
|
| 291 |
+
|
| 292 |
+
def walk(o):
|
| 293 |
+
if isinstance(o, dict):
|
| 294 |
+
for v in o.values():
|
| 295 |
+
walk(v)
|
| 296 |
+
elif isinstance(o, list):
|
| 297 |
+
for v in o:
|
| 298 |
+
walk(v)
|
| 299 |
+
elif isinstance(o, str) and o.count("/") == 1 and o.split("/")[0] in owners and " " not in o:
|
| 300 |
+
ids.add(o)
|
| 301 |
+
for o in objs:
|
| 302 |
+
walk(o)
|
| 303 |
+
bad = [i for i in sorted(ids) if retry(lambda: api.model_info(i, expand=["private"])).private is not False]
|
| 304 |
+
if bad:
|
| 305 |
+
raise ValueError(f"private repos in page data: {bad}")
|
| 306 |
+
|
| 307 |
+
|
| 308 |
def check_public(obj, public_ids):
|
| 309 |
"""Every MiniMaxAI/... id in data bound for the Space must be a public, shown repo."""
|
| 310 |
bad = set()
|
code/scripts/daily.py
CHANGED
|
@@ -93,6 +93,7 @@ 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:
|
|
|
|
| 93 |
org.check_public(obj, public_ids)
|
| 94 |
paths.append(store.LOCAL / "dashboard" / f"{name}.json")
|
| 95 |
metrics.dump(obj, paths[-1])
|
| 96 |
+
org.check_owned_public([obj for _, obj in out])
|
| 97 |
log(f"org: {len(rels)} releases, {sum(r['n'] for r in site['releases'])} community models, "
|
| 98 |
f"pages: {', '.join(pages)}")
|
| 99 |
if args.push:
|