-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,22 +16,26 @@ | |
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
#define USD_UTILS_VALIDATOR_NAME_TOKENS \ | ||
((packageEncapsulationValidator, \ | ||
"usdUtilsValidators:PackageEncapsulationValidator")) \ | ||
((fileExtensionValidator, \ | ||
"usdUtilsValidators:FileExtensionValidator")) | ||
|
||
#define USD_UTILS_VALIDATOR_KEYWORD_TOKENS \ | ||
(UsdUtilsValidators) \ | ||
#define USD_UTILS_VALIDATOR_NAME_TOKENS \ | ||
((packageEncapsulationValidator, \ | ||
"usdUtilsValidators:PackageEncapsulationValidator")) \ | ||
((fileExtensionValidator, \ | ||
"usdUtilsValidators:FileExtensionValidator")) \ | ||
((missingReferenceValidator, \ | ||
"usdUtilsValidators:MissingReferenceValidator")) \ | ||
|
||
#define USD_UTILS_VALIDATOR_KEYWORD_TOKENS \ | ||
(UsdUtilsValidators) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
(UsdzValidators) | ||
|
||
#define USD_UTILS_VALIDATION_ERROR_NAME_TOKENS \ | ||
((layerNotInPackage, "LayerNotInPackage")) \ | ||
((assetNotInPackage, "AssetNotInPackage")) \ | ||
((invalidLayerInPackage, "InvalidLayerInPackage")) \ | ||
((unsupportedFileExtensionInPackage, \ | ||
"UnsupportedFileExtensionInPackage")) | ||
"UnsupportedFileExtensionInPackage")) \ | ||
((unresolvableDependency, "UnresolvableDependency")) | ||
|
||
|
||
///\def | ||
/// Tokens representing validator names. Note that for plugin provided | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,10 +143,44 @@ _FileExtensionValidator(const UsdStagePtr& usdStage) { | |
return errors; | ||
} | ||
|
||
static | ||
UsdValidationErrorVector | ||
_MissingReferenceValidator(const UsdStagePtr& usdStage) { | ||
const SdfLayerRefPtr& rootLayer = usdStage->GetRootLayer(); | ||
|
||
SdfLayerRefPtrVector layers; | ||
std::vector<std::basic_string<char>> assets, unresolvedPaths; | ||
const SdfAssetPath& path = SdfAssetPath(rootLayer->GetIdentifier()); | ||
|
||
UsdUtilsComputeAllDependencies(path, &layers, &assets, &unresolvedPaths, | ||
nullptr); | ||
|
||
UsdValidationErrorVector errors; | ||
for(const std::basic_string<char>& unresolvedPath : unresolvedPaths) | ||
{ | ||
errors.emplace_back( | ||
UsdUtilsValidationErrorNameTokens->unresolvableDependency, | ||
UsdValidationErrorType::Error, | ||
UsdValidationErrorSites { | ||
UsdValidationErrorSite( | ||
rootLayer, SdfPath(unresolvedPath)) | ||
}, | ||
TfStringPrintf( | ||
("Found unresolvable external dependency " | ||
"'%s'."), unresolvedPath.c_str()) | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it does! awesome. I'll close this one out then. Thanks |
||
|
||
return errors; | ||
} | ||
|
||
TF_REGISTRY_FUNCTION(UsdValidationRegistry) | ||
{ | ||
UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); | ||
|
||
registry.RegisterPluginValidator( | ||
UsdUtilsValidatorNameTokens->missingReferenceValidator, _MissingReferenceValidator); | ||
|
||
registry.RegisterPluginValidator( | ||
UsdUtilsValidatorNameTokens->packageEncapsulationValidator, | ||
_PackageEncapsulationValidator); | ||
|
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.