usd_chunks.chunk_registry
The ChunkRegistry singleton, which finds, loads and unloads chunk modules.
The USD_CHUNK_DIRS environment variable tells the registry where to scan for chunk modules (.py files), nested folders included. The registry also holds the scene, which is how running code finds a chunk by name:
ChunkDependencyManager
⚓︎
Installs and tracks the pip packages chunk modules declare as requirements.
Packages go into USD_CHUNK_DEPENDENCY_DIR, which is added to sys.path. Nothing is installed without the scene's say-so; see USD_CHUNK_AUTO_INSTALL.
initialize
⚓︎
Put the dependency directory on sys.path and in PYTHONPATH for subprocesses.
Source code in usd_chunks/chunk_registry.py
install
⚓︎
pip-install packages into the dependency dir, now, without asking; whether pip succeeded.
The scene runs pip (ChunkScene.run_install) so it can show progress; the bookkeeping after it stays here, on the calling thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
Requirement strings. |
required | |
chunk_name
|
str
|
The chunk that needs them, for the progress display. |
''
|
Source code in usd_chunks/chunk_registry.py
install_later
⚓︎
Whether the scene installs packages in the background; False with no scene.
Source code in usd_chunks/chunk_registry.py
install_packages
⚓︎
Install whichever of these requirements are not already satisfied.
The scene is asked once for all of them (should_install_packages), naming the chunk that needs them; nothing is installed without its yes. With USD_CHUNK_AUTO_INSTALL set falsey, or a scene that cannot ask, the missing packages are named in a warning instead. With it set truthy, a scene that installs in the background (install_later) takes them over, and they count as missing until it has. Only what pip actually installed is cached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requirements
|
Requirement strings, ranges allowed. |
required | |
chunk_name
|
str
|
The chunk module that declares them, for the question and the warning. |
''
|
Returns:
| Type | Description |
|---|---|
list[str]
|
The requirements still not installed afterwards -- declined, failed, or never |
list[str]
|
asked. Empty when the manager is not initialized, since it cannot tell. |
Source code in usd_chunks/chunk_registry.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | |
package_in_cache
⚓︎
Whether package -- a requirement, range and all -- is satisfied by the cache.
Reads the ranges chunks declare ("numpy>=2,<3"), not only "==". package_info splits
on "==" alone, so a ranged requirement would come back with the whole string as its
name, which no cache entry is ever keyed by -- every chunk declaring a range would
miss the cache on every load, costing two pip list subprocesses each time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
A requirement string. |
required |
Returns:
| Type | Description |
|---|---|
|
True if a cached version satisfies it. |
Source code in usd_chunks/chunk_registry.py
package_info
staticmethod
⚓︎
Split an "==" requirement into (name, version); version is None without "==".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
A requirement string such as "numpy==2.1.0". |
required |
Returns:
| Type | Description |
|---|---|
|
(name, version). |
Source code in usd_chunks/chunk_registry.py
should_install_packages
⚓︎
Whether the scene allows installing packages for chunk_name; False with no scene.
Source code in usd_chunks/chunk_registry.py
target_dir
⚓︎
Where install() puts packages -- for telling the user, before initialize() too.
Source code in usd_chunks/chunk_registry.py
update_cache
⚓︎
Record every installed package: what Python can import, then pip list on top.
Source code in usd_chunks/chunk_registry.py
ChunkEnvVar
⚓︎
Bases: Generic[_T]
An environment variable the chunk system reads, with a typed default.
A list-typed variable is split on os.pathsep, and its entries come before the defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The environment variable's name. |
required |
default
|
_T
|
The value when the variable is unset or empty. |
required |
relpath
|
Resolve a string or list default relative to the repository root. |
False
|
Source code in usd_chunks/chunk_registry.py
__call__
⚓︎
The variable's current value.
A list variable returns the environment's entries first, then the defaults, keeping the first of any duplicate: env-provided dirs take precedence on duplicate module names, since the first one registered wins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fallback
|
_T | None
|
Used in place of the environment value when the variable is unset. |
None
|
*args
|
Any
|
Ignored. |
()
|
**kwds
|
Any
|
Ignored. |
{}
|
Returns:
| Type | Description |
|---|---|
|
The value, or the default when the variable is unset or empty. |
Source code in usd_chunks/chunk_registry.py
ChunkLayerManager
⚓︎
A singleton that creates, tracks and removes the layers chunks author into.
Every chunk is associated with a layer onto which the edits of its parameters are applied. The layers are created and deleted along with the chunks.
Attributes:
| Name | Type | Description |
|---|---|---|
chunk_layers |
dict[ChunkHash, Layer]
|
Maps each chunk to its layer |
scene |
SceneSender
|
A handle to the scene for stage access |
add_arc_layer
⚓︎
Hold layer as the one c made for an asset to payload or reference, or drop c's.
A Layer chunk set not to sublayer makes a layer nothing in the stage points at yet: held here it stays alive, and arc_layers lists it for an Edit Target to author into and a Payload or Reference chunk to bring in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
ChunkBase
|
The chunk that made the layer. |
required |
layer
|
Layer | None
|
The layer, or None to drop the one c made. |
required |
Source code in usd_chunks/chunk_registry.py
add_layer
⚓︎
Add a layer to the stage and add a mapping from chunk c to the new layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_layer
|
Layer
|
The target layer onto which we append the new layer |
required |
c
|
ChunkUsdLayerSupport
|
The chunk that can modify the new layer. The new layer's identifier will be created from the chunks get_layer_identifier() |
required |
index
|
int
|
Where in target_layer's subLayerPaths to insert the new layer |
0
|
Returns:
| Type | Description |
|---|---|
Layer
|
Sdf.Layer: A new layer |
Source code in usd_chunks/chunk_registry.py
add_outside_layer
⚓︎
Record layer as one c sublayered into parent itself, outside its own layer -- or forget c's.
A Layer chunk placed below a file the target lists has its layer there, not in its own layer, so deleting the chunk does not take it with it: this manager takes it out of parent when it takes c's own layer away.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
ChunkBase
|
The chunk that placed the layer. |
required |
layer
|
Layer | None
|
The layer, or None to forget the one c placed. |
required |
parent
|
Layer | None
|
The layer it is a sublayer of. |
None
|
Source code in usd_chunks/chunk_registry.py
arc_layers
⚓︎
(display name, layer) for every layer a chunk made to be brought in by arc.
batched_placement
⚓︎
Collect graph-layer sublayer edits made inside, and write each list once at the end.
Only graph layers are batched, those there already and those made meanwhile: they are this manager's own and hold no layer offsets, which a whole-list write would not keep. The layers they sit under are edited as before.
Source code in usd_chunks/chunk_registry.py
clear_layer
⚓︎
Clear a layer's contents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str | ChunkBase
|
The layer identifier, or the chunk whose layer to clear |
required |
Source code in usd_chunks/chunk_registry.py
cook_layer_for
⚓︎
The layer cooks of chunks defined in home nest under: home's cook sublayer.
layout.usda lists layout.cook.usda (chunk_layers.find_cook_sublayer), so the cook sits just under the layer that defines it: stronger layers -- lighting's, authored or cooked -- beat it, and so do home's own hand edits. The graph layers go under it in memory; neither file is written, so both may be locked.
Opt-in by the link: a home listing none is never given one here, since that would dirty a file merely by opening it -- its chunks cook into the session layer as before. Whoever owns the file adds the link (chunk_layers.add_cook_sublayer).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
home
|
Layer
|
A file layer that defines chunks. |
required |
Returns:
| Type | Description |
|---|---|
Layer | None
|
The cook layer, internal to the chunk system (is_chunk_internal_layer), or None |
Layer | None
|
when home lists none. |
Source code in usd_chunks/chunk_registry.py
deactivate_stale_bakes
⚓︎
Hide the prims an asset's published bake makes that this stage's live cooks don't.
A shot cooks an asset's chunks into its own cook layer and never touches the asset,
so the bake the asset was published with still composes underneath -- with every prim
that network made then. A prim the live cook no longer makes would linger. So for
each copy of an asset whose chunks have all cooked live here, every prim that only
the asset's bake defines gets an over with active = false, the topmost one of a
subtree only, in a layer under this stage's cook layer. It is written into the shot's
bake with the rest (save_cook_layers), so a consumer without usd_chunks sees the same.
A copy whose chunks have not all cooked -- disabled, blocked outside the active view, never cooked -- keeps its bake whole: hiding it would leave the bare asset.
Incremental, for large assets. A copy that turns live is walked once in full. After that only the bake subtrees at paths whose definition changed (_after_cook) are walked again, and only the overs that change are written, so a prim that stays hidden is never recomposed.
Source code in usd_chunks/chunk_registry.py
3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 | |
defer_new
⚓︎
Leave a chunk with no layer yet without one until placement, while deferring.
A new chunk asks for its layer as it is added, only to clear it -- and a layer made then went on the stage at once, in the loading layer: an edit that recomposes the whole layer stack, per chunk. Made at placement instead, with all the others, it goes straight into its graph layer, written once.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if c waits for placement; False when not deferring, or c has a layer. |
Source code in usd_chunks/chunk_registry.py
defer_placement
⚓︎
Hold chunk layers made from now on in one loading layer, until the graph is wired.
A load restores each chunk's inputs before it restores the wiring between chunks, and restoring an input asks for the chunk's layer. Placed then, every chunk looks like a graph of its own: it got a graph layer of its own on the stage, and the wiring moved it into the shared one a moment later and threw that graph layer away. Each of those sublayer edits recomposes the stage -- a fifth of opening a 70-chunk network.
The held layers stay on the stage, in one loading layer, so a held layer behaves as a placed one does. Off the stage it would not: Usd.EditContext raises for a layer outside the stage's layer stack, and chunk_notice declines to cook a chunk whose layer is not in it yet. A first version kept them off the stage, and that skipped a cook the load used to run -- the same outcome, reached by accident, that a vector's premature cook no longer has in the first place (see _set_children_blocked).
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if this call turned deferral on. Only that caller calls |
bool
|
place_deferred_layers; a nested caller gets False and leaves it to the outer one. |
Source code in usd_chunks/chunk_registry.py
end_deferral
⚓︎
Stop deferring, and return the chunks whose layer is still waiting to be placed.
The loading layer comes off the stage, so the returned chunks' layers are off it until they are placed. The caller places them, in the order it wants: the order layers go onto a graph layer breaks ties between chunks at the same depth, and a load keeps the order it had before placement was deferred.
Source code in usd_chunks/chunk_registry.py
follow_merged_graphs
⚓︎
Move each chunk's layer into its graph's layer when a wire merged its graph into another.
A layer moves on its chunk's next get_or_create_layer, which a cook asks for. The chunk above a new wire doesn't cook again, so ranking calls this first, or that chunk's layer stays in its old graph layer where the ranking can't place it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
Iterable[ChunkCommon]
|
The chunks about to be ranked. |
required |
Source code in usd_chunks/chunk_registry.py
get_chunk_target
⚓︎
The real layer this chunk's content last resolved against.
That is the session layer by default, or an Edit-Target-chosen layer, as tracked by get_or_create_layer. Export tooling uses it to group a chunk's own bookkeeping prim (always in the session layer) with whichever real layer its driven content nests in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
ChunkHash
|
The chunk. |
required |
Returns:
| Type | Description |
|---|---|
Layer | None
|
The layer, or None if the chunk has none yet. |
Source code in usd_chunks/chunk_registry.py
get_layer
⚓︎
Get the layer associated with a chunk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
ChunkHash
|
The chunk whose layer to get |
required |
Returns:
| Type | Description |
|---|---|
Layer | None
|
Sdf.Layer | None: The chunk's layer, or None if it has none |
Source code in usd_chunks/chunk_registry.py
get_layer_file_name
⚓︎
The file name a layer is saved under: its display name without the unique suffix.
get_or_create_layer
⚓︎
Get a chunk's layer as get_layer() does, creating it if it does not exist yet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
ChunkCommon
|
The chunk whose layer to get |
required |
Returns:
| Type | Description |
|---|---|
Layer | None
|
Sdf.Layer | None: The layer, or None when there is no stage or the chunk has been |
Layer | None
|
deleted |
Source code in usd_chunks/chunk_registry.py
2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 | |
holding_deletes
⚓︎
Take the layers of chunks deleted inside this block off the stage together, at its end.
Each layer taken off on its own recomposes the whole stage, twice with the mute, so deleting every chunk of a big network one by one cost the square of its size -- most of the time closing a 900-chunk scene took. Nested blocks join the outermost.
Source code in usd_chunks/chunk_registry.py
initialize
⚓︎
Set up the manager for a stage. Call at least once before using it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
Stage
|
The stage to manage |
required |
Source code in usd_chunks/chunk_registry.py
2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 | |
is_muted
⚓︎
Check if a chunk's layer is muted.
A chunk layer can be muted stage-scoped (the disable path) or at the Sdf level (node graph view slots); either counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
ChunkHash
|
The chunk whose layer to check |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the layer is muted, False otherwise |
Source code in usd_chunks/chunk_registry.py
iter_chunk_layers
⚓︎
Every tracked graph layer and chunk layer, with the layer it sits under.
Covers every graph layer regardless of which real layer (the session layer, or an Edit-Target-chosen sublayer) it is attached under.
Yields:
| Type | Description |
|---|---|
tuple[Layer, Layer]
|
(parent, sublayer) pairs. |
Source code in usd_chunks/chunk_registry.py
place_deferred_layers
⚓︎
Put every layer held back by defer_placement on the stage, and stop deferring.
Each graph layer's sublayer list is written once, for all its chunks: every write to a list on the stage recomposes the whole layer stack, so placing a layer per write made a network of n chunks cost n recomposes of up to n layers each.
Each chunk's Edit Target is resolved first, while every held layer is still on the stage: an Edit Target names a layer, and counts only while that layer is composed. Asked during placement, a layer a Layer chunk made was in no stack -- its loading layer gone, the graph layer it moves to written only at the end -- so a chunk not yet resolved fell back to the session layer: a group's child under an Edit Target cooked outside the layer the target exports. The answers are kept: the memo holds across this manager's own layer edits.
Source code in usd_chunks/chunk_registry.py
reset
⚓︎
Return the singleton to its pre-initialize state, dropping every layer mapping.
Used when switching stages (reload, tests) so state from the old stage's stack doesn't leak into the new one. Keeps this class the single owner of its private field list -- callers must not clear fields directly.
Source code in usd_chunks/chunk_registry.py
save_cook_layers
⚓︎
Write every cook layer's bake to its file: what its chunks cooked, flattened.
At runtime a cook layer only lists the layers its chunks cook into, all in memory. The bake is that stack flattened (UsdUtils.FlattenLayerStack, honouring the stage's mutes) and written beside the layer that lists it, so a consumer without usd_chunks sees the result. The layer in memory keeps listing the live ones; it is exported, never saved.
Each chunk the bake holds is stamped in the file's customLayerData under usdchunks:cooks, by its prim path in the file's own namespace: its module hash, a hash of its inputs, and whether its result is partial (muted, blocked outside the active view, or never cooked). A bake whose stamps no longer match is stale.
Returns:
| Type | Description |
|---|---|
list[str]
|
The files written. |
Source code in usd_chunks/chunk_registry.py
save_layer
⚓︎
Export one chunk's layer into a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
ChunkHash
|
The chunk. |
required |
dirname
|
str | Path
|
The directory to write to. |
required |
Returns:
| Type | Description |
|---|---|
|
The written file, or None if the chunk has no layer. |
Source code in usd_chunks/chunk_registry.py
save_layers
⚓︎
Export every chunk layer into a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The directory to write to. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
{chunk: written file}, empty if |
Source code in usd_chunks/chunk_registry.py
target_of_layer
⚓︎
The real layer a chunk layer's content lands in (get_chunk_target, by layer).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
Layer
|
A chunk's own layer. |
required |
Returns:
| Type | Description |
|---|---|
Layer | None
|
Its chunk's target, or None if no tracked chunk owns |
Source code in usd_chunks/chunk_registry.py
ChunkModule
⚓︎
One chunk module file, as the ChunkRegistry manages it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
ModuleType | None
|
The loaded chunk module |
None
|
module_name
|
str
|
The name of the module |
''
|
module_file
|
str
|
The original, absolute, path to the python module |
Path()
|
Source code in usd_chunks/chunk_registry.py
__repr__
⚓︎
create
⚓︎
Run the module's main function and return the chunks it made, with its config attached.
The chunks are not added to a scene; the caller does that.
Returns:
| Type | Description |
|---|---|
Sequence[ChunkBase]
|
Sequence[ChunkBase]: The created chunks, empty if main failed or is missing. |
Source code in usd_chunks/chunk_registry.py
declared_requirements
⚓︎
Its requirements, then its optional ones (the module-level declared_requirements).
export
⚓︎
Export this ChunkModule's source as a .py file. Any other extension warns and fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The path to export to. Should be .py |
required |
Source code in usd_chunks/chunk_registry.py
from_chunk_definition
staticmethod
⚓︎
Create a ChunkModule from a chunk module file (.py).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str | Path
|
The module file. |
required |
name
|
str | None
|
The module name; defaults to the file's stem. |
None
|
Returns:
| Type | Description |
|---|---|
list[ChunkModule]
|
list[ChunkModule]: A list holding the created module, or empty for anything |
list[ChunkModule]
|
that is not a .py file. |
Source code in usd_chunks/chunk_registry.py
get_menu_path
⚓︎
Get the menu namespace this module lives under, outermost element first.
The module's dotted path is prefixed with its category, dropping a leading path element that merely repeats that category.
Returns:
| Type | Description |
|---|---|
list[str]
|
List[str]: The menu namespace, outermost first; the last element is the label. |
has_config
⚓︎
has_main
⚓︎
installed_packages
⚓︎
The installed version of each package the config declares, optional ones included.
A package unpacked into a folder on PYTHONPATH, as the usdview bundles do it, has no install record to read a version from; if it is imported, its version stands in.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
{package: installed version}; a package with no version to find is left out. |
Source code in usd_chunks/chunk_registry.py
load
⚓︎
Load the module and create its chunks.
Runs the one-time initialization before create(). Once loaded, call create() directly to skip it.
Returns:
| Type | Description |
|---|---|
Sequence[ChunkBase]
|
Sequence[ChunkBase]: The created chunks, empty if loading failed. |
Source code in usd_chunks/chunk_registry.py
optional_requirements_installed
⚓︎
Whether every optional requirement is installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
installed
|
installed_packages(), when the caller has it already. |
None
|
Source code in usd_chunks/chunk_registry.py
should_load_for_filter
⚓︎
Check if this module passes USD_CHUNK_LOAD_FILTER.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if no filter is set or the module is named in it |
Source code in usd_chunks/chunk_registry.py
should_load_for_host
⚓︎
Whether config.hosts lets the module load in host name at version.
Empty hosts means every host. Otherwise one entry must name this host, and its specifier (if any) must admit the version: "blender>=5.1" admits "5.1.0", and a host that reports no version only matches an entry without a specifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The host's name, from SceneSender.get_host(). |
required |
version
|
str
|
Its version string. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the module may load here |
Source code in usd_chunks/chunk_registry.py
should_load_for_plugin
⚓︎
Check if the module may be used with a plugin.
An empty config.load_for_plugin means the module is safe to load everywhere.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_name
|
str
|
The name of the plugin |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the ChunkModule can be used with the plugin plugin_name |
Source code in usd_chunks/chunk_registry.py
unload
⚓︎
ChunkRegistry
⚓︎
A singleton that finds and registers chunk modules.
By default chunk modules are scanned for in the USD_CHUNK_DIRS directories.
Attributes:
| Name | Type | Description |
|---|---|---|
registered_directories |
set[str]
|
A set of directories we have searched |
registered_modules |
dict[str, ChunkModule]
|
A mapping between module names and modules |
scene |
SceneSender
|
An instance of the SceneSender for accessing the scene |
plugin |
str
|
A string identifier of the currently loaded plugin |
get_chunk_module
⚓︎
Get the ChunkModule registered under a module name.
The name is the chunk's file name without its folder or extension, e.g. A/B/C/foo.py is 'foo'. A folder-qualified name such as 'B.C.foo', as older scenes saved it, resolves to the same module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_name
|
str
|
The name of the module to find |
required |
Returns:
| Type | Description |
|---|---|
ChunkModule | None
|
ChunkModule | None: The module, or None if not found |
Source code in usd_chunks/chunk_registry.py
get_chunk_modules
⚓︎
Every registered chunk module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loaded
|
Only the modules that are loaded. |
False
|
|
sort_result
|
Sort by module name. |
False
|
Returns:
| Type | Description |
|---|---|
list[ChunkModule]
|
The modules. |
Source code in usd_chunks/chunk_registry.py
get_menu_entries
⚓︎
Get every entry a chunk-creation menu should offer, described without reference to any UI.
One entry per registered module, plus one per element of that module's ChunkConfig.variants. Variant entries sit alongside their module rather than beneath it, so a declared variant reads as a chunk in its own right in both the menu tree and the search field -- which is the whole point of declaring one.
A variant label may contain "/" to nest further, e.g. "standard_surface/Standard Surface". A catalog-driven module can declare hundreds of variants, and those need grouping or the category becomes one unnavigable list; search stays flat either way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sort_result
|
bool
|
Sort modules by trailing name, as get_chunk_modules does |
True
|
Returns:
| Type | Description |
|---|---|
list[MenuEntry]
|
List[MenuEntry]: Base and variant entries, in module order |
Source code in usd_chunks/chunk_registry.py
import_chunk
⚓︎
Import a chunk module from path. The file extension of path should be .py.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The path to the chunk module |
required |
Source code in usd_chunks/chunk_registry.py
initialize
⚓︎
Initialize the FileReader with the working directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scene_sender
|
SceneSender
|
A SceneSender instance for access to the scene. We hold a reference to it here in order to keep it alive |
required |
plugin
|
str
|
A string identifying the currently used plugin |
required |
Source code in usd_chunks/chunk_registry.py
register_chunk_environ_directories
⚓︎
Register USD_CHUNK_DIRS, then append the GLOBAL_USDCHUNKS directory.
On a duplicate module name the first-registered wins (see register_module), so the USD_CHUNK_DIRS entries -- your proprietary / on-prem chunks -- override marketplace chunks installed into the appended GLOBAL_USDCHUNKS dir.
Returns:
| Type | Description |
|---|---|
list[Path]
|
The registered directories, in precedence order. |
Source code in usd_chunks/chunk_registry.py
register_chunk_modules
⚓︎
Recursively register the chunk module files (.py) under each directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Iterable[Path]
|
The directories containing the chunk modules to register. |
required |
Source code in usd_chunks/chunk_registry.py
register_directory
⚓︎
Add a single directory to the register.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk_dir
|
str | Path
|
The directory to add; a relative one is taken from the working directory now and kept absolute (see register_chunk_environ_directories). |
required |
Source code in usd_chunks/chunk_registry.py
register_module
⚓︎
Register a ChunkModule, keeping it alive and accessible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
ChunkModule
|
The module to add to the registry |
required |
Returns:
| Type | Description |
|---|---|
ChunkModule | None
|
ChunkModule | None: The registered module, or None if it was skipped |
Source code in usd_chunks/chunk_registry.py
unload_modules
⚓︎
Unload every loaded module, so the next load of each reads its file again.
The chunks already made stay as they are. Reload Chunks (chunk_stage.ChunkStageSync.reload_chunks) calls this, then builds them again.
Source code in usd_chunks/chunk_registry.py
MenuEntry
dataclass
⚓︎
One selectable item in a chunk-creation menu, described without reference to any UI.
A module contributes one base entry, plus one more per ChunkConfig.variants element. A variant creates exactly the same chunk as its module and then presets some params, so it needs no ChunkModule of its own: the preset lands in an ordinary param value, which round-trips through save/load like any other. That is what keeps N menu entries from costing N files -- module identity, discovery and shadowing all stay 1:1 with a file, and only the menu grows.
Frontends render this list rather than deriving it, so a module that declares variants gains them in every frontend at once.
Attributes:
| Name | Type | Description |
|---|
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
ChunkModule
|
|
required |
namespace
|
tuple[str, ...]
|
|
required |
tooltip
|
str
|
|
''
|
presets
|
dict[str, Any] | None
|
|
None
|
create
⚓︎
Create this entry's chunk(s), applying any variant presets.
Presets are applied here rather than by the caller because they must land before the chunk is added to a container: PARAM_ADDED fires synchronously and builds widgets that read their values immediately, so a preset applied after the add would never reach the widgets it was supposed to configure.
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
The created chunks, ready for the caller to add |
Source code in usd_chunks/chunk_registry.py
candidate_distributions
⚓︎
Every pip name that could plausibly supply this import.
Several distributions can provide one module -- opencv-python and opencv-python-headless both give you cv2 -- so there is no single right answer to check against. The static map covers the well-known renames without needing anything installed; the environment is consulted as well, which catches the variants the map does not know, but is never the only source or a chunk would pass or fail on which variant this particular machine happens to have.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
imported
|
str
|
A top-level import name. |
required |
Returns:
| Type | Description |
|---|---|
set
|
Normalised distribution names. |
Source code in usd_chunks/chunk_registry.py
clean_description
⚓︎
Dedented/stripped chunk description for a tooltip; '' for the unset placeholder.
Descriptions are often triple-quoted with leading indentation; dedent + strip so the tooltip reads cleanly. Returns '' for the default placeholder so undocumented chunks show no tooltip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desc
|
str
|
The raw ChunkConfig.description |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Tooltip-ready text, or '' when the chunk is undocumented |
Source code in usd_chunks/chunk_registry.py
conflicting_requirements
⚓︎
Packages whose installed version fails some chunk's declared range.
Reported against the version actually installed rather than by intersecting ranges in the abstract, because that is the question that has an answer: two chunks disagreeing matters exactly when what is on the machine cannot satisfy both. It also catches the single-chunk case, where the one declared range is not what is installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modules
|
The chunk modules to check. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
{package: [(module_name, specifier, installed), ...]} for the failures only. |
Source code in usd_chunks/chunk_registry.py
declared_requirements
⚓︎
Every package a module declares: its requirements, then its optional ones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
The chunk module. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The requirement strings. |
Source code in usd_chunks/chunk_registry.py
installed_version
⚓︎
The version actually importable right now, or None.
The only number that is true. What a chunk declared is a claim; this is what ran, and it is what a recipe's manifest has to record -- otherwise a conflict resolved by whichever install landed last is invisible after the fact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
A distribution name; "-" and "_" spellings are both tried. |
required |
Returns:
| Type | Description |
|---|---|
|
The installed version, or None. |
Source code in usd_chunks/chunk_registry.py
is_chunk_internal_layer
⚓︎
Whether the chunk graph owns this layer.
"Internal" means a per-chunk procedural layer or a graph layer grouping them: content the chunk system Clear()s and regenerates, never something a user picks as an Edit Target or exports, and never somewhere a chunk's bookkeeping may be hand-moved.
Answered from the identifiers ChunkLayerManager records as it creates them, so it costs a set lookup. The alternative -- deriving it by walking every tracked layer's sublayers -- has to be redone against live subLayerPaths every time it is asked, which is once per reconcile pass and one pass per wire, and the layer stack grows with the graph.
Deliberately NOT stored on the layer itself, which is the obvious place and is wrong: Sdf.Layer.Clear() drops customLayerData along with everything else, and Clear() on its own layer is exactly what a procedural chunk does every time it cooks. A mark there survives until the chunk first runs and then silently disappears.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
Layer
|
The layer to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for a layer the chunk graph created. |
Source code in usd_chunks/chunk_registry.py
match_score
⚓︎
How well query matches label, or the category path it sits in; 0 if it does not.
Every word of query must match. The scoring is search_menu_entries', so the chunk menu and the node graph's search rank the same way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
What was typed; case and surrounding whitespace are ignored. |
required |
label
|
str
|
The name being searched for. |
required |
path
|
tuple[str, ...]
|
Weaker names the label also answers to, such as its category. |
()
|
Returns:
| Type | Description |
|---|---|
int
|
The score, higher for a closer match; 0 for an empty query or any word that misses. |
Source code in usd_chunks/chunk_registry.py
migrate_legacy_dependencies
⚓︎
Copy into target the packages in sources that this interpreter can import.
Run while this Python version's folder has no packages yet, so a user upgrading is not asked to reinstall every chunk's packages. A distribution is copied only if its wheel tags fit this interpreter and its files are intact (_intact_files); anything else is left for the usual ask-to-install. Copied, not moved: the sources may also hold packages for another Python version, whose own first run migrates them. Several versions of one distribution: the newest that qualifies wins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sources
|
list[str]
|
Folders packages were |
required |
target
|
str
|
This Python version's dependency folder. It may already exist holding only the package cache file; anything else in it means it is in use, and nothing is copied. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The distributions copied, as "name-version". |
Source code in usd_chunks/chunk_registry.py
search_menu_entries
⚓︎
The entries matching query, closest first -- the chunk menu's search.
Every word of the query must match the entry's name or its category path. A name that starts with the query ranks first (shorter names ahead), then a name with a word that starts with it, then the query anywhere in the name, then the name's initials ("vmo" for vector_math_ops), then the category, then the query's letters in order with a few missing in between ("tranform"). Shared by every frontend so "trans" lists the same chunks in the same order everywhere.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entries
|
List[MenuEntry]
|
The entries to search, in menu order |
required |
query
|
str
|
What was typed; case and surrounding whitespace are ignored |
required |
Returns:
| Type | Description |
|---|---|
list[MenuEntry]
|
List[MenuEntry]: Matching entries, best first; all of entries, unchanged, for an |
list[MenuEntry]
|
empty query. |
split_requirement
⚓︎
A requirement string as (name, specifier), specifier "" when unconstrained.
Separate from ChunkDependencyManager.package_info, which answers a narrower question -- the exact version to cache an install under -- and only understands "==".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requirement
|
str
|
A requirement string. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
(name, specifier). |
Source code in usd_chunks/chunk_registry.py
top_level_imports
⚓︎
The root names a chunk module imports at module scope, read without executing it.
Walks into try/except, if and with rather than only tree.body, so a guarded import is
seen. rbd_solver is exactly that case::
try:
import mujoco as _mj
import numpy as _np
_HAS_MUJOCO = True
except ImportError:
_HAS_MUJOCO = False
Reading only the literal top level would report nothing for that file, in the one chunk where a version silently changing the answer matters most -- try-guarding a heavy optional is the normal pattern for precisely the chunks that carry a simulator.
Function and class bodies are still skipped, which is the actual house rule: imports go at module top level, never inside a function. A try-guarded import obeys that rule lexically; it just is not an ast.Import node in tree.body, which is a different thing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_file
|
The chunk module's file. |
required |
Returns:
| Type | Description |
|---|---|
set
|
The imported root names, empty if the file cannot be read or parsed. |
Source code in usd_chunks/chunk_registry.py
unconstrained_requirements
⚓︎
Requirements declared with no version constraint at all.
A bare "mujoco" says nothing, so two runs a month apart can use different solvers from an identical recipe and nothing recorded explains the difference.
A range is what a chunk should declare -- what it is compatible with -- rather than an exact pin. Exact pins do not compose: two chunks pinning numpy==2 and numpy==3 have no solution, there is one sys.modules['numpy'], and resolving it would mean editing someone else's chunk. Ranges intersect, and the exact version belongs in the recipe that runs them, recorded as what was actually imported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
ChunkModule
|
The chunk module. |
required |
Returns:
| Type | Description |
|---|---|
list
|
The unconstrained requirement strings. |
Source code in usd_chunks/chunk_registry.py
undeclared_imports
⚓︎
Third-party imports a chunk makes without declaring them in config().
An undeclared dependency is not only an install that breaks on a clean machine -- it is a version that never reaches a run's manifest. A chunk importing numpy without saying so means a numpy upgrade can change its results while the manifest still reads clean, which is worse than having no manifest, because it looks authoritative.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
ChunkModule
|
The chunk module. |
required |
sibling_modules
|
The other chunk modules' import names, which resolve locally and are not dependencies to declare. |
()
|
Returns:
| Type | Description |
|---|---|
list
|
The undeclared import names. |