nspasojevic commited on
Commit
91fc062
Β·
verified Β·
1 Parent(s): 7057e4d

UI slim-ui-f0276569 (query normalization + 5k verdict memory) + USD add-1 loader (#78)

Browse files

Dist = indexing #79 (slim-ui-license f0276569 = 8174ebc0 + caching a5e567dc). pipeline/library_media.py = indexing #78 @5ea312f (reads media-<stamp>.usd-add-<n>.tar: the 8 OEM props + 9 loop props with joints; archives in S3, read back). One restart.

pipeline/library_media.py CHANGED
@@ -49,6 +49,16 @@ skipped or failed USD HD archive leaves tier 1; a skipped or failed USD archive
49
  either is fetched unless the Space's ``VIEWER_FORMAT`` (the Explorer's /config.js ``features.viewerFormat``, rendered
50
  by supervisord.conf) is ``usd`` or ``auto``; LIBRARY_MEDIA_USD=off / LIBRARY_MEDIA_USD_HD=off skip one or both. nginx
51
  serves a ``.usdc`` as its ``.br`` to a client that accepts brotli.
 
 
 
 
 
 
 
 
 
 
52
  """
53
 
54
  from __future__ import annotations
@@ -87,6 +97,9 @@ USD_OVERLAY = "usd-manifest.json" # the USD archive's first member: the bloc
87
  USD_OVERLAY_MAX = 64 * 2**20
88
  USD_PROFILE = "simready-web-usd/1"
89
  USD_ASSET = "usd/asset.usdc"
 
 
 
90
  VIEWER_FORMATS = ("glb", "usd", "auto") # the Space's VIEWER_FORMAT; anything else is "glb" (supervisord.conf too)
91
 
92
 
@@ -296,10 +309,12 @@ def usd_overlay(doc, manifest: dict) -> tuple[dict[str, tuple[str, dict]], int]:
296
  return out, left
297
 
298
 
299
- def stream_usd(body, tree: Path, manifest: dict) -> tuple[dict[str, tuple[str, dict]], int, int, int, int]:
 
300
  """Write the USD archive ``body`` into ``tree``: its FIRST member must be ``usd-manifest.json`` (else ValueError,
301
  nothing written), whose usable blocks (``usd_overlay``) name the only members written β€” each block's
302
- ``usd_tier1_files``. (blocks, left out, written, bytes, skipped)."""
 
303
  blocks, left, total = None, 0, [0, 0, 0]
304
  with tarfile.open(fileobj=body, mode="r|") as tf:
305
  for m in tf:
@@ -308,6 +323,8 @@ def stream_usd(body, tree: Path, manifest: dict) -> tuple[dict[str, tuple[str, d
308
  raise ValueError(f"the first member is {m.name!r}, not {USD_OVERLAY}")
309
  with tf.extractfile(m) as src:
310
  blocks, left = usd_overlay(json.loads(src.read()), manifest)
 
 
311
  allowed: dict[str, set[str]] = {}
312
  for i, block in blocks.values():
313
  allowed.setdefault(i, set()).update(usd_tier1_files(block))
@@ -460,33 +477,114 @@ def fetch_usd(cfg: Config, store, uri: str, tree: Path) -> int:
460
  return shown
461
 
462
 
463
- def fetch_usd_hd(cfg: Config, store, uri: str, tree: Path, blocks: dict[str, tuple[str, dict]]) -> set[str]:
464
- """Stream the ``.usdhd.tar`` ``uri`` into ``tree`` (only ``blocks``' ``usd_hd_files``); the Space keys whose
465
- full-level files are all there. Off (LIBRARY_MEDIA_USD_HD), absent or without room: none."""
 
 
466
  if cfg.get("LIBRARY_MEDIA_USD_HD", "").strip().lower() in DISABLED:
467
- print("==> library media USD HD: off (LIBRARY_MEDIA_USD_HD) β€” USD tier 1 only")
468
  return set()
469
  size = listed_size(cfg, store, uri)
470
  if size is None:
471
- print(f"==> library media USD HD: none at {uri} β€” USD tier 1 only")
472
  return set()
473
- if not room_for(tree, size, "USD HD"):
474
  return set()
475
  allowed: dict[str, set[str]] = {}
476
  for i, block in blocks.values():
477
  allowed.setdefault(i, set()).update(usd_hd_files(block))
478
  t0 = time.time()
479
- got = stream_with_retry(cfg, store, uri, "USD HD", lambda body: stream_hd(body, tree, allowed))
480
  if got is None:
481
  return set()
482
  written, nbytes, skipped = got
483
  keys = {k for k, (i, b) in blocks.items() if landed(tree, i, usd_hd_files(b))}
484
- print(f"==> library media USD HD: {len(keys)} of {len(blocks)} blocks with their full level ({written} files, "
485
  f"{nbytes / 1e6:.0f} MB) from {uri} in {time.time() - t0:.0f} s"
486
  + (f"; {skipped} members not listed skipped" if skipped else ""))
487
  return keys
488
 
489
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
490
  def fetch(env: dict[str, str], root: Path = MEDIA_ROOT, store=None) -> int:
491
  """Fetch this corpus's media into ``root/INDEX_KEY``; returns the number of assets installed (0: none).
492
  ``store``: artifact_store's read_text / list_subprefixes / list_objects / download_file / bucket_base."""
@@ -536,6 +634,10 @@ def fetch(env: dict[str, str], root: Path = MEDIA_ROOT, store=None) -> int:
536
  except Exception as exc: # noqa: BLE001 β€” the GLB tiers are served already; web USD is a bonus
537
  print(f"==> library media USD: stopped ({type(exc).__name__}: {str(exc)[:300]}) β€” the GLB stays",
538
  file=sys.stderr)
 
 
 
 
539
  return count
540
 
541
 
 
49
  either is fetched unless the Space's ``VIEWER_FORMAT`` (the Explorer's /config.js ``features.viewerFormat``, rendered
50
  by supervisord.conf) is ``usd`` or ``auto``; LIBRARY_MEDIA_USD=off / LIBRARY_MEDIA_USD_HD=off skip one or both. nginx
51
  serves a ``.usdc`` as its ``.br`` to a client that accepts brotli.
52
+
53
+ Web USD additions (2026-10-15): the pair above is write-once, so blocks made later (new assets, or a better
54
+ conversion of some) travel in supplementary pairs of the same stamp, ``media-<stamp>.usd-add-<n>.tar`` (same layout
55
+ as the ``.usd.tar``: its own ``usd-manifest.json`` first) and ``media-<stamp>.usdhd-add-<n>.tar``, n = 1, 2, ...
56
+ They are applied after the pair, in order of n, each with its own disk check, under the same switches. An add's
57
+ block replaces whatever block that entry had: before the add writes anything, its entries' ``usd`` blocks leave the
58
+ served manifest and their ``<id>/usd/`` folders are removed (no file of an older block stays beside the new one);
59
+ then each block is served at tier 1 once its files landed, and at full once its ``.usdhd-add-<n>.tar`` files did.
60
+ A failed add leaves its entries on the GLB and never stops a later add. Revert: delete the add's two objects and
61
+ restart.
62
  """
63
 
64
  from __future__ import annotations
 
97
  USD_OVERLAY_MAX = 64 * 2**20
98
  USD_PROFILE = "simready-web-usd/1"
99
  USD_ASSET = "usd/asset.usdc"
100
+ # Web USD additions (see the module doc): media-<stamp>.usd-add-<n>.tar + .usdhd-add-<n>.tar, n without a leading 0
101
+ USD_ADD = r"\.usd-add-([1-9][0-9]{0,2})\.tar"
102
+ USD_HD_ADD = ".usdhd-add-{n}.tar"
103
  VIEWER_FORMATS = ("glb", "usd", "auto") # the Space's VIEWER_FORMAT; anything else is "glb" (supervisord.conf too)
104
 
105
 
 
309
  return out, left
310
 
311
 
312
+ def stream_usd(body, tree: Path, manifest: dict,
313
+ before=None) -> tuple[dict[str, tuple[str, dict]], int, int, int, int]:
314
  """Write the USD archive ``body`` into ``tree``: its FIRST member must be ``usd-manifest.json`` (else ValueError,
315
  nothing written), whose usable blocks (``usd_overlay``) name the only members written β€” each block's
316
+ ``usd_tier1_files``. ``before(blocks)``, when given, runs once the blocks are read and before any member is
317
+ written (an add clears its entries there). (blocks, left out, written, bytes, skipped)."""
318
  blocks, left, total = None, 0, [0, 0, 0]
319
  with tarfile.open(fileobj=body, mode="r|") as tf:
320
  for m in tf:
 
323
  raise ValueError(f"the first member is {m.name!r}, not {USD_OVERLAY}")
324
  with tf.extractfile(m) as src:
325
  blocks, left = usd_overlay(json.loads(src.read()), manifest)
326
+ if before is not None:
327
+ before(blocks)
328
  allowed: dict[str, set[str]] = {}
329
  for i, block in blocks.values():
330
  allowed.setdefault(i, set()).update(usd_tier1_files(block))
 
477
  return shown
478
 
479
 
480
+ def fetch_usd_hd(cfg: Config, store, uri: str, tree: Path, blocks: dict[str, tuple[str, dict]],
481
+ what: str = "USD HD") -> set[str]:
482
+ """Stream the ``.usdhd.tar`` ``uri`` (or an add's ``.usdhd-add-<n>.tar``; ``what`` names it in the log) into
483
+ ``tree`` (only ``blocks``' ``usd_hd_files``); the Space keys whose full-level files are all there. Off
484
+ (LIBRARY_MEDIA_USD_HD), absent or without room: none."""
485
  if cfg.get("LIBRARY_MEDIA_USD_HD", "").strip().lower() in DISABLED:
486
+ print(f"==> library media {what}: off (LIBRARY_MEDIA_USD_HD) β€” USD tier 1 only")
487
  return set()
488
  size = listed_size(cfg, store, uri)
489
  if size is None:
490
+ print(f"==> library media {what}: none at {uri} β€” USD tier 1 only")
491
  return set()
492
+ if not room_for(tree, size, what):
493
  return set()
494
  allowed: dict[str, set[str]] = {}
495
  for i, block in blocks.values():
496
  allowed.setdefault(i, set()).update(usd_hd_files(block))
497
  t0 = time.time()
498
+ got = stream_with_retry(cfg, store, uri, what, lambda body: stream_hd(body, tree, allowed))
499
  if got is None:
500
  return set()
501
  written, nbytes, skipped = got
502
  keys = {k for k, (i, b) in blocks.items() if landed(tree, i, usd_hd_files(b))}
503
+ print(f"==> library media {what}: {len(keys)} of {len(blocks)} blocks with their full level ({written} files, "
504
  f"{nbytes / 1e6:.0f} MB) from {uri} in {time.time() - t0:.0f} s"
505
  + (f"; {skipped} members not listed skipped" if skipped else ""))
506
  return keys
507
 
508
 
509
+ def served_usd(tree: Path) -> dict[str, dict]:
510
+ """{Space key: usd block} of the served manifest's entries that carry one."""
511
+ assets = json.loads((tree / "manifest.json").read_text()).get("assets") or {}
512
+ return {k: e["usd"] for k, e in assets.items() if isinstance(e, dict) and isinstance(e.get("usd"), dict)}
513
+
514
+
515
+ def usd_adds(cfg: Config, store, uri: str) -> list[tuple[int, str, int]]:
516
+ """The supplementary web USD archives of ``uri``'s stamp (media-<stamp>.usd-add-<n>.tar): [(n, uri, size)] by n."""
517
+ folder, name = uri.rsplit("/", 1)
518
+ pattern = re.compile(re.escape(name[: -len(".tar")]) + USD_ADD)
519
+ found = [(int(m.group(1)), f"{folder}/{rel}", size) for rel, size in store.list_objects(cfg, folder)
520
+ if (m := pattern.fullmatch(rel))]
521
+ return sorted(found)
522
+
523
+
524
+ def fetch_usd_add(cfg: Config, store, n: int, uri: str, size: int, tree: Path) -> int:
525
+ """Apply one add (see the module doc): clear its entries' blocks and ``<id>/usd/`` before it writes, stream its
526
+ tier-1 files and serve the blocks that landed, then its ``.usdhd-add-<n>.tar`` and give back their full level.
527
+ Returns the number of the add's blocks served."""
528
+ what = f"USD add {n}"
529
+ if not room_for(tree, size, what):
530
+ return 0
531
+ manifest = json.loads((tree / "manifest.json").read_text())
532
+ cleared: set[str] = set()
533
+ replaced: list[int] = [0]
534
+
535
+ def clear(blocks: dict[str, tuple[str, dict]]) -> None:
536
+ if cleared: # a restarted stream: cleared already, keep what landed since
537
+ return
538
+ before = served_usd(tree)
539
+ replaced[0] = sum(1 for k in blocks if k in before)
540
+ publish_usd(tree, {k: b for k, b in before.items() if k not in blocks})
541
+ for i, _ in blocks.values():
542
+ shutil.rmtree(tree / i / "usd", ignore_errors=True)
543
+ cleared.add(i)
544
+
545
+ t0 = time.time()
546
+ got = stream_with_retry(cfg, store, uri, what, lambda body: stream_usd(body, tree, manifest, before=clear))
547
+ del manifest
548
+ if got is None:
549
+ return 0
550
+ blocks, left, written, nbytes, skipped = got
551
+ tier1 = {k: usd_without_hd(b) for k, (i, b) in blocks.items() if landed(tree, i, usd_tier1_files(b))}
552
+ rest = {k: b for k, b in served_usd(tree).items() if k not in blocks}
553
+ publish_usd(tree, {**rest, **tier1})
554
+ print(f"==> library media {what}: {len(tier1)} of {len(blocks)} blocks served at tier 1 ({replaced[0]} replacing "
555
+ f"an earlier block; {written} files, {nbytes / 1e6:.0f} MB) from {uri} in {time.time() - t0:.0f} s"
556
+ + (f"; {left} blocks not in this manifest (or malformed) left out" if left else "")
557
+ + (f"; {skipped} members not listed skipped" if skipped else ""))
558
+ full = {k: (i, b) for k, (i, b) in blocks.items() if k in tier1 and usd_hd_files(b)}
559
+ if not full:
560
+ return len(tier1)
561
+ hd_uri = uri[: -len(f".usd-add-{n}.tar")] + USD_HD_ADD.format(n=n)
562
+ try:
563
+ landed_hd = fetch_usd_hd(cfg, store, hd_uri, tree, full, what=f"USD HD add {n}")
564
+ except Exception as exc: # noqa: BLE001 β€” the add's tier 1 is served already; its full level is a bonus
565
+ print(f"==> library media USD HD add {n}: stopped ({type(exc).__name__}: {str(exc)[:300]}) β€” "
566
+ f"its tier 1 stays", file=sys.stderr)
567
+ return len(tier1)
568
+ if landed_hd:
569
+ publish_usd(tree, {**served_usd(tree), **{k: blocks[k][1] for k in landed_hd}})
570
+ return len(tier1)
571
+
572
+
573
+ def fetch_usd_adds(cfg: Config, store, uri: str, tree: Path) -> int:
574
+ """Every add of ``uri``'s stamp, in order of n, under the switches ``fetch_usd`` reads (it already said when they
575
+ are off). A failed add leaves its entries on the GLB; the next one is applied anyway. Blocks served by the adds."""
576
+ if viewer_format(cfg) == "glb" or cfg.get("LIBRARY_MEDIA_USD", "").strip().lower() in DISABLED:
577
+ return 0
578
+ total = 0
579
+ for n, add_uri, size in usd_adds(cfg, store, uri):
580
+ try:
581
+ total += fetch_usd_add(cfg, store, n, add_uri, size, tree)
582
+ except Exception as exc: # noqa: BLE001 β€” one add never stops the next, nor the GLB
583
+ print(f"==> library media USD add {n}: stopped ({type(exc).__name__}: {str(exc)[:300]}) β€” its entries "
584
+ f"stay on the GLB", file=sys.stderr)
585
+ return total
586
+
587
+
588
  def fetch(env: dict[str, str], root: Path = MEDIA_ROOT, store=None) -> int:
589
  """Fetch this corpus's media into ``root/INDEX_KEY``; returns the number of assets installed (0: none).
590
  ``store``: artifact_store's read_text / list_subprefixes / list_objects / download_file / bucket_base."""
 
634
  except Exception as exc: # noqa: BLE001 β€” the GLB tiers are served already; web USD is a bonus
635
  print(f"==> library media USD: stopped ({type(exc).__name__}: {str(exc)[:300]}) β€” the GLB stays",
636
  file=sys.stderr)
637
+ try:
638
+ fetch_usd_adds(cfg, store, uri, root / INDEX_KEY)
639
+ except Exception as exc: # noqa: BLE001 β€” as above: the adds are a bonus on top of whatever is served
640
+ print(f"==> library media USD adds: stopped ({type(exc).__name__}: {str(exc)[:300]})", file=sys.stderr)
641
  return count
642
 
643
 
services/explorer/dist/build-info.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "product": "simready-central-slim-explorer",
3
- "version": "slim-ui-8174ebc0",
4
- "bundle_id": "main.ca1c1a68.js",
5
- "built_at": "2026-10-15T14:40:01Z",
6
  "flags": {"public_mode": true, "email_auth": false, "create_ui": false, "hierarchy_editor": false, "create_search": false, "auth_ui": false, "credentials_ui": false, "index_management": false, "inference_backend": "hub", "vlm_asset_refs": false, "validation_image_max_px": 448, "validation_max_retries": 0, "validation_max_concurrent": 32, "validation_tail_concurrent": 8, "validation_eager_count": 50, "validation_batch_stream": true, "library_idle_prefetch": false, "validation_score_scale": "percent", "parse_gate_fields": true, "parse_fast_path": true, "featured_landing": true, "dependency_views": true, "model_viewer": false, "library_viewer": true, "library_media": "runtime", "spell_correction": false, "downloads": "runtime", "submit_content": "runtime", "third_party_notices": "runtime"}
7
  }
 
1
  {
2
  "product": "simready-central-slim-explorer",
3
+ "version": "slim-ui-f0276569",
4
+ "bundle_id": "main.ca52152d.js",
5
+ "built_at": "2026-10-15T15:28:11Z",
6
  "flags": {"public_mode": true, "email_auth": false, "create_ui": false, "hierarchy_editor": false, "create_search": false, "auth_ui": false, "credentials_ui": false, "index_management": false, "inference_backend": "hub", "vlm_asset_refs": false, "validation_image_max_px": 448, "validation_max_retries": 0, "validation_max_concurrent": 32, "validation_tail_concurrent": 8, "validation_eager_count": 50, "validation_batch_stream": true, "library_idle_prefetch": false, "validation_score_scale": "percent", "parse_gate_fields": true, "parse_fast_path": true, "featured_landing": true, "dependency_views": true, "model_viewer": false, "library_viewer": true, "library_media": "runtime", "spell_correction": false, "downloads": "runtime", "submit_content": "runtime", "third_party_notices": "runtime"}
7
  }
services/explorer/dist/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/ds.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="SimReady Central β€” SimReady asset search"/><meta name="ui-version" content="slim-ui-8174ebc0"><script src="/config.js"></script><title>SimReady Central</title><script defer="defer" src="/static/js/main.ca1c1a68.js"></script><link href="/static/css/main.01671ca7.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
 
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/ds.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="SimReady Central β€” SimReady asset search"/><meta name="ui-version" content="slim-ui-f0276569"><script src="/config.js"></script><title>SimReady Central</title><script defer="defer" src="/static/js/main.ca52152d.js"></script><link href="/static/css/main.01671ca7.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
services/explorer/dist/static/js/main.ca52152d.js ADDED
The diff for this file is too large to render. See raw diff
 
services/explorer/dist/static/js/main.ca52152d.js.LICENSE.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license React
3
+ * react-dom.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ /**
12
+ * @license React
13
+ * react-jsx-runtime.production.min.js
14
+ *
15
+ * Copyright (c) Facebook, Inc. and its affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ /**
22
+ * @license React
23
+ * react.production.min.js
24
+ *
25
+ * Copyright (c) Facebook, Inc. and its affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
30
+
31
+ /**
32
+ * @license React
33
+ * scheduler.production.min.js
34
+ *
35
+ * Copyright (c) Facebook, Inc. and its affiliates.
36
+ *
37
+ * This source code is licensed under the MIT license found in the
38
+ * LICENSE file in the root directory of this source tree.
39
+ */
services/explorer/dist/third-party-notices.txt CHANGED
@@ -1,4 +1,4 @@
1
- Third-party notices β€” SimReady Central Explorer slim-ui-8174ebc0
2
 
3
  The software in this web application's browser bundle includes the packages below, each under its own
4
  license. Each entry gives the package, its version, its license and the license / notice text it ships.
 
1
+ Third-party notices β€” SimReady Central Explorer slim-ui-f0276569
2
 
3
  The software in this web application's browser bundle includes the packages below, each under its own
4
  license. Each entry gives the package, its version, its license and the license / notice text it ships.