Revert asset catalog additions for review
#2
by jkosnik - opened
- README.md +0 -36
- catalog/MAINTENANCE.md +0 -29
- catalog/assets.parquet +0 -3
- scripts/update_asset_catalog.py +0 -201
README.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
pretty_name: NVIDIA SimReady Assets
|
| 3 |
-
tags:
|
| 4 |
-
- 3d
|
| 5 |
-
- simready
|
| 6 |
-
configs:
|
| 7 |
-
- config_name: catalog
|
| 8 |
-
default: true
|
| 9 |
-
data_files:
|
| 10 |
-
- split: assets
|
| 11 |
-
path: catalog/assets.parquet
|
| 12 |
-
dataset_info:
|
| 13 |
-
- config_name: catalog
|
| 14 |
-
features:
|
| 15 |
-
- name: thumbnail
|
| 16 |
-
dtype: image
|
| 17 |
-
- name: name
|
| 18 |
-
dtype: string
|
| 19 |
-
- name: asset_url
|
| 20 |
-
dtype: string
|
| 21 |
-
---
|
| 22 |
-
|
| 23 |
-
# NVIDIA SimReady Assets
|
| 24 |
-
|
| 25 |
-
Browse **1,400 assets** in the thumbnail table on this page. Each row shows the
|
| 26 |
-
asset's existing preview, its package name, and a link to its main USD file.
|
| 27 |
-
|
| 28 |
-
[Open the full asset table](https://huggingface.co/datasets/nvidia/simready-assets/viewer/catalog/assets)
|
| 29 |
-
to search by name and navigate between pages.
|
| 30 |
-
|
| 31 |
-
Asset packages, USD files, materials, textures, and validation reports are available
|
| 32 |
-
in [Files and versions](https://huggingface.co/datasets/nvidia/simready-assets/tree/main).
|
| 33 |
-
Refer to each package's license and metadata for its terms and details.
|
| 34 |
-
|
| 35 |
-
The thumbnail catalog is generated from the asset packages. See
|
| 36 |
-
[catalog maintenance](catalog/MAINTENANCE.md) for refreshing it after asset changes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catalog/MAINTENANCE.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
# Refresh the asset catalog
|
| 2 |
-
|
| 3 |
-
The catalog contains one row per package, using its main USD entrypoint and the
|
| 4 |
-
matching preview in `simready_usd/.thumbs/256x256/`. Images are embedded in the
|
| 5 |
-
catalog as previews up to 256 pixels wide and tall. Source files stay in place.
|
| 6 |
-
|
| 7 |
-
Run the generator after publishing a batch of assets:
|
| 8 |
-
|
| 9 |
-
```bash
|
| 10 |
-
uv run --with huggingface_hub --with pyarrow --with requests --with Pillow scripts/update_asset_catalog.py --output catalog-build --create-pr
|
| 11 |
-
```
|
| 12 |
-
|
| 13 |
-
Authenticate first with `hf auth login`, or provide `HF_TOKEN` through the runner's
|
| 14 |
-
secret environment. The command creates a pull request updating the catalog and
|
| 15 |
-
asset count. Merge that pull request to refresh the dataset page.
|
| 16 |
-
|
| 17 |
-
To preview locally, omit `--create-pr`. The generator checks every package has one
|
| 18 |
-
main USD and a matching readable thumbnail. It stops with an error if a package
|
| 19 |
-
cannot be represented, so assets are never silently omitted.
|
| 20 |
-
|
| 21 |
-
For automatic refreshes, invoke this command as a final step of the existing
|
| 22 |
-
publishing pipeline, or from a webhook runner. Configure the runner to respond to
|
| 23 |
-
asset-package changes on `main`, skip catalog-only changes, and avoid opening
|
| 24 |
-
duplicate refresh pull requests. A schedule or webhook is not installed by this
|
| 25 |
-
change.
|
| 26 |
-
|
| 27 |
-
The dataset card's configuration explicitly selects `catalog/assets.parquet` for
|
| 28 |
-
the viewer. It does not move, rename, or rewrite asset packages. Dataset access
|
| 29 |
-
settings continue to apply.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catalog/assets.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:ee741743ab3b11d0568f1629111d21b562d569232c2682f7b4ed3f3ed483e9d1
|
| 3 |
-
size 76043244
|
|
|
|
|
|
|
|
|
|
|
|
scripts/update_asset_catalog.py
DELETED
|
@@ -1,201 +0,0 @@
|
|
| 1 |
-
"""Build the Hugging Face thumbnail catalog without modifying asset packages.
|
| 2 |
-
|
| 3 |
-
Dependencies: huggingface_hub, pyarrow, requests, Pillow.
|
| 4 |
-
Uses the existing Hugging Face login or HF_TOKEN. Never stores credentials.
|
| 5 |
-
Run after publishing assets; --create-pr proposes changed catalog files on the Hub.
|
| 6 |
-
"""
|
| 7 |
-
from __future__ import annotations
|
| 8 |
-
|
| 9 |
-
import argparse
|
| 10 |
-
from collections import defaultdict
|
| 11 |
-
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 12 |
-
import hashlib
|
| 13 |
-
import io
|
| 14 |
-
import json
|
| 15 |
-
from pathlib import Path, PurePosixPath
|
| 16 |
-
import threading
|
| 17 |
-
from urllib.parse import quote
|
| 18 |
-
|
| 19 |
-
from huggingface_hub import HfApi, CommitOperationAdd, get_token
|
| 20 |
-
import pyarrow as pa
|
| 21 |
-
import pyarrow.parquet as pq
|
| 22 |
-
from PIL import Image
|
| 23 |
-
import requests
|
| 24 |
-
from requests.adapters import HTTPAdapter
|
| 25 |
-
from urllib3.util.retry import Retry
|
| 26 |
-
|
| 27 |
-
REPO = "nvidia/simready-assets"
|
| 28 |
-
LOCAL = threading.local()
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
def session():
|
| 32 |
-
if not hasattr(LOCAL, "session"):
|
| 33 |
-
s = requests.Session()
|
| 34 |
-
token = get_token()
|
| 35 |
-
if token:
|
| 36 |
-
s.headers["Authorization"] = "Bearer " + token
|
| 37 |
-
s.mount("https://", HTTPAdapter(max_retries=Retry(
|
| 38 |
-
total=3, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504])))
|
| 39 |
-
LOCAL.session = s
|
| 40 |
-
return LOCAL.session
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
def discover(paths):
|
| 44 |
-
files = set(paths)
|
| 45 |
-
entrypoints_by_package = defaultdict(list)
|
| 46 |
-
for path in files:
|
| 47 |
-
if path.count("/") == 2 and "/simready_usd/" in path and PurePosixPath(path).suffix.lower() in (".usd", ".usda", ".usdc"):
|
| 48 |
-
entrypoints_by_package[path.split("/")[0]].append(path)
|
| 49 |
-
packages = sorted(p.rsplit("/", 1)[0] for p in files
|
| 50 |
-
if p.count("/") == 1 and p.endswith("/com.nvidia.simready.packaging.json"))
|
| 51 |
-
rows = []
|
| 52 |
-
for package in packages:
|
| 53 |
-
prefix = package + "/simready_usd/"
|
| 54 |
-
entrypoints = sorted(entrypoints_by_package[package])
|
| 55 |
-
if len(entrypoints) != 1:
|
| 56 |
-
raise ValueError(f"Expected one main USD for {package}; found {len(entrypoints)}")
|
| 57 |
-
asset = entrypoints[0]
|
| 58 |
-
thumbnail = prefix + ".thumbs/256x256/" + PurePosixPath(asset).name + ".png"
|
| 59 |
-
if thumbnail not in files:
|
| 60 |
-
raise ValueError(f"Missing asset thumbnail: {thumbnail}")
|
| 61 |
-
rows.append({"name": package, "asset_path": asset, "thumbnail_path": thumbnail})
|
| 62 |
-
if not rows:
|
| 63 |
-
raise ValueError("No asset packages found")
|
| 64 |
-
return rows
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
def fetch_thumbnail(row, repo, revision, cache):
|
| 68 |
-
key = hashlib.sha256((repo + revision + row["thumbnail_path"]).encode()).hexdigest()
|
| 69 |
-
target = cache / (key + ".png")
|
| 70 |
-
if target.exists():
|
| 71 |
-
data = target.read_bytes()
|
| 72 |
-
else:
|
| 73 |
-
url = f"https://huggingface.co/datasets/{repo}/resolve/{revision}/{quote(row['thumbnail_path'], safe='/')}"
|
| 74 |
-
response = session().get(url, timeout=(15, 60))
|
| 75 |
-
response.raise_for_status()
|
| 76 |
-
data = response.content
|
| 77 |
-
target.write_bytes(data)
|
| 78 |
-
with Image.open(io.BytesIO(data)) as image:
|
| 79 |
-
image.verify()
|
| 80 |
-
with Image.open(io.BytesIO(data)) as image:
|
| 81 |
-
image.thumbnail((256, 256), Image.Resampling.LANCZOS)
|
| 82 |
-
preview = io.BytesIO()
|
| 83 |
-
image.save(preview, format="PNG", optimize=True)
|
| 84 |
-
return preview.getvalue()
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
def card_text(repo, count):
|
| 88 |
-
return f"""---
|
| 89 |
-
pretty_name: NVIDIA SimReady Assets
|
| 90 |
-
tags:
|
| 91 |
-
- 3d
|
| 92 |
-
- simready
|
| 93 |
-
configs:
|
| 94 |
-
- config_name: catalog
|
| 95 |
-
default: true
|
| 96 |
-
data_files:
|
| 97 |
-
- split: assets
|
| 98 |
-
path: catalog/assets.parquet
|
| 99 |
-
dataset_info:
|
| 100 |
-
- config_name: catalog
|
| 101 |
-
features:
|
| 102 |
-
- name: thumbnail
|
| 103 |
-
dtype: image
|
| 104 |
-
- name: name
|
| 105 |
-
dtype: string
|
| 106 |
-
- name: asset_url
|
| 107 |
-
dtype: string
|
| 108 |
-
---
|
| 109 |
-
|
| 110 |
-
# NVIDIA SimReady Assets
|
| 111 |
-
|
| 112 |
-
Browse **{count:,} assets** in the thumbnail table on this page. Each row shows the
|
| 113 |
-
asset's existing preview, its package name, and a link to its main USD file.
|
| 114 |
-
|
| 115 |
-
[Open the full asset table](https://huggingface.co/datasets/{repo}/viewer/catalog/assets)
|
| 116 |
-
to search by name and navigate between pages.
|
| 117 |
-
|
| 118 |
-
Asset packages, USD files, materials, textures, and validation reports are available
|
| 119 |
-
in [Files and versions](https://huggingface.co/datasets/{repo}/tree/main).
|
| 120 |
-
Refer to each package's license and metadata for its terms and details.
|
| 121 |
-
|
| 122 |
-
The thumbnail catalog is generated from the asset packages. See
|
| 123 |
-
[catalog maintenance](catalog/MAINTENANCE.md) for refreshing it after asset changes.
|
| 124 |
-
"""
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
def build(args):
|
| 128 |
-
api = HfApi()
|
| 129 |
-
info = api.dataset_info(args.repo, revision=args.revision)
|
| 130 |
-
revision = info.sha
|
| 131 |
-
rows = discover([s.rfilename for s in info.siblings])
|
| 132 |
-
output = Path(args.output).resolve()
|
| 133 |
-
cache = output / ".cache" / "thumbnails"
|
| 134 |
-
cache.mkdir(parents=True, exist_ok=True)
|
| 135 |
-
records = [None] * len(rows)
|
| 136 |
-
print(f"Found {len(rows)} packages at {revision}", flush=True)
|
| 137 |
-
with ThreadPoolExecutor(max_workers=args.workers) as pool:
|
| 138 |
-
futures = {pool.submit(fetch_thumbnail, row, args.repo, revision, cache): i
|
| 139 |
-
for i, row in enumerate(rows)}
|
| 140 |
-
for done, future in enumerate(as_completed(futures), 1):
|
| 141 |
-
i = futures[future]
|
| 142 |
-
row = rows[i]
|
| 143 |
-
records[i] = {
|
| 144 |
-
"thumbnail": {"bytes": future.result(), "path": row["thumbnail_path"]},
|
| 145 |
-
"name": row["name"],
|
| 146 |
-
"asset_url": f"https://huggingface.co/datasets/{args.repo}/blob/main/{quote(row['asset_path'], safe='/')}",
|
| 147 |
-
}
|
| 148 |
-
if done % 100 == 0 or done == len(rows):
|
| 149 |
-
print(f"Validated thumbnails: {done}/{len(rows)}", flush=True)
|
| 150 |
-
schema = pa.schema([
|
| 151 |
-
("thumbnail", pa.struct([("bytes", pa.binary()), ("path", pa.string())])),
|
| 152 |
-
("name", pa.string()), ("asset_url", pa.string()),
|
| 153 |
-
], metadata={b"huggingface": json.dumps({"info": {"features": {
|
| 154 |
-
"thumbnail": {"_type": "Image"},
|
| 155 |
-
"name": {"dtype": "string", "_type": "Value"},
|
| 156 |
-
"asset_url": {"dtype": "string", "_type": "Value"},
|
| 157 |
-
}}}).encode()})
|
| 158 |
-
table = pa.Table.from_pylist(records, schema=schema)
|
| 159 |
-
catalog = output / "catalog" / "assets.parquet"
|
| 160 |
-
catalog.parent.mkdir(parents=True, exist_ok=True)
|
| 161 |
-
pq.write_table(table, catalog, compression="zstd", row_group_size=50, write_page_index=True)
|
| 162 |
-
readback = pq.read_table(catalog)
|
| 163 |
-
assert readback.num_rows == len(rows)
|
| 164 |
-
assert readback.column("name").to_pylist() == [r["name"] for r in rows]
|
| 165 |
-
assert all(r["thumbnail"]["bytes"] for r in readback.to_pylist())
|
| 166 |
-
# Preserve the card on future refreshes; update only its generated count.
|
| 167 |
-
readme = output / "README.md"
|
| 168 |
-
try:
|
| 169 |
-
response = session().get(f"https://huggingface.co/datasets/{args.repo}/resolve/{revision}/README.md", timeout=30)
|
| 170 |
-
if response.status_code == 404:
|
| 171 |
-
text = card_text(args.repo, len(rows))
|
| 172 |
-
else:
|
| 173 |
-
response.raise_for_status()
|
| 174 |
-
import re
|
| 175 |
-
text = response.text
|
| 176 |
-
if "path: catalog/assets.parquet" not in text:
|
| 177 |
-
raise ValueError("Existing README has no catalog configuration; integrate it manually")
|
| 178 |
-
text = re.sub(r"Browse \*\*[\d,]+ assets\*\*", f"Browse **{len(rows):,} assets**", text)
|
| 179 |
-
readme.write_text(text, encoding="utf-8")
|
| 180 |
-
except requests.RequestException:
|
| 181 |
-
raise
|
| 182 |
-
audit = {"repo": args.repo, "revision": revision, "rows": len(rows),
|
| 183 |
-
"parquet_bytes": catalog.stat().st_size, "assets": rows}
|
| 184 |
-
(output / "audit.json").write_text(json.dumps(audit, indent=2), encoding="utf-8")
|
| 185 |
-
print(json.dumps({k: v for k, v in audit.items() if k != "assets"}), flush=True)
|
| 186 |
-
if args.create_pr:
|
| 187 |
-
result = api.create_commit(repo_id=args.repo, repo_type="dataset", parent_commit=revision,
|
| 188 |
-
operations=[CommitOperationAdd(path_in_repo="catalog/assets.parquet", path_or_fileobj=str(catalog)),
|
| 189 |
-
CommitOperationAdd(path_in_repo="README.md", path_or_fileobj=str(readme))],
|
| 190 |
-
commit_message="Refresh asset thumbnail catalog", create_pr=True)
|
| 191 |
-
print(result.pr_url)
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
if __name__ == "__main__":
|
| 195 |
-
p = argparse.ArgumentParser(description=__doc__)
|
| 196 |
-
p.add_argument("--repo", default=REPO)
|
| 197 |
-
p.add_argument("--revision", default="main")
|
| 198 |
-
p.add_argument("--output", default="catalog-build")
|
| 199 |
-
p.add_argument("--workers", type=int, default=8)
|
| 200 |
-
p.add_argument("--create-pr", action="store_true")
|
| 201 |
-
build(p.parse_args())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|