AdithyaSK HF Staff commited on
Commit
985470a
·
verified ·
1 Parent(s): 599974a

Deploy HF RL Explorer

Browse files
Files changed (1) hide show
  1. app/seo.py +8 -4
app/seo.py CHANGED
@@ -97,8 +97,8 @@ def public_rows(rows):
97
  return [r for r in rows if r["key"] not in hidden and not any(r.get(k) for k in ("private", "gated", "restricted"))]
98
 
99
 
100
- def discoverable(r):
101
- return r.get("kind") == "dataset" or space_checks.browseable(space_checks.inventory().get(r["id"]))
102
 
103
 
104
  def index_rows(spec: str) -> list[dict[str, Any]]:
@@ -215,7 +215,8 @@ def crumbs(base: str, items: list[tuple[str, str]]) -> tuple[str, dict[str, Any]
215
  def home(request: Request) -> HTMLResponse:
216
  base = base_url(request)
217
  by, rows = listing()
218
- rows = [r for r in public_rows(rows) if discoverable(r)]
 
219
  top = sorted(rows, key=lambda r: (r.get("trending") or 0) * 1e9 + (r.get("downloads") or 0), reverse=True)[:120]
220
  desc = DESCRIPTION
221
  body = (f"<header class=\"tp-head\"><h1>{TAGLINE}</h1><p class=\"lede\">{esc(desc)}</p></header>"
@@ -401,10 +402,11 @@ def _entries() -> tuple[list[tuple[str, str | None]], list[tuple[str, str | None
401
  return _sitemap["pages"], _sitemap["tasks"]
402
  by, rows = listing()
403
  rows = public_rows(rows)
 
404
  pages: list[tuple[str, str | None]] = [("/", None), ("/community", None)]
405
  # Every public dataset and only Spaces with evidence of a supported API.
406
  pages += [(_href(r), (r.get("updated") or "")[:10] or None) for r in rows
407
- if discoverable(r)]
408
  tasks: list[tuple[str, str | None]] = []
409
  for spec in dict.fromkeys(r["id"] for r in rows if r["kind"] == "dataset"):
410
  try:
@@ -426,6 +428,8 @@ def _space_ranges():
426
  if r.get("kind") != "space" or not space_checks.browseable(records.get(r["id"])):
427
  continue
428
  rec = records[r["id"]]
 
 
429
  ranges = rec.get("task_splits") or seo_tasks.ranges((spaces_live.last_seen(r["id"]) or {}).get("task_api"))
430
  for env, split, n in ranges:
431
  if type(n) is int and 0 < n <= 1_000_000_000:
 
97
  return [r for r in rows if r["key"] not in hidden and not any(r.get(k) for k in ("private", "gated", "restricted"))]
98
 
99
 
100
+ def discoverable(r, records=None):
101
+ return r.get("kind") == "dataset" or space_checks.browseable((space_checks.inventory() if records is None else records).get(r["id"]))
102
 
103
 
104
  def index_rows(spec: str) -> list[dict[str, Any]]:
 
215
  def home(request: Request) -> HTMLResponse:
216
  base = base_url(request)
217
  by, rows = listing()
218
+ checks = space_checks.inventory()
219
+ rows = [r for r in public_rows(rows) if discoverable(r, checks)]
220
  top = sorted(rows, key=lambda r: (r.get("trending") or 0) * 1e9 + (r.get("downloads") or 0), reverse=True)[:120]
221
  desc = DESCRIPTION
222
  body = (f"<header class=\"tp-head\"><h1>{TAGLINE}</h1><p class=\"lede\">{esc(desc)}</p></header>"
 
402
  return _sitemap["pages"], _sitemap["tasks"]
403
  by, rows = listing()
404
  rows = public_rows(rows)
405
+ checks = space_checks.inventory()
406
  pages: list[tuple[str, str | None]] = [("/", None), ("/community", None)]
407
  # Every public dataset and only Spaces with evidence of a supported API.
408
  pages += [(_href(r), (r.get("updated") or "")[:10] or None) for r in rows
409
+ if discoverable(r, checks)]
410
  tasks: list[tuple[str, str | None]] = []
411
  for spec in dict.fromkeys(r["id"] for r in rows if r["kind"] == "dataset"):
412
  try:
 
428
  if r.get("kind") != "space" or not space_checks.browseable(records.get(r["id"])):
429
  continue
430
  rec = records[r["id"]]
431
+ if not (rec.get("task_catalog") or {}).get("tasks") and not rec.get("task_splits"):
432
+ continue
433
  ranges = rec.get("task_splits") or seo_tasks.ranges((spaces_live.last_seen(r["id"]) or {}).get("task_api"))
434
  for env, split, n in ranges:
435
  if type(n) is int and 0 < n <= 1_000_000_000: