Skip to content

Commit 42bb048

Browse files
committed
Fix Houdini CachedResolver production example syntax errors
1 parent 0efa8a0 commit 42bb048

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ endif()
450450
# Status
451451
message(STATUS "--- Usd Resolver Build Info Start ---")
452452
message(NOTICE "Detected Libs:")
453-
message(NOTICE "- DCC: ${AR_DCC_NAME}")
453+
message(NOTICE "- DCC: $ENV{AR_DCC_NAME}")
454454
message(NOTICE "- Python: ${AR_PYTHON_LIB}")
455455
message(NOTICE "- Boost: Python ${AR_BOOST_PYTHON_LIB}")
456456
message(STATUS "--- Usd Resolver Build Info End ---")

files/implementations/CachedResolver/code/PythonExpose.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import re
55
from functools import wraps
66

7+
from pxr import Sdf
8+
79
# Init logger
810
logging.basicConfig(format="%(asctime)s %(message)s", datefmt="%Y/%m/%d %I:%M:%S%p")
911
LOG = logging.getLogger("Python | {file_name}".format(file_name=__name__))
10-
LOG.setLevel(level=logging.INFO)
12+
LOG.setLevel(level=logging.DEBUG)
1113

1214
# Globals
1315
ROOT_DIR_PATH = os.path.dirname(os.path.dirname(__file__))
@@ -71,7 +73,7 @@ def CreateRelativePathIdentifier(resolver, anchoredAssetPath, assetPath, anchorA
7173
entity_element = os.path.basename(assetPath).split("_")[0]
7274
entity_version = REGEX_VERSION.search(os.path.basename(assetPath)).groups()[0]
7375

74-
remapped_relative_path_identifier = f"{RELATIVE_PATH_IDENTIFIER_PREFIX}{entity_type}/{entity_identifier}?{entity_element}-{entity_version}"
76+
remapped_relative_path_identifier = f"{RELATIVE_PATH_IDENTIFIER_PREFIX}{entity_type}/{entity_identifier}?{entity_element}_{entity_version}"
7577
resolver.AddCachedRelativePathIdentifierPair(anchoredAssetPath, remapped_relative_path_identifier)
7678

7779
# If you don't want this identifier to be passed through to ResolverContext.ResolveAndCache
@@ -117,6 +119,9 @@ def ResolveAndCache(context, assetPath):
117119
LOG.debug(
118120
"::: ResolverContext.ResolveAndCache | {} | {}".format(assetPath, context.GetCachingPairs())
119121
)
122+
if Sdf.Layer.IsAnonymousLayerIdentifier(assetPath):
123+
return assetPath
124+
120125
resolved_asset_path = ""
121126
if assetPath.startswith(RELATIVE_PATH_IDENTIFIER_PREFIX):
122127
base_identifier = assetPath[len(RELATIVE_PATH_IDENTIFIER_PREFIX):]

src/CachedResolver/PythonExpose.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
from functools import wraps
55

6-
from pxr import Ar
6+
from pxr import Ar, Sdf
77

88

99
# Init logger
@@ -118,6 +118,9 @@ def ResolveAndCache(context, assetPath):
118118
# To clear the context cache call:
119119
context.ClearCachingPairs()
120120
"""
121+
if Sdf.Layer.IsAnonymousLayerIdentifier(assetPath):
122+
context.AddCachingPair(assetPath, assetPath)
123+
return assetPath
121124
"""The code below is only needed to verify that UnitTests work."""
122125
UnitTestHelper.resolve_and_cache_call_counter += 1
123126
resolved_asset_path = "/some/path/to/a/file.usd"

src/PythonResolver/PythonExpose.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def _CreateIdentifier(assetPath, anchorAssetPath, serializedContext, serializedF
151151
"""
152152
if not assetPath:
153153
return assetPath
154+
if Sdf.Layer.IsAnonymousLayerIdentifier(assetPath):
155+
return assetPath
154156
if not anchorAssetPath:
155157
return os.path.normpath(assetPath)
156158
anchoredAssetPath = _AnchorRelativePath(anchorAssetPath.GetPathString(), assetPath)
@@ -172,6 +174,8 @@ def _CreateIdentifierForNewAsset(assetPath, anchorAssetPath):
172174
"""
173175
if not assetPath:
174176
return assetPath
177+
if Sdf.Layer.IsAnonymousLayerIdentifier(assetPath):
178+
return assetPath
175179
if _IsRelativePath(assetPath):
176180
if anchorAssetPath:
177181
return os.path.normpath(_AnchorRelativePath(anchorAssetPath.GetPathString(), assetPath))
@@ -191,6 +195,8 @@ def _Resolve(assetPath, serializedContext, serializedFallbackContext):
191195
"""
192196
if not assetPath:
193197
return Ar.ResolvedPath()
198+
if Sdf.Layer.IsAnonymousLayerIdentifier(assetPath):
199+
return Ar.ResolvedPath(assetPath)
194200
if _IsRelativePath(assetPath):
195201
if Resolver._IsContextDependentPath(assetPath):
196202
for data in [serializedContext, serializedFallbackContext]:
@@ -228,6 +234,9 @@ def _ResolveForNewAsset(assetPath):
228234
Returns:
229235
Ar.ResolvedPath: The resolved path.
230236
"""
237+
if Sdf.Layer.IsAnonymousLayerIdentifier(assetPath):
238+
return Ar.ResolvedPath(assetPath)
239+
231240
return Ar.ResolvedPath(assetPath if not assetPath else os.path.abspath(os.path.normpath(assetPath)))
232241

233242
@staticmethod

0 commit comments

Comments
 (0)