Skip to content
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

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

beersandrew
Copy link
Contributor

Description of Change(s)

  • created implementation, test, as well as associated entries in plugInfo.json & validatorTokens.h

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)

("Found unresolvable external dependency "
"'%s'."), unresolvedPath.c_str())
);
}
Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10493

@jesschimein
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@beersandrew
Copy link
Contributor Author

Closing since this work is already complete, see Varun's comment above

@beersandrew beersandrew reopened this Dec 10, 2024
Copy link
Contributor

@tallytalwar tallytalwar left a 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."
Copy link
Contributor

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.

Copy link
Contributor

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) \
Copy link
Contributor

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). :/

Copy link
Contributor Author

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.

Copy link
Contributor

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");
Copy link
Contributor

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?

Copy link
Contributor

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).

Copy link
Contributor Author

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

@beersandrew beersandrew force-pushed the validation-usdUtils-MissingReferenceValidator branch from 595a8d6 to b6e248d Compare December 12, 2024 05:52
@jesschimein
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jesschimein
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).


const UsdStageRefPtr& stage = UsdStage::CreateInMemory();

const UsdGeomXform xform = UsdGeomXform::Define(stage, SdfPath("/Xform"));
Copy link
Contributor

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

Comment on lines 162 to 164
xform.GetPrim().GetReferences().RemoveReference(badLayerReference);
const SdfReference badAssetReference("doesNotExist.jpg");
xform.GetPrim().GetReferences().AddReference(badAssetReference);
Copy link
Contributor

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'
>>>

Copy link
Contributor Author

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

Comment on lines 185 to 189
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")));
Copy link
Contributor

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?

Copy link
Contributor Author

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
@beersandrew beersandrew force-pushed the validation-usdUtils-MissingReferenceValidator branch from 73b6890 to d71c0a1 Compare December 18, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants