Closed jackie-megalis closed 2 months ago
Hey Jackie, thanks for re-posting your question here.
For context, I want to use this method to dynamically resolve sublayered assets. For example, if I resolve a shot called "shot" and input it as shot.latest, I hope to hook into CreateRelativePathIdentifier to add custom prefixes that resolve all sublayered assets as the latest version. Conversely, if I input shot.first, I want to resolve all sublayered assets as the first, again using a custom prefix from CreateRelativePathIdentifier.
I think you can also achieve this by just using ResolveAndCache and adjusting the logic in there to resolve different files to different versions. The relative path feature is more there to solve overriding relative dependent paths (which yes is partially what you are aiming for). At the end of the day it kind of just depends on how you want to deal with asset identifiers.
Would it be possible to also share the .usd files you are testing with? It would be easier to debug your scenario that way.
Have you tried going through the example setup as described here: Setup: https://lucascheller.github.io/VFX-UsdAssetResolver/resolvers/CachedResolver/example.html Files: https://github.com/LucaScheller/VFX-UsdAssetResolver/tree/main/files/implementations/CachedResolver
You can also see if relative path exposure is actually on via:
from pxr import Ar, Sdf, Usd, Vt
from usdAssetResolver import CachedResolver
import PythonExpose
resolver = Ar.GetResolver()
cached_resolver = Ar.GetUnderlyingResolver()
print(cached_resolver.GetExposeRelativePathIdentifierState())
cached_resolver.SetExposeRelativePathIdentifierState(True)
resolver tag 0.7.2
import os
from pxr import Ar, Sdf, Usd, Vt
from usdAssetResolver import CachedResolver
import PythonExpose
resolver = Ar.GetResolver()
cached_resolver = Ar.GetUnderlyingResolver()
print(os.environ.get("AR_CACHEDRESOLVER_ENV_EXPOSE_ABSOLUTE_PATH_IDENTIFIERS"))
print(cached_resolver.GetExposeAbsolutePathIdentifierState())
1 False
For the absolute path I have something similar. The variable is set but the resolver seems not affected by the variable.
I just noticed the docs are wrong, sorry about that! I'll fit it asap.
The env vars to set are: "AR_EXPOSE_ABSOLUTE_PATH_IDENTIFIERS" "AR_EXPOSE_RELATIVE_PATH_IDENTIFIERS"
They are configured here: https://github.com/LucaScheller/VFX-UsdAssetResolver/blob/main/CMakeLists.txt#L57
Using those env vars worked and it properly calls CreateRelativePathIdentifier now! Thank you so much! Closing this issue :)
Hi Luca!
As I mentioned in the aousd forum thread, I’m using the USD Asset Resolver for Houdini and attempting to enable Relative Path Identifiers. Before launching Houdini, I set the environment variable AR_CACHEDRESOLVER_ENV_EXPOSE_RELATIVE_PATH_IDENTIFIERS=1 and confirmed that it is correctly set to 1 using the Python shell within the Houdini session.
However, when resolving assets, the CreateRelativePathIdentifier function is not being called, even though the Initialize and ResolveAndCache functions seem to be triggered (but not in certain instances). Here I've attached my environment as a txt file along with a trimmed-down example where I expected CreateRelativePathIdentifier to be invoked: asset_resolver_issue.zip
I included log statements to identify if and when it’s being called, as well as its return behavior. Here’s how it behaves:
Additionally, paths that were sublayered from another USD file also only triggered ResolveAndCache.
For context, I want to use this method to dynamically resolve sublayered assets. For example, if I resolve a shot called "shot" and input it as shot.latest, I hope to hook into CreateRelativePathIdentifier to add custom prefixes that resolve all sublayered assets as the latest version. Conversely, if I input shot.first, I want to resolve all sublayered assets as the first, again using a custom prefix from CreateRelativePathIdentifier.
If there's a better approach to achieving this, or if I’m misunderstanding something and not using the resolver as intended, I’d greatly appreciate your insights! Thank you very much for your help and time!