nspasojevic commited on
Commit
0de6afd
Β·
verified Β·
1 Parent(s): d14edb4

UI main.f3a49a85.js (Central main 14ff836d), HD library media loader, restore skips library-media/

Browse files
licenses/extras-usd-search-explorer-ui-bundle-javascript-dependencies.txt CHANGED
@@ -1,4 +1,4 @@
1
- Third-party notices β€” SimReady Central Explorer slim-30948535
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-8c93f7a5
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.
pipeline/artifact_store.py CHANGED
@@ -179,6 +179,22 @@ def read_text(cfg: Config, uri: str) -> Optional[str]:
179
  return with_retry(attempt, what=f"read of {uri}")
180
 
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  def download_file(cfg: Config, uri: str, dest: Path) -> bool:
183
  """Download one object to `dest`. False if it doesn't exist."""
184
  bucket, key = split_uri(uri)
@@ -216,16 +232,17 @@ def list_subprefixes(cfg: Config, uri: str) -> List[str]:
216
  return names
217
 
218
 
219
- def download_prefix(cfg: Config, uri: str, dest: Path) -> int:
220
  """Download everything under `uri/` into `dest`, keeping relative paths β€”
221
  the `aws s3 sync <uri>/ <dest>` replacement. Files already present with
222
  the same size are skipped, so a retried or resumed download doesn't
223
- start over. Returns the number of objects under the prefix."""
 
224
  bucket, key = split_uri(uri)
225
  prefix = _prefix(key)
226
 
227
  def attempt() -> int:
228
- objects = list_objects(cfg, uri)
229
  todo = [rel for rel, size in objects if not ((dest / rel).is_file() and (dest / rel).stat().st_size == size)]
230
  with _transfer_manager(s3_client(cfg)) as manager:
231
  futures = []
 
179
  return with_retry(attempt, what=f"read of {uri}")
180
 
181
 
182
+ def open_stream(cfg: Config, uri: str):
183
+ """The object's body as a stream (read once, in order), or None if it doesn't exist. Opening is retried like
184
+ read_text; a stream that breaks mid-read is the caller's to start again."""
185
+ bucket, key = split_uri(uri)
186
+
187
+ def attempt():
188
+ try:
189
+ return s3_client(cfg).get_object(Bucket=bucket, Key=key)["Body"]
190
+ except ClientError as exc:
191
+ if _is_missing(exc):
192
+ return None
193
+ raise
194
+
195
+ return with_retry(attempt, what=f"stream of {uri}")
196
+
197
+
198
  def download_file(cfg: Config, uri: str, dest: Path) -> bool:
199
  """Download one object to `dest`. False if it doesn't exist."""
200
  bucket, key = split_uri(uri)
 
232
  return names
233
 
234
 
235
+ def download_prefix(cfg: Config, uri: str, dest: Path, skip: tuple = ()) -> int:
236
  """Download everything under `uri/` into `dest`, keeping relative paths β€”
237
  the `aws s3 sync <uri>/ <dest>` replacement. Files already present with
238
  the same size are skipped, so a retried or resumed download doesn't
239
+ start over; so is every object whose relative path starts with one of
240
+ `skip`. Returns the number of objects under the prefix."""
241
  bucket, key = split_uri(uri)
242
  prefix = _prefix(key)
243
 
244
  def attempt() -> int:
245
+ objects = [(rel, size) for rel, size in list_objects(cfg, uri) if not rel.startswith(skip)]
246
  todo = [rel for rel, size in objects if not ((dest / rel).is_file() and (dest / rel).stat().st_size == size)]
247
  with _transfer_manager(s3_client(cfg)) as manager:
248
  futures = []
pipeline/library_media.py CHANGED
@@ -23,6 +23,13 @@ serves it at /library_media/ (docker/hf-space/nginx.conf.template), where the Ex
23
  Nothing here is needed to search. Any failure β€” no archive, no bucket credentials, a network error, an unsafe or
24
  malformed archive β€” leaves the previous tree (none at boot): nginx answers 404 and the Explorer shows no media.
25
  LIBRARY_MEDIA=off disables the fetch.
 
 
 
 
 
 
 
26
  """
27
 
28
  from __future__ import annotations
@@ -45,6 +52,14 @@ ARCHIVE = re.compile(r"^media-\d{8}T\d{4}Z\.tar$") # media-20261005T1010Z.tar:
45
  INDEX_KEY = "usdsearch-dev"
46
  MEDIA_ROOT = BUILD_DIR / "library_media"
47
  DISABLED = {"off", "none", "false", "0"}
 
 
 
 
 
 
 
 
48
 
49
 
50
  def run_prefix(cfg: Config, store, corpus: str) -> str:
@@ -106,6 +121,106 @@ def install(src: Path, dest: Path) -> None:
106
  shutil.rmtree(old, ignore_errors=True)
107
 
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  def fetch(env: dict[str, str], root: Path = MEDIA_ROOT, store=None) -> int:
110
  """Fetch this corpus's media into ``root/INDEX_KEY``; returns the number of assets installed (0: none).
111
  ``store``: artifact_store's read_text / list_subprefixes / list_objects / download_file / bucket_base."""
@@ -143,6 +258,10 @@ def fetch(env: dict[str, str], root: Path = MEDIA_ROOT, store=None) -> int:
143
  shutil.rmtree(tmp, ignore_errors=True)
144
  size = sum(p.stat().st_size for p in (root / INDEX_KEY).rglob("*") if p.is_file())
145
  print(f"==> library media: {count} assets from {uri} ({size / 1e6:.0f} MB) in {time.time() - t0:.0f} s")
 
 
 
 
146
  return count
147
 
148
 
 
23
  Nothing here is needed to search. Any failure β€” no archive, no bucket credentials, a network error, an unsafe or
24
  malformed archive β€” leaves the previous tree (none at boot): nginx answers 404 and the Explorer shows no media.
25
  LIBRARY_MEDIA=off disables the fetch.
26
+
27
+ The HD tiers (2026-10-09: tier-2 model_hd.glb, a spin's HD frames, an RTX clip's HD file) are too big for that
28
+ boot-time download (about 16 GB of tier-2 models alone, against about 7 GB for everything else), so they travel in
29
+ a sibling archive of the same stamp, ``media-<stamp>.hd.tar``, which ARCHIVE never matches. Once the tree above is
30
+ installed and served, it is STREAMED in (no copy of the archive on disk): each member the manifest lists lands
31
+ under ``<id>/<file>`` through a temporary file, anything else is skipped. Until a file lands the Explorer reads a
32
+ 404 and stays on tier 1, quietly; a failure leaves what landed.
33
  """
34
 
35
  from __future__ import annotations
 
52
  INDEX_KEY = "usdsearch-dev"
53
  MEDIA_ROOT = BUILD_DIR / "library_media"
54
  DISABLED = {"off", "none", "false", "0"}
55
+ # The HD tiers (tier-2 model_hd.glb, a spin's HD frames, an RTX clip's HD file) travel in a sibling archive of the
56
+ # same stamp, media-<stamp>.hd.tar (ARCHIVE never matches it), streamed into the installed tree AFTER it is served:
57
+ # the Explorer reads them only after the tier-1 picture or model, and quietly stays on tier 1 until a file lands.
58
+ HD_SUFFIX = ".hd.tar"
59
+ SAFE_ID = re.compile(r"^[A-Za-z0-9_-]{1,64}$")
60
+ SAFE_NAME = re.compile(r"^[A-Za-z0-9_-][A-Za-z0-9._-]{0,127}$")
61
+ HD_TRIES = 2
62
+ HD_DISK_MARGIN = 8 * 10**9 # free disk the HD stream always leaves (the index, Neo4j and logs keep writing)
63
 
64
 
65
  def run_prefix(cfg: Config, store, corpus: str) -> str:
 
121
  shutil.rmtree(old, ignore_errors=True)
122
 
123
 
124
+ def hd_files(manifest: dict) -> dict[str, set[str]]:
125
+ """{entry id: file names} of the HD tiers the manifest lists: an entry's ``hd`` files (model_hd.glb), its spin's
126
+ HD frames (``spin.hd``: ``spin_hd_{k:03d}.webp`` for every k below ``spin.frames``) and its RTX clip's HD files
127
+ (``rtxclip.hd``). The only members an HD archive may write."""
128
+ out: dict[str, set[str]] = {}
129
+ for e in (manifest.get("assets") or {}).values():
130
+ if not isinstance(e, dict) or not isinstance(e.get("id"), str) or not SAFE_ID.match(e["id"]):
131
+ continue
132
+ names: set[str] = set()
133
+ hd = e.get("hd") if isinstance(e.get("hd"), dict) else {}
134
+ names |= {n for n in (hd.get("files") or {}).values() if isinstance(n, str)}
135
+ spin = e.get("spin") if isinstance(e.get("spin"), dict) else {}
136
+ spin_hd = spin.get("hd") if isinstance(spin.get("hd"), dict) else {}
137
+ frames = spin.get("frames")
138
+ if (spin_hd.get("files") or {}).get("pattern") == "spin_hd_{k:03d}.webp" and isinstance(frames, int):
139
+ names |= {f"spin_hd_{k:03d}.webp" for k in range(min(frames, 360))}
140
+ clip = e.get("rtxclip") or e.get("rtx_clip") or (e.get("clip") or {}).get("rtx") or {}
141
+ clip_hd = clip.get("hd") if isinstance(clip, dict) and isinstance(clip.get("hd"), dict) else {}
142
+ names |= {n for n in (clip_hd.get("files") or {}).values() if isinstance(n, str)}
143
+ names = {n for n in names if SAFE_NAME.match(n)}
144
+ if names:
145
+ out[e["id"]] = names
146
+ return out
147
+
148
+
149
+ def stream_hd(body, tree: Path, allowed: dict[str, set[str]]) -> tuple[int, int, int]:
150
+ """Write the HD archive ``body`` (a stream, read once in order) into ``tree``: each member the manifest lists
151
+ (``allowed``) lands under ``<id>/<file>`` through a temporary file, so nginx never serves half of one; a file
152
+ already there at the member's size is kept (a retried stream). Anything else is skipped. (written, bytes,
153
+ skipped)."""
154
+ written = size = skipped = 0
155
+ with tarfile.open(fileobj=body, mode="r|") as tf:
156
+ for m in tf:
157
+ if m.isdir():
158
+ continue
159
+ parts = m.name.removeprefix("./").split("/")
160
+ if not m.isfile() or len(parts) != 2 or parts[1] not in allowed.get(parts[0], ()):
161
+ skipped += 1
162
+ continue
163
+ target = tree / parts[0] / parts[1]
164
+ if target.is_file() and target.stat().st_size == m.size:
165
+ continue
166
+ target.parent.mkdir(parents=True, exist_ok=True)
167
+ part = target.with_name(f".{target.name}.part")
168
+ try:
169
+ with tf.extractfile(m) as src, open(part, "wb") as out:
170
+ shutil.copyfileobj(src, out, 1 << 20)
171
+ if part.stat().st_size != m.size:
172
+ raise ValueError(f"{m.name}: {part.stat().st_size} of {m.size} bytes")
173
+ except BaseException:
174
+ part.unlink(missing_ok=True)
175
+ raise
176
+ os.replace(part, target)
177
+ written += 1
178
+ size += m.size
179
+ return written, size, skipped
180
+
181
+
182
+ def fetch_hd(cfg: Config, store, uri: str, tree: Path) -> int:
183
+ """Stream ``uri``'s HD sibling (media-<stamp>.hd.tar) into the installed ``tree``; returns the files written.
184
+ No sibling, or a manifest that lists no HD tier: nothing. A broken stream is started again once (files already
185
+ complete are kept); a failure leaves what landed β€” the Explorer stays on tier 1 for the rest."""
186
+ hd_uri = uri[: -len(".tar")] + HD_SUFFIX
187
+ if cfg.get("LIBRARY_MEDIA_HD", "").strip().lower() in DISABLED:
188
+ print("==> library media HD: off (LIBRARY_MEDIA_HD)")
189
+ return 0
190
+ allowed = hd_files(json.loads((tree / "manifest.json").read_text()))
191
+ if not allowed:
192
+ return 0
193
+ folder, name = hd_uri.rsplit("/", 1)
194
+ size = next((n for rel, n in store.list_objects(cfg, folder) if rel == name), None)
195
+ if size is None:
196
+ print(f"==> library media HD: none at {hd_uri}")
197
+ return 0
198
+ free = shutil.disk_usage(tree).free
199
+ if size + HD_DISK_MARGIN > free:
200
+ # never fill the disk OpenSearch and Neo4j write to: a smaller Space keeps tier 1
201
+ print(f"==> library media HD: {size / 1e9:.1f} GB would leave under {HD_DISK_MARGIN / 1e9:.0f} GB of "
202
+ f"{free / 1e9:.1f} GB free β€” not fetched")
203
+ return 0
204
+ t0 = time.time()
205
+ total = [0, 0, 0]
206
+ for attempt in range(HD_TRIES):
207
+ body = store.open_stream(cfg, hd_uri)
208
+ if body is None:
209
+ print(f"==> library media HD: none at {hd_uri}")
210
+ return 0
211
+ try:
212
+ written, size, skipped = stream_hd(body, tree, allowed)
213
+ total = [total[0] + written, total[1] + size, skipped]
214
+ break
215
+ except (OSError, ValueError, tarfile.TarError) as exc:
216
+ if attempt == HD_TRIES - 1:
217
+ raise
218
+ print(f"==> library media HD: stream broke ({type(exc).__name__}: {str(exc)[:200]}), starting again")
219
+ print(f"==> library media HD: {total[0]} files ({total[1] / 1e6:.0f} MB) from {hd_uri} in {time.time() - t0:.0f} s"
220
+ + (f"; {total[2]} members not in the manifest skipped" if total[2] else ""))
221
+ return total[0]
222
+
223
+
224
  def fetch(env: dict[str, str], root: Path = MEDIA_ROOT, store=None) -> int:
225
  """Fetch this corpus's media into ``root/INDEX_KEY``; returns the number of assets installed (0: none).
226
  ``store``: artifact_store's read_text / list_subprefixes / list_objects / download_file / bucket_base."""
 
258
  shutil.rmtree(tmp, ignore_errors=True)
259
  size = sum(p.stat().st_size for p in (root / INDEX_KEY).rglob("*") if p.is_file())
260
  print(f"==> library media: {count} assets from {uri} ({size / 1e6:.0f} MB) in {time.time() - t0:.0f} s")
261
+ try:
262
+ fetch_hd(cfg, store, uri, root / INDEX_KEY)
263
+ except Exception as exc: # noqa: BLE001 β€” the tier-1 tree is served already; HD is a bonus
264
+ print(f"==> library media HD: stopped ({type(exc).__name__}: {str(exc)[:300]}) β€” tier 1 stays", file=sys.stderr)
265
  return count
266
 
267
 
pipeline/restore.py CHANGED
@@ -63,6 +63,11 @@ def resolve_baseline_prefix(cfg: Config) -> Optional[str]:
63
  return json.loads(pointer)["prefix"]
64
 
65
 
 
 
 
 
 
66
  def download(cfg: Config, prefix: str, dest: Path = RESTORE_DIR) -> None:
67
  # dest is overridable so two independent restores (e.g. the HF Space's
68
  # OpenSearch and Neo4j restores, run by separate supervisord programs β€”
@@ -72,8 +77,8 @@ def download(cfg: Config, prefix: str, dest: Path = RESTORE_DIR) -> None:
72
  if dest.exists():
73
  shutil.rmtree(dest)
74
  dest.mkdir(parents=True)
75
- print(f" downloading {prefix}/ -> {dest}")
76
- download_prefix(cfg, prefix, dest)
77
 
78
 
79
  def bulk_load(opensearch_url: str, index: str, data_path: Path, chunk_docs: int) -> int:
 
63
  return json.loads(pointer)["prefix"]
64
 
65
 
66
+ # What a restore never downloads: the run's library media archives (2026-10-09: ~48 GB in all, and every start
67
+ # downloaded them, twice: the OpenSearch and the Neo4j restores). pipeline/library_media.py fetches the one it
68
+ # installs itself; nothing reads them from a restore dir.
69
+ RESTORE_SKIP = ("library-media/",)
70
+
71
  def download(cfg: Config, prefix: str, dest: Path = RESTORE_DIR) -> None:
72
  # dest is overridable so two independent restores (e.g. the HF Space's
73
  # OpenSearch and Neo4j restores, run by separate supervisord programs β€”
 
77
  if dest.exists():
78
  shutil.rmtree(dest)
79
  dest.mkdir(parents=True)
80
+ print(f" downloading {prefix}/ -> {dest} (without {', '.join(RESTORE_SKIP)})")
81
+ download_prefix(cfg, prefix, dest, skip=RESTORE_SKIP)
82
 
83
 
84
  def bulk_load(opensearch_url: str, index: str, data_path: Path, chunk_docs: int) -> int:
services/explorer/dist/build-info.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "product": "simready-central-slim-explorer",
3
- "version": "slim-30948535",
4
- "bundle_id": "main.955ad1da.js",
5
- "built_at": "2026-10-09T16:59:49Z",
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, "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-8c93f7a5",
4
+ "bundle_id": "main.f3a49a85.js",
5
+ "built_at": "2026-10-09T20:04:00Z",
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, "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-30948535"><script src="/config.js"></script><title>SimReady Central</title><script defer="defer" src="/static/js/main.955ad1da.js"></script><link href="/static/css/main.1d1f5271.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-8c93f7a5"><script src="/config.js"></script><title>SimReady Central</title><script defer="defer" src="/static/js/main.f3a49a85.js"></script><link href="/static/css/main.1d1f5271.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.955ad1da.js β†’ main.f3a49a85.js} RENAMED
The diff for this file is too large to render. See raw diff
 
services/explorer/dist/static/js/{main.955ad1da.js.LICENSE.txt β†’ main.f3a49a85.js.LICENSE.txt} RENAMED
File without changes
services/explorer/dist/third-party-notices.txt CHANGED
@@ -1,4 +1,4 @@
1
- Third-party notices β€” SimReady Central Explorer slim-30948535
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-8c93f7a5
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.