-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usdValidation: usdUtils: MissingReferenceValidator #3450
base: dev
Are you sure you want to change the base?
usdValidation: usdUtils: MissingReferenceValidator #3450
Conversation
("Found unresolvable external dependency " | ||
"'%s'."), unresolvedPath.c_str()) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tallytalwar One note here, it looks like complianceChecker.py is doing another check here which gets some diagnostic information, but it seems like this process of collecting diagnostic information should be started before opening the stage (here). I tried doing this inside the validator with stage.Reload() but was unable to populate the diagnostics this way.
In my specific test, the errors were similar so I wanted your opinion on if it's possible to do something similar here, or if it's necessary to move the diagnostic part over in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might not need an explicit validator for this now! https://github.com/PixarAnimationStudios/OpenUSD/blob/dev/pxr/usdValidation/usdValidation/coreValidators.cpp#L16-L29 should provide coverage for this? Do you want to try running it through the CoreValidator and see if it gives you the appropriate composition error wrapped by a CoreValidation error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it does! awesome. I'll close this one out then. Thanks
Filed as internal issue #USD-10493 |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
Closing since this work is already complete, see Varun's comment above |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few notes, but otherwise lgtm.
@@ -3,6 +3,9 @@ | |||
{ | |||
"Info": { | |||
"Validators": { | |||
"MissingReferenceValidator": { | |||
"doc": "The composed USD stage should not contain any unresolvable asset dependencies (in every possible variation of the asset), when using the default asset resolver." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove the "every possible variation of the asset" thats part of the usdchecker to iterate through various variants. Validator should just be checking a stage/variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets leave it as is, since UsdUtilsComputeAllDependencies operates at Sdf level and will give unresolved references across variants.
#define USD_UTILS_VALIDATOR_KEYWORD_TOKENS \ | ||
(UsdUtilsValidators) \ | ||
#define USD_UTILS_VALIDATOR_KEYWORD_TOKENS \ | ||
(UsdUtilsValidators) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if UsdUtilsValidators should be the name of it! (I also want to move this pxr/usdValidation/usdUtilsValidators to be called something else). :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my perspective, the naming started from "which folder in the usd code base does this validator depend on?". Now that the validation code is moved out of those folders, this feels like a broader problem of defining validation domains, which may be fine for the others already (usdGeom, usdShade... etc).
Maybe this validator could go into pxr/usd/usdValidation
? I'm not sure if it's important for that project to not have external dependencies on usdUtils or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly correction the suffix here is the name of the plugin (the directory name happens to be matching the plugin name :D).
I do plan to move the usdUtilsValidators plugin sometime later so lets leave it as-is for now.
const UsdStageRefPtr& stage = UsdStage::CreateInMemory(); | ||
|
||
const UsdGeomXform xform = UsdGeomXform::Define(stage, SdfPath("/Xform")); | ||
const SdfReference badReference("doesNotExist.usd"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also try adding a non-layer asset which is unresolved / missing and see if the validator reports that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might also make sense for the test to include an unresolved layer in a variant which isn't selected in the stage (this is when the composition validator will not report this reference layer in a not-selected variant).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i've added the non-layer asset test, but take a look and make sure it's what you wanted. I'll have the variant test added tomorrow
595a8d6
to
b6e248d
Compare
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
|
||
const UsdStageRefPtr& stage = UsdStage::CreateInMemory(); | ||
|
||
const UsdGeomXform xform = UsdGeomXform::Define(stage, SdfPath("/Xform")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this is fine, but you can also create a prim like:
prim = stage.DefinePrim("/Prim", "Xform")
which won't require you to include usdGeom/xform.h
xform.GetPrim().GetReferences().RemoveReference(badLayerReference); | ||
const SdfReference badAssetReference("doesNotExist.jpg"); | ||
xform.GetPrim().GetReferences().AddReference(badAssetReference); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh don't think its legal to have a non-usd as a reference like this.
An asset would be something like this:
asset inputs:file = @USDLogoLrg.png@ |
So what you can do is:
>>> from pixar import Sdf, Usd, UsdShade
>>> stage = Usd.Stage.CreateInMemory()
>>> shader = UsdShade.Shader.Define(stage, "/Shader")
>>> assetInput = shader.CreateInput("notFoundAsset", Sdf.ValueTypeNames.Asset)
>>> assetInput.Set("NotFoundTexture.png")
True
>>> stage.ExportToString()
'#usda 1.0\n(\n doc = """Generated from Composed Stage of root layer \n"""\n)\n\ndef Shader "Shader"\n{\n asset inputs:notFoundAsset = @NotFoundTexture.png@\n}\n\n'
>>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This has been updated
UsdVariantSets variantSets = xform.GetPrim().GetVariantSets(); | ||
UsdVariantSet colorsVariantSet = variantSets.AddVariantSet("myVariant"); | ||
|
||
UsdGeomXform selectedXform = UsdGeomXform::Define(stage, xform.GetPath().AppendChild(TfToken("selected"))); | ||
UsdGeomXform notSelectedXform = UsdGeomXform::Define(stage, xform.GetPath().AppendChild(TfToken("notSelected"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this is correct.
You can refer the authoring variant tutorials here: https://openusd.org/docs/Authoring-Variants.html
to see how you can add a variantSet with 2 variants on a prim, with one having a good reference and other a bad reference. Have the one which has a good reference be the default set on the prim.
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, thanks for the help here. Should be good now
created implementation, test, as well as associated entries in plugInfo.json & validatorTokens.h
- remove unnecessary usage of usdGeom - corrected how the missing asset test was written - corrected how the variant test was written
73b6890
to
d71c0a1
Compare
Description of Change(s)
Link to proposal (if applicable)
Fixes Issue(s)
Note: This PR is a replacement for #3403
Checklist
[X] I have created this PR based on the dev branch
[X] I have followed the coding conventions
[X] I have added unit tests that exercise this functionality (Reference:
testing guidelines)
[X] I have verified that all unit tests pass with the proposed changes
[X] I have submitted a signed Contributor License Agreement (Reference:
Contributor License Agreement instructions)