Skip to content

pinning

generate_pinning_file(entry_usd, root_info, pinning_file_path)

Generate a AYON USD Resolver pinning file.

The pinning file can be used to pin paths in USD to specific filepaths, avoiding the need for dynamic resolving and runtime and allowing to pin dynamic URIs (like "get me latest version") to be pinned to the version at the time of the generation.

Parameters:

Name Type Description Default
entry_usd str

The USD filepath to generate the pinning file for.

required
root_info Dict[str, str]

The project roots for the site the pinning should resolve to. These can be obtained via e.g. the AYON REST API get `/api/projects/{project_name}/siteRoots".

required
pinning_file_path str

The destination path to write the pinning file to.

required
Source code in client/ayon_usd/standalone/usd/pinning/_pinning_file_generation_funcs.py
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
def generate_pinning_file(
    entry_usd: str, root_info: Dict[str, str], pinning_file_path: str
):
    """Generate a AYON USD Resolver pinning file.

    The pinning file can be used to pin paths in USD to specific filepaths,
    avoiding the need for dynamic resolving and runtime and allowing to pin
    dynamic URIs (like "get me latest version") to be pinned to the version
    at the time of the generation.

    Arguments:
        entry_usd: The USD filepath to generate the pinning file for.
        root_info: The project roots for the site the pinning should resolve
          to. These can be obtained via e.g. the AYON REST API get
          `/api/projects/{project_name}/siteRoots".
        pinning_file_path: The destination path to write the pinning file to.

    """

    if not pinning_file_path.endswith(".json"):
        raise RuntimeError(
            f"Pinning file path is not a json file {pinning_file_path}")

    # Assume that the environment sets up the correct default AyonUsdResolver
    resolver = Ar.GetResolver()
    pinning_data = get_asset_dependencies(entry_usd, resolver)

    # on Windows, we need to make the drive letter lowercase.
    if sys.platform.startswith("win"):
        pinning_data = {
            # _normalize_path(key): _normalize_path(val)
            key: _normalize_path(val)
            for key, val in pinning_data.items()
        }

    rootless_pinning_data = remove_root_from_dependency_info(
        pinning_data, root_info
    )

    rootless_pinning_data["ayon_pinning_data_entry_scene"] = _remove_sdf_args(
        entry_usd
    )

    _write_pinning_file(
        pinning_file_path,
        rootless_pinning_data,
    )