Skip to content

Regression in implementation search logic for node definitions #2701

@kwokcb

Description

@kwokcb

Issue

This is a regression from 1.39.4 to 1.39.5.

  1. In 1.39.4: Nodedef.getImplementation() will return the NodeGraph when the assocaition is stored in an implementation. This is the case for both standard surface definitions.
  2. In 1.39.5: Nodedef.getImplemetnation() will return the Implementation association instead. It no longer finds the NodeGraph defined in the association

Steps:

This script will supports scanning the libraries either from a install location or a specification location.
It was used to test a 1.39.4 install and the current 1.39.5 build.

 import MaterialX as mx
import os
import argparse

parser = argparse.ArgumentParser(description="Build MaterialX NodeDef Introspection JSON")
parser.add_argument('-ip', '--input_path', type=str, default='', help="Input path for MaterialX libraries. If not specified will use default search path.")
args = parser.parse_args()

input_path = args.input_path
# Convert opts.library_folder from set to list
library_list = []

path_list = []
if not input_path:

    searchPath = mx.getDefaultDataSearchPath().asString() 
    searchPath = os.path.normpath(searchPath)
    # Append 'libraries' to the search path
    searchPath = mx.FileSearchPath(os.path.join(searchPath, 'libraries'))
    path_list.append(searchPath.asString())

    libraryPath = mx.getDefaultDataSearchPath()
    libraryFolders = mx.getDefaultDataLibraryFolders()

    version = mx.getVersionString()

else:
    libraryFolders = ['libraries']
    searchPath = os.path.normpath(input_path)
    path_list.append(searchPath)
    for lib in libraryFolders:
        path_list.append(os.path.join(searchPath, lib))
    
    libraryPath = mx.FileSearchPath(searchPath)

print("Library folders", libraryFolders)
print("Search paths:", path_list)
print("Library path:", libraryPath.asString())
stdlib = mx.createDocument()
libFiles = mx.loadLibraries(libraryFolders, libraryPath, stdlib)
#for l in libFiles:
#    print("Loaded library file:", l)

# Create main document and import the library document
doc = mx.createDocument()
doc.importLibrary(stdlib)

for nodedef in doc.getNodeDefs():
    nodedef_name = nodedef.getName()

    # Add implementation children if they exist
    implementation = nodedef.getImplementation()
    if implementation:

        # Add nodegraph
        if implementation.isA(mx.NodeGraph):
            pass # print("Add nodegraph implementation for nodedef:", nodedef_name)

        else:
            # Add nodegraph implementation
            node_graph_attr = implementation.getAttribute('nodegraph')
            if node_graph_attr:
                print('FAILED to find nodegraph. Scan manually:', node_graph_attr)
                print(mx.prettyPrint(implementation))
                implementation = doc.getNodeGraph(node_graph_attr)
            else:
                pass
                # Add non-nodegraph implementation
                #print("Add non-nodegraph implementation for nodedef:", nodedef_name, "name", implementation.getNamePath())
    else:
        print(f'-- No implementation for nodedef: {nodedef_name}')

Results 1.39.4

This is taking the local library location from main without any modifications.

python ng_test.py -ip d:\work\materialx\ILM_materialx
Library folders ['libraries']
Search paths: ['d:\\work\\materialx\\ILM_materialx', 'd:\\work\\materialx\\ILM_materialx\\libraries']
Library path: d:\work\materialx\ILM_materialx
-- No implementation for nodedef: ND_volumematerial

Results 1.39.5:

python ng_test.py -ip d:\work\materialx\ILM_materialx
Library folders ['libraries']
Search paths: ['d:\\work\\materialx\\ILM_materialx', 'd:\\work\\materialx\\ILM_materialx\\libraries']
Library path: d:\work\materialx\ILM_materialx
FAILED to find nodegraph. Scan manually: NG_standard_surface_surfaceshader_100
<implementation name="IMPL_standard_surface_surfaceshader_101" nodedef="ND_standard_surface_surfaceshader" nodegraph="NG_standard_surface_surfaceshader_100">

FAILED to find nodegraph. Scan manually: NG_standard_surface_surfaceshader_100
<implementation name="IMPL_standard_surface_surfaceshader_100" nodedef="ND_standard_surface_surfaceshader_100" nodegraph="NG_standard_surface_surfaceshader_100">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions