Download usd_models/scripts/usd_cleaner/Readme.md from SberRoboticsCenter/GreenChallengeAssets: direct link, hf CLI and curl.
- Browser
- Download file 4.98 kB
-
https://huggingface.co/datasets/SberRoboticsCenter/GreenChallengeAssets/resolve/main/usd_models/scripts/usd_cleaner/Readme.md
- Command line
-
hf download hf://datasets/SberRoboticsCenter/GreenChallengeAssets/usd_models/scripts/usd_cleaner/Readme.md
-
curl -L -o Readme.md https://huggingface.co/datasets/SberRoboticsCenter/GreenChallengeAssets/resolve/main/usd_models/scripts/usd_cleaner/Readme.md
USD models cleaner
Finds the USD models under assets/usd_models that no scene actually uses, and
deletes them. Pure standard library β no Isaac Sim, no pxr, no pip installs.
Two scripts, run in order:
| File | What it does |
|---|---|
usd_models_cleaner.py |
Seeds from assets/scenes/*.json, follows references inside the USD files transitively, writes the list to JSON. Read-only. |
usd_models_delete.py |
Takes that JSON and deletes the listed files, then removes folders left without any USD. Destructive. |
Both resolve paths against the repo root, so they work from any directory.
1. Build the list
python3 scripts/usd_cleaner/usd_models_cleaner.py --unused
Writes unused_usds.json next to the script β every USD file under
assets/usd_models that no scene references. That is the delete list.
Without --unused it writes used_usds.json instead: the models that are
referenced. Useful as a sanity check.
| Flag | Effect |
|---|---|
--unused |
Invert: list what is NOT reachable (the delete list) |
--aggressive |
Drop the sibling-directory guard (riskier, deletes more) |
--no_follow |
Scene JSONs only β unsafe, reproduces the old broken behaviour |
--out PATH |
Write somewhere else (a bare name lands in this folder) |
--no_out |
Print only, write no file |
--verbose |
Annotate each path with the scenes referencing it |
--scenes_dir / --models_dir |
Point at different directories |
2. Preview
python3 scripts/usd_cleaner/usd_models_delete.py unused_usds.json --dry-run
Prints every file and folder that would go, plus the total freed. Touches nothing. Always run this first.
3. Delete
python3 scripts/usd_cleaner/usd_models_delete.py unused_usds.json
Prints a summary and asks [y/N] before removing anything.
| Flag | Effect |
|---|---|
--dry-run |
Preview only |
--yes |
Skip the confirmation prompt |
--keep_empty_dirs |
Delete the files but leave USD-less folders in place |
--models_dir |
Confine deletion to a different directory |
Rules it follows
- Folder removal. A folder is removed only if it held a USD file and now
holds none. A folder that never held one β
textures/,material/β belongs to its parent model and is left alone, so surviving models keep their assets. - Protected folders.
.git,.svn,.hg,__pycache__and any dotted folder are never swept. Without this the "no USD inside" rule would deleteassets/usd_models/.gitwholesale. - Containment. Deletion cannot leave
--models_dir. A../in the list aborts the run instead of escaping. - Only
.usd,.usda,.usdc,.usdzcount as models. A.pngor a backup file whose name contains.usdis not a model and is not counted.
How references are followed
A scene names a wrapper; the geometry and joints usually live elsewhere. The cleaner therefore starts at the scene paths and walks outward:
.usdatext β parsed for@asset/path@(and the@@@path@@@form), resolved relative to the file holding the reference. Reliable..usdcbinary β the token table is compressed, so printable strings are mined and kept only when they resolve to a file that exists. Best-effort.- Companion folder β
X.usdbeside a folderX/pulls in that whole folder. This is the convention these assets use and it is what catches what the binary scan misses. - Sibling directories β a reachable binary USD also protects the
directories next to it, since its real references are unreadable.
kitchen_background.usdkeepslocalized/this way.--aggressiveturns this off.
Every step is repeated transitively until nothing new is reached.
Why this matters
An earlier version scanned scene JSONs only. It deleted
model_dishwasher_v2/resource/v_0/link_default_0.usda β never named by any
scene, but the file holding the dishwasher's articulation. Isaac Sim then failed
with:
RuntimeError: Failed to find an articulation when resolving
'/World/envs/env_0/model_dishwasher'
--no_follow reproduces that behaviour for comparison. Do not delete with it.
Before you delete
The binary side is a heuristic, not a parser. Only pxr (via
/isaac-sim/python.sh) can resolve .usdc references with certainty. Treat the
list as a strong suggestion, not proof.
Scene JSONs may also not be the only referrer β task configs or code can name a model directly.
assets/usd_models is a git repo, which is the real safety net: after deleting,
git status shows every removal and git reset --hard HEAD restores them.
Load a scene before committing the deletions.
Current numbers
158 paths declared by scenes expand to 264 reachable USD files; 652 are unreachable. Scene-JSON-only scanning would have kept just 158 and deleted 729 β the 106-file difference is what broke the dishwasher.