MaterialX icon indicating copy to clipboard operation
MaterialX copied to clipboard

Improvements to document validation

Open ld-kerley opened this issue 1 year ago • 7 comments

This PR adds two new pieces to the correctness checking within MaterialX, these were discovered while doing work on MaterialX library files. I found them helpful, so I thought it might help to upstream the changes for others to benefit from too.

When loading libraries, there is now an optional boolean errorOnDuplicates, that will raise an error if a library contains an element is already present, previously this case would silently continue. I did wrestle with if this should just be called strict, incase there are other cases we want to add in the future. Open to input there.

Secondly I have added validation to TypedElement to validate if the type used has actually been registered in the document as a type. This very helpfully tracked down a couple of typos in work-in-progress code.

Finally I added the ability for the mxvalidate.py script to directly accept a path to alternate library locations.

ld-kerley avatar Mar 07 '24 03:03 ld-kerley

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: ld-kerley (ce648d12d4ced4de552e8a78b414b31485995612, e6c6221b1d994f0a856a47393aa5b7234ab0aa95, 30de94790556476f098a8db4f2056f62b515117a, 062d337e9275413ad61e94d2595928a93db056c0)
  • :white_check_mark: login: jstone-lucasfilm / name: Jonathan Stone (533a05343ba8d4474d3e1d03e12037ab28b6c528, 1214d9c0d25062b6b60229c4bc13b1f9f459e32c, 7b217bb10ab11e00e02c1d2e671e0bf2836e0b62, e96d237b984b8d665070c229864d01e16d39a67e)

Thanks for the feedback @kwokcb. This was certainly not posted as final work, and I wanted to get input on what I had thrown together internally to get me unstuck.

ld-kerley avatar Mar 07 '24 16:03 ld-kerley

After a brief chat with @jstone-lucasfilm I added a ValidationOptions class to pass around configuration for the validation stage, this way we can add additional validations, without changing existing behavior.

ld-kerley avatar Mar 08 '24 05:03 ld-kerley

Just on this specific build error, it looks like we'd need to add the new argument for Document::importLibrary to its JavaScript binding, so that existing calls continue to work as before:

https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/source/JsMaterialX/JsMaterialXCore/JsDocument.cpp#L26

jstone-lucasfilm avatar Mar 11 '24 22:03 jstone-lucasfilm

I took a stab at resolving the JS bindings - but I don't have a local build setup to build them, and I also don't have a lot of experience with them either - perhaps someone with more JS chops could give me some pointers (or patch this PR)

ld-kerley avatar Mar 12 '24 00:03 ld-kerley

Thanks for taking a look, @ld-kerley, and either @kwokcb or I can help to resolve that last JavaScript issue.

jstone-lucasfilm avatar Mar 12 '24 00:03 jstone-lucasfilm

@ld-kerley We've now merged development work on MaterialX 1.39 back to the main branch of MaterialX, in preparation for the final weeks of development on the 1.39.0 release. When you have a chance, could you retarget this pull request back to the main branch as well?

jstone-lucasfilm avatar May 30 '24 22:05 jstone-lucasfilm

@ld-kerley I'll close out this pull request for now, since it's framed in terms of a branch that we're planning to delete, but feel free to propose a similar pull request for the main branch in the future!

jstone-lucasfilm avatar Jul 13 '24 17:07 jstone-lucasfilm