Python API#
omni.asset_validator API#
- class omni.asset_validator.AssetLocatedCallback(*args, **kwargs)#
A typedef for the notification of asset(s) founds during
ValidationEngine.validate_with_callbacks()
. It is invoked at the beginning of asset validation.- Parameters:
asset (AssetType) – The asset type located.
- class omni.asset_validator.AssetProgressCallback(*args, **kwargs)#
A typedef for the notification of asset progress found during
ValidationEngine.validate_with_callbacks()
.- Parameters:
progress (AssetProgress) – The progress for a specific asset.
- class omni.asset_validator.AssetValidatedCallback(*args, **kwargs)#
A typedef for the notification of asset results found during
ValidationEngine.validate_with_callbacks()
.- Parameters:
results (Results) – The results for a specific asset.
- omni.asset_validator.AuthoringLayers(
- at: AtType | list[AtType],
- omni.asset_validator.AuthoringLayers(
- prop: Property | Attribute | Relationship,
- omni.asset_validator.AuthoringLayers(
- prop: Property | Attribute | Relationship,
- omni.asset_validator.AuthoringLayers(
- prop: Property | Attribute | Relationship,
- omni.asset_validator.AuthoringLayers(primvar: Primvar) list[Layer]
- omni.asset_validator.AuthoringLayers(
- at_list: list[AtType],
- Parameters:
at (AtType | list[AtType]) – The location to compute the authoring layers.
- Returns:
The layers (from stronger to weaker) where the at is authored.
- class omni.asset_validator.BaseRuleChecker(
- verbose: bool,
- consumerLevelChecks: bool,
- assetLevelChecks: bool,
This is Base class for all the rule-checkers.
- Parameters:
verbose – Controls output (print) verbosity
consumerLevelChecks – Expands checks with coverage relevant to the public/community (eg limit file types)
assetLevelChecks – Expand checks with asset (top) level coverage
- CheckDependencies(usdStage, layerDeps, assetDeps)#
Check usdStage’s layer and asset dependencies that were gathered using UsdUtils.ComputeAllDependencies().
- CheckDiagnostics(diagnostics)#
Check the diagnostic messages that were generated when opening the USD stage. The diagnostic messages are collected using a UsdUtilsCoalescingDiagnosticDelegate.
- CheckLayer(layer)#
Check the given SdfLayer.
- CheckPrim(prim)#
Check the given prim, which may only exist is a specific combination of variant selections on the UsdStage.
- CheckStage(usdStage)#
Check the given usdStage.
- CheckUnresolvedPaths(unresolvedPaths)#
Check or process any unresolved asset paths that were found when analysing the dependencies.
- CheckZipFile(zipFile, packagePath)#
Check the zipFile object created by opening the package at path packagePath.
- classmethod GetDescription()#
Returns the docstring describing the rule.
- ResetCaches()#
Reset any caches the rule owns. Called whenever stage authoring occurs, such as when we iterate through VariantSet combinations.
- omni.asset_validator.CategoryRuleRegistry() None #
A singleton mutable registry of all rules grouped by categories.
- class omni.asset_validator.FixResult( )#
FixResult is a combination of input and output to the
IssueFixer
.- exception#
Optional. If the status is a Failure, it will contain the thrown exception.
- Type:
Exception
- class omni.asset_validator.FixStatus(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Result of fix status.
- FAILURE = 2#
A fix was applied, however it resulted into a failure (i.e. Exception). Check stack trace for more information.
- INVALID_LOCATION = 5#
A fix could not be performed as the location is no longer valid.
- NO_LAYER = 4#
A fix was applied at a specific layer, however the layer is not found in the layer stack.
- NO_LOCATION = 0#
A fix could not be performed as there was no location where to apply a suggestion.
- NO_SUGGESTION = 1#
A fix could not be performed as there was no suggestion to apply.
- SUCCESS = 3#
A fix was successfully applied.
- class omni.asset_validator.Identifier#
An Identifier is a stateful representation of an Usd object (i.e. Usd.Prim). A identifier can convert back to a live Usd object.
- classmethod from_(
- obj: AtType,
- Parameters:
obj (AtType) – An Usd Object.
- Returns:
A stateful representation of an Usd object.
- get_spec_ids() list[SpecId] #
- Returns:
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- restore(
- stage: Stage,
Convert this stateful identifier to a live object.
- Parameters:
stage (Usd.Stage) – The stage to use to restore the object.
- Returns:
An Usd object.
- class omni.asset_validator.Issue(
- message: str | None = None,
- severity: IssueSeverity | None = None,
- rule: RuleType | None = None,
- at: Identifier[AtType] | None = None,
- suggestion: Suggestion | None = None,
- asset: StageId | None = None,
- code: str | None = None,
- requirement: Requirement | None = None,
Issues capture information related to Validation Rules:
- message#
The reason this issue is mentioned.
- Type:
str | None
- severity#
The severity associated with the issue.
- Type:
IssueSeverity | None
- rule#
Optional. The class of rule detecting this issue.
- Type:
Type[BaseRuleChecker] | None
- at#
Optional. The Prim/Stage/Layer/SdfLayer/SdfPrim/etc.. where this issue arises.
- Type:
Identifier[AtType] | None
- suggestion#
Optional. The suggestion to apply. Suggestion evaluation (i.e. suggestion()) could raise exception, in which case they will be handled by IssueFixer and mark as failed.
- Type:
Suggestion | None
- code#
Optional. The code or identifierof the issue.
- Type:
str | None
- requirement#
Optional. The requirement that this issue belongs to. When requirement is provided, code and message are ignored.
- Type:
Requirement | None
The following exemplifies the expected arguments of an issue:
import omni.asset_validator class MyRule(BaseRuleChecker): pass stage = Usd.Stage.Open('foo.usd') prim = stage.GetPrimAtPath("/"); def my_suggestion(stage: Usd.Stage, at: Usd.Prim): pass issue = omni.asset_validator.Issue( identifier=SemanticLabelsRequirements.SL_001.code, message=SemanticLabelsRequirements.SL_001.message, severity=IssueSeverity.ERROR, rule=MyRule, at=stage, suggestion=Suggestion(my_suggestion, "A good suggestion"), )
- property default_fix_site: SpecId | None#
Returns: The default fix site. The default fix site is generally the Node at root layer. Rules can override this behavior by supplying
Suggestion.at
locations.
- classmethod none()#
Returns: Singleton object representing no Issue.
- class omni.asset_validator.IssueFixer(
- asset: str | ~pxr.Usd.Stage,
- layers: set[~pxr.Sdf.Layer] = <factory>,
Fixes issues for the given Asset.
- asset#
An in-memory Usd.Stage, either provided directly or opened from a URI pointing to a Usd layer file.
- Type:
Usd.Stage
import omni.asset_validator # validate a layer file engine = omni.asset_validator.ValidationEngine() results = engine.validate('foo.usd') issues = results.issues() # fix that layer file fixer = omni.asset_validator.IssueFixer('foo.usd') fixer.fix(issues) fixer.save() # fix a live stage directly stage = Usd.Stage.Open('foo.usd') engine = omni.asset_validator.ValidationEngine() results = engine.validate(stage) issues = results.issues() # fix that same stage in-memory fixer = omni.asset_validator.IssueFixer(stage) fixer.fix(issues) fixer.save()
- apply(
- issue: Issue,
- at: Identifier[AtType] | None = None,
Fix the specified issues persisting on a specific identifier. If no identifier is given, the default fix site is used.
- Parameters:
issue (Issue) – The issue to fix.
at (Identifier[AtType] | None) – Optional. Apply the changes in a different site.
- Returns:
An array with the resulting status (i.e. FixResult) of each issue.
- fix(
- issues: list[Issue],
Fix the specified issues in the default layer of each issue.
- Parameters:
issues (List[Issue]) – The list of issues to fix.
- Returns:
An array with the resulting status (i.e. FixResult) of each issue.
- fix_at(
- issues: list[Issue],
- layer: Layer,
Fix the specified issues persisting on a provided layer.
- Parameters:
issues (List[Issue]) – The list of issues to fix.
layer (Sdf.Layer) – Layer where to persist the changes.
- Returns:
An array with the resulting status (i.e. FixResult) of each issue.
- property fixed_layers: list[Layer]#
Returns: The layers affected by fix or fix_at methods.
- save() None #
Save the Asset to disk.
- Raises:
OSError – If writing permissions are not granted.
- class omni.asset_validator.IssueGroupBy(*args, **kwargs)#
An IssueGroupBy is a callable that returns a list linking an Issue to a specific group.
- class omni.asset_validator.IssueGroupsBy#
Convenient methods to group issues.
Examples
Group by messages.
import collections import omni.asset_validator issues = [ omni.asset_validator.Issue( severity=omni.asset_validator.IssueSeverity.ERROR, message="This is an error at Prim1", rule=omni.asset_validator.TypeChecker), omni.asset_validator.Issue( severity=omni.asset_validator.IssueSeverity.ERROR, message="This is an error at Prim2", rule=omni.asset_validator.TypeChecker), ] groups = set() for group, issue in omni.asset_validator.IssueGroupsBy.message()(issues): groups.add(group) print(groups)
Output
{'This is an error at .*'}
Groups by rule.
import collections import omni.asset_validator issues = [ omni.asset_validator.Issue( severity=omni.asset_validator.IssueSeverity.ERROR, message="This is an error at Prim1", rule=omni.asset_validator.TypeChecker), omni.asset_validator.Issue( severity=omni.asset_validator.IssueSeverity.ERROR, message="This is an error at Prim2", rule=omni.asset_validator.TypeChecker), ] groups = set() for group, issue in omni.asset_validator.IssueGroupsBy.rule()(issues): groups.add(group) print(groups)
Output
{<class 'omni.asset_validator.TypeChecker'>}
Groups by severity.
import collections import omni.asset_validator issues = [ omni.asset_validator.Issue( severity=omni.asset_validator.IssueSeverity.ERROR, message="This is an error at Prim1", rule=omni.asset_validator.TypeChecker), omni.asset_validator.Issue( severity=omni.asset_validator.IssueSeverity.ERROR, message="This is an error at Prim2", rule=omni.asset_validator.TypeChecker), ] groups = set() for group, issue in omni.asset_validator.IssueGroupsBy.severity()(issues): groups.add(group) print(groups)
{<IssueSeverity.ERROR: 0>}
- classmethod asset() IssueGroupBy #
Returns a list of tuples with the issue asset and the issue.
- classmethod code() IssueGroupBy #
Returns a list of tuples with the issue code and the issue.
- classmethod message() IssueGroupBy #
Returns a list of tuples with the issue message and the issue.
- classmethod requirement() IssueGroupBy #
Returns a list of tuples with the issue requirement and the issue.
- classmethod rule() IssueGroupBy #
Returns a list of tuples with the issue rule and the issue.
- classmethod rule_name() IssueGroupBy #
Returns a list of tuples with the issue rule name and the issue.
- classmethod severity() IssueGroupBy #
Returns a list of tuples with the issue severity and the issue.
- class omni.asset_validator.IssuePredicate(*args, **kwargs)#
An IssuePredicate is a callable that returns True or False for a specific Issue.
- Parameters:
issue (Issue) – The issue to check.
- Returns:
True if the issue matches the predicate, False otherwise.
- Return type:
(bool)
- class omni.asset_validator.IssuePredicates#
Convenient methods to filter issues. Additionally, provides
IssuePredicates.And()
andIssuePredicates.Or()
predicates to chain multiple predicates, see example below.import omni.asset_validator issues = [ omni.asset_validator.Issue( severity=omni.asset_validator.IssueSeverity.ERROR, message="This is an error"), omni.asset_validator.Issue( severity=omni.asset_validator.IssueSeverity.WARNING, message="Important warning!"), ] filtered = list(filter( omni.asset_validator.IssuePredicates.And( omni.asset_validator.IssuePredicates.IsError(), omni.asset_validator.IssuePredicates.ContainsMessage("Important"), ), issues ))
- static And(
- *predicates,
- Parameters:
predicates – One or more IssuePredicate.
- Returns:
A predicate joining predicates by
and
condition.
- static Any() IssuePredicate #
- Returns:
A dummy filter that does not filter.
- static ContainsMessage(
- text: str,
- Parameters:
text – A specific text to filter the message in issues.
- Returns:
A filter for messages containing
text
.
- static HasCode() IssuePredicate #
- Returns:
A filter for issues with requirement identifier.
- static HasFix() IssuePredicate #
- Returns:
A filter for issues with a fix.
- static HasLocation() IssuePredicate #
- Returns:
A filter for issues with location, i.e. at
- static HasRootLayer() IssuePredicate #
- Returns:
A filter for issues with a root layer.
- static HasTag(
- tag: str,
- Returns:
A filter for issues with specific tag.
- static IsError() IssuePredicate #
- Returns:
A filter for Issues marked as errors.
- static IsFailure() IssuePredicate #
- Returns:
A filter for Issues marked as failure.
- static IsInfo() IssuePredicate #
- Returns:
A filter for Issues marked as infos.
- static IsRule(
- rule: str | RuleType,
- Parameters:
rule (str | RuleType) – The rule to filter.
- Returns:
A filter for issues with the rule.
- static IsSuccess() IssuePredicate #
- Returns:
A filter for Issues marked as success, i.e. IssueSeverity.NONE.
- static IsWarning() IssuePredicate #
- Returns:
A filter for Issues marked as warnings.
- static MatchesAnyCode(
- codes: Sequence[str],
- Returns:
A filter for issues with matching code.
- static MatchesCode(
- code: str,
- Returns:
A filter for issues with matching code.
- static MatchesToken(
- token: str,
- Returns:
A filter for issues with matching token.
- static Not(
- predicate: IssuePredicate,
- Returns:
A predicate joining predicates by
not
condition.
- static Or(
- *predicates,
- Parameters:
predicates – One or more IssuePredicate.
- Returns:
A predicate joining predicates by
or
condition.
- class omni.asset_validator.IssueSeverity(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Defines the severity of an issue.
- ERROR = 0#
The issue is the result of an actual exception/failure in the code.
- FAILURE = 1#
An indication that it is failing to comply with a specific rule.
- INFO = 3#
Information that needs to be reported by the validation rules.
- NONE = 4#
No issue.
- WARNING = 2#
A warning is a suggestion to improve USD, it could be related to performance or memory.
- class omni.asset_validator.IssuesList(
- issues: list[~omni.asset_validator._issues.Issue] = <factory>,
- success: list[~omni.asset_validator._issues.Issue] = <factory>,
- name: ~typing.Any | None = None,
A list of issues, provides convenient features to filter/group by issues.
- name#
The name of the list.
- Type:
Any | None
- filter_by(
- predicate: IssuePredicate | None = None,
- Parameters:
predicate – The predicate to filter issues.
- Returns:
A subset of the issues for which the predicate is True.
- group_by(
- group_by: IssueGroupBy | None = None,
- Parameters:
group_by – A grouping function.
- Returns:
All groups generated by the grouping function.
- merge(
- other: IssuesList,
- Parameters:
other – Another issue group.
- Returns:
A new group that combines both existing groups.
- class omni.asset_validator.LayerId(identifier: str)#
A unique identifier to layer, i.e. identifier.
- identifier#
The unique identifier of this layer.
- Type:
str
- classmethod from_(
- layer: Layer,
- Parameters:
obj (AtType) – An Usd Object.
- Returns:
A stateful representation of an Usd object.
- get_spec_ids() list[SpecId] #
- Returns:
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- restore(stage: Stage) Layer #
Convert this stateful identifier to a live object.
- Parameters:
stage (Usd.Stage) – The stage to use to restore the object.
- Returns:
An Usd object.
- class omni.asset_validator.PrimId(
- stage_id: StageId,
- spec_ids: SpecIdList,
- variant_selection_path: Path = Sdf.Path.emptyPath,
A unique identifier of a prim, i.e. a combination of Stage definition and a list of Specs.
- spec_ids#
The list of specifications as found in the stage.
- Type:
- classmethod from_(
- prim: Prim,
- Parameters:
obj (AtType) – An Usd Object.
- Returns:
A stateful representation of an Usd object.
- get_spec_ids() list[SpecId] #
- Returns:
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- restore(stage: Stage) Prim #
Convert this stateful identifier to a live object.
- Parameters:
stage (Usd.Stage) – The stage to use to restore the object.
- Returns:
An Usd object.
- class omni.asset_validator.PropertyId(
- prim_id: PrimId,
- path: Path,
A unique identifier of a property, i.e. a combination of prim definition and property path.
- path#
The path to this property.
- Type:
Sdf.Path
- classmethod from_(
- prop: Property,
- Parameters:
obj (AtType) – An Usd Object.
- Returns:
A stateful representation of an Usd object.
- get_spec_ids() list[SpecId] #
- Returns:
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- restore(stage: Stage) Property #
Convert this stateful identifier to a live object.
- Parameters:
stage (Usd.Stage) – The stage to use to restore the object.
- Returns:
An Usd object.
- class omni.asset_validator.Requirement(*args, **kwargs)#
A protocol definition of requirement.
- code#
A unique identifier of the requirement
- Type:
str
- display_name#
The name of the requirement (optional)
- Type:
str | None
- message#
A basic description of the requirement (optional)
- Type:
str | None
- path#
Relative path in documentation (optional)
- Type:
str | None
- tags#
Tags of the requirement (optional)
- Type:
tuple[str, …]
- class omni.asset_validator.Results(
- asset: str,
- issues: list[~omni.asset_validator._issues.Issue] | ~omni.asset_validator._issues.IssuesList = <factory>,
A collection of
Issue
.Provides convenience mechanisms to filter
Issue
byIssuePredicates
.- asset#
The asset.
- Type:
str
- issues#
The issues.
- Type:
list[Issue] | IssuesList
- classmethod create(
- asset: Stage | str,
- issues: Sequence[Issue],
Convenience method. The only difference with constructor is that it will link the issues with the asset.
- Parameters:
asset (Usd.Stage | str) – The asset.
issues (List[Issue]) – A list of issues to associate with asset.
- Returns:
A new Results object.
- filter_by(
- predicate: IssuePredicate,
Filter the issues by the given predicate.
- class omni.asset_validator.SpecId(
- layer_id: LayerId,
- path: Path,
A snapshot of a Prim Specification.
- path#
The path to this specification.
- Type:
Sdf.Path
- classmethod from_(
- spec: Spec,
- Parameters:
obj (AtType) – An Usd Object.
- Returns:
A stateful representation of an Usd object.
- get_spec_ids() list[SpecId] #
- Returns:
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- restore(stage: Stage) Spec #
Convert this stateful identifier to a live object.
- Parameters:
stage (Usd.Stage) – The stage to use to restore the object.
- Returns:
An Usd object.
- class omni.asset_validator.SpecIdList(
- root_path: Path,
- spec_ids: list[SpecId],
A snapshot of a list of PcpNodeRefs.
- root_path#
The prim path in stage.
- Type:
Sdf.Path
- class omni.asset_validator.StageId(root_layer: LayerId)#
A unique identifier to stage, i.e. identifier.
- classmethod from_(
- stage: Stage,
- Parameters:
obj (AtType) – An Usd Object.
- Returns:
A stateful representation of an Usd object.
- get_spec_ids() list[SpecId] #
- Returns:
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- restore(stage: Stage) Stage #
Convert this stateful identifier to a live object.
- Parameters:
stage (Usd.Stage) – The stage to use to restore the object.
- Returns:
An Usd object.
- class omni.asset_validator.Suggestion(
- callable: Callable[[Stage, AtType], None],
- message: str,
- at: list[Identifier[AtType]] | None = None,
A suggestion is a combination of a callable and a message describing the suggestion.
- callable#
A proposed fix to an issue.
- Type:
Callable[[Usd.Stage, AtType], None]
- message#
A proposed solution to an issue.
- Type:
str
- at#
Optional. The Layer/SdfLayer/etc… where the issue can be fixed.
- Type:
List[Identifier[AtType]] | None
- class omni.asset_validator.ValidationEngine(*, init_rules: bool = True, variants: bool = True)#
An engine for running rule-checkers on a given OpenUSD Asset.
Rules are
BaseRuleChecker
derived classes which perform specific validation checks over various aspects of a USD layer/stage. Rules must be added through enable_rule. removed through disable_rule.Validation can be performed asynchronously (using either
validate_async()
orvalidate_with_callbacks()
) or blocking (viavalidate()
).Example
Construct an engine and validate several assets using the default-enabled rules:
import omni.asset_validator engine = omni.asset_validator.ValidationEngine() engine.enable_rule(MyRule) # Validate a single OpenUSD file print( engine.validate('foo.usd') ) # Search a folder and recursively validate all OpenUSD files asynchronously # note a running asyncio EvenLoop is required task = engine.validate_with_callbacks( 'bar/', asset_located_fn = lambda url: print(f'Validating "{url}"'), asset_validated_fn = lambda result: print(result), ) task.add_done_callback(lambda task: print('validate_with_callbacks complete')) # Perform the same search & validate but await the results import asyncio async def test(url): results = await engine.validate_async(url) for result in results: print(result) asyncio.ensure_future(test('bar/')) # Load a layer onto a stage and validate it in-memory, including any unsaved edits from pxr import Usd, Kind stage = Usd.Stage.Open('foo.usd') prim = stage.DefinePrim(f'{stage.GetDefaultPrim().GetPath()}/MyCube', 'cube') Usd.ModelAPI(prim).SetKind(Kind.Tokens.component) print( engine.validate(stage) )
- classmethod describe(asset: str | Stage) str #
- classmethod describe(asset: Stage) str
- classmethod describe(asset: str) str
Provides a description of an Asset.
- Parameters:
asset (AssetType) – A single Asset pointing to a file URI, folder/container URI, or a live Usd.Stage.
- Returns:
The str description of the asset that was validated.
- disable_rule(
- rule: type[BaseRuleChecker],
Disable a given rule on this engine.
This gives control to client code to disable rules one by one. Rules must be
BaseRuleChecker
derived classes.- Parameters:
rule (type[BaseRuleChecker]) – A BaseRuleChecker derived class to be enabled
- enable_capability(
- capability: Capability,
Enable a given capability on this engine.
This gives control to client code to enable capabilities one by one.
- Parameters:
capability (type[Capability]) – A Capability to be enabled
- enable_requirement(
- requirement: Requirement,
Enable a given requirement on this engine.
This gives control to client code to enable requirements one by one. Requirements must be
Requirement
enums, and should be registered with theRequirementsRegistry
before they are enabled on this engine.- Parameters:
requirement (Requirement) – A Requirement to be enabled
- enable_rule(
- rule: type[BaseRuleChecker],
Enable a given rule on this engine.
This gives control to client code to enable rules one by one. Rules must be
BaseRuleChecker
derived classes, and should be registered with theValidationRulesRegistry
before they are enabled on this engine.- Parameters:
rule (Type[BaseRuleChecker]) – A BaseRuleChecker derived class to be enabled
- property init_rules: bool#
Returns: Whether to initialize rules from
CategoryRuleRegistry()
.
- property initialized_rules: list[type[BaseRuleChecker]]#
Returns: A list of rules that have been initialized.
- classmethod is_asset_supported(
- asset: str | Stage,
- classmethod is_asset_supported(asset: None) bool
- classmethod is_asset_supported(asset: Stage) bool
- classmethod is_asset_supported(asset: str) bool
Determines if the provided asset can be validated by the engine.
- Parameters:
asset (AssetType) – A single Asset pointing to a file URI, folder/container URI, or a live Usd.Stage.
- Returns:
Whether the provided asset can be validated by the engine.
- property stats: ValidationStats#
Returns Statistics about each validation run.
- validate(
- asset: str | Stage,
Run the enabled rules on the given asset. (Blocking version)
Note
Validation of folders/container URIs is not supported in the blocking version. Use
validate_async()
orvalidate_with_callbacks()
to recursively validate a folder.- Parameters:
asset (AssetType) – A single Asset pointing to a file URI or a live Usd.Stage.
- Returns:
All issues reported by the enabled rules.
- async validate_async(
- asset: str | Stage,
Asynchronously run the enabled rules on the given asset. (Concurrent Version)
If the asset is a folder/container URI it will be recursively searched for individual asset files and each applicable URI will be validated, with all results accumulated and indexed alongside the respective asset.
Note
Even a single asset will return a list of
Results
, so it must be indexed via results[0].asset, results[0].failures, etc- Parameters:
asset (AssetType) – A single Asset. Note this can be a file URI, folder/container URI,
Usd.Stage. (or a live)
- Returns:
All issues reported by the enabled rules, index aligned with their respective asset.
- validate_with_callbacks(
- asset: str | Stage,
- asset_located_fn: AssetLocatedCallback | None = None,
- asset_validated_fn: AssetValidatedCallback | None = None,
- asset_progress_fn: AssetProgressCallback | None = None,
Asynchronously run the enabled rules on the given asset. (Callbacks Version)
If the asset is validate-able (e.g. a USD layer file), asset_located_fn will be invoked before validation begins. When validation completes, asset_validated_fn will be invoked with the results.
If the asset is a folder/container URI it will be recursively searched for individual asset files and each applicable URL will be validated, with asset_located_fn and asset_validated_fn being invoked once per validate-able asset.
- Parameters:
asset – A single Asset. Note this can be a file URI, folder/container URI, or a live Usd.Stage.
asset_located_fn – A callable to be invoked upon locating an individual asset. If asset is a single validate-able asset (e.g. a USD layer file) asset_located_fn will be called once. If asset is a folder/container URI asset_located_fn will be called once per validate-able asset within the container (e.g. once per USD layer file). Signature must be cb(AssetType) where str is the url of the located asset.
asset_validated_fn – A callable to be invoked when validation of an individual asset has completed. If asset is itself a single validate-able asset (e.g. a USD layer file) asset_validated_fn will be called once. If asset is a folder/container asset_validated_fn will be called once per validate-able asset within the container (e.g. once per USD layer file). Signature must be cb(results).
asset_progress_fn – A callable to be invoked when validation of an individual asset is running.
- Returns:
A task to control execution.
- property variants: bool#
Returns: Whether to process all variants.
- class omni.asset_validator.ValidationNamespaceExec(namespace: Namespace)#
Uses Argument Parser Namespace to run validation. Useful for CLI tools.
- property asset: str | None#
Returns: The asset option value.
- property capabilities: list[Capability]#
Returns: The capabilities option value.
- property category_rules: list[type[BaseRuleChecker]]#
Returns: The category options value.
- property csv_output: str | None#
Returns: The csv-output option value.
- property disable_category_rules: list[type[BaseRuleChecker]]#
Returns: The disable_category option value.
- property disabled_rules: list[type[BaseRuleChecker]]#
Returns: The disable_rules option value.
- property enabled_category_rules: list[type[BaseRuleChecker]]#
Returns: The enable_category options value.
- property enabled_rules: list[type[BaseRuleChecker]]#
Returns: The enable_rules option value.
- property fix: bool#
Returns: The fix option value.
- property init_rules: bool#
Returns: The init_rules option value.
- property requirements: list[Requirement]#
Returns: The requirements option value.
- property rules: list[type[BaseRuleChecker]]#
Returns: The rules option value.
- property variants: bool#
Returns: The variants option value.
- omni.asset_validator.create_validation_parser() ArgumentParser #
Creates an argument parser with common options, this includes:
For ValidationEngine:
init-rules/no-init-rules: Optional. Default True. Sets ValidationEngine, init_rules argument.
variants/no-variants: Optional. Default True. Sets ValidationEngine, variants argument.
rule/disable-rule: Optional. Enables/Disable rules in ValidationEngine.
category/disable-category. Optional. Enable/Disable categories in ValidationEngine.
asset. Required. The asset in which to perform validation.
enable-rule and enable-category are alias for rule and category respectively.
For IssueFixer:
predicate: Optional. Issues to filter for IssueFixer.
fix/no-fix: Optional. Whether to apply IssueFixer after ValidationEngine.
Other options: - version: Print the version of omni.asset_validator.
- omni.asset_validator.default_implementation(function: LambdaType)#
A single dispatch for multiple distributions. Example:
@default_implementation def compute_value(...): ... @compute_value.numpy def _(...): import numpy as np ... # if numpy is installed will get the numpy implementation. result = compute_value(...)
- omni.asset_validator.get_version()#
- Returns
The version of this module.
omni.asset_validator.tests API#
- class omni.asset_validator.tests.AsyncioValidationTestCaseMixin#
A mixin for asyncio test cases to simplify testing of individual Validation Rules.
Example
from unittest import IsolatedAsyncioTestCase from omni.asset_validator.tests import AsyncioValidationTestCaseMixin class AsyncioValidationTestCase(IsolatedAsyncioTestCase, AsyncioValidationTestCaseMixin): ... class MyTestCase(AsyncioValidationTestCase): async def testMyRuleChecker(self): await self.assertRuleAsync( asset='example.usd', rule=MyRuleChecker, asserts=[ IsAFailure("Prim.*has unsupported type.*"), ] )
- async assertCapabilityAsync(
- *,
- asset: str | Stage,
- capability: Capability,
- asserts: list[IsAnIssue],
Same as assertCapability, but for async tests.
- async assertFailureAsync(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
- predicate: IssuePredicate | None = None,
Same as assertFailure, but for async tests.
- async assertIssuesAsync(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
- asserts: list[IsAnIssue],
Same as assertIssues, but for async tests.
- async assertRequirementAsync(
- *,
- asset: str | Stage,
- requirement: Requirement,
- asserts: list[IsAnIssue],
Same as assertRequirement, but for async tests.
- async assertRuleAsync(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker],
- asserts: list[IsAnIssue],
Same as assertRule, but for async tests.
- async assertSuccessAsync(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
- predicate: IssuePredicate | None = None,
Same as assertSuccess, but for async tests.
- async assertSuggestionAsync(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
- predicate: IssuePredicate | None = None,
Same as assertSuggestion, but for async tests.
- async validateAsync(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
Validate the asset using the rule.
- class omni.asset_validator.tests.Failure(**kwargs)#
- class omni.asset_validator.tests.IsAFailure(
- message: str | Pattern | None = None,
- at: str | Path | None = None,
- code: str | None = None,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- severity: IssueSeverity = IssueSeverity.FAILURE,
IsAFailure let us assert messages and locations of failure to match against the real issue found in Validation Engine. This class is used in conjuntion to ValidationRuleTestCase.assertRule.
- message#
Regex pattern for the expected failure message.
- Type:
str | re.Pattern | None
- at#
Optional. The expected location of the expected failure.
- Type:
str | pxr.Sdf.Path | None
- class omni.asset_validator.tests.IsAWarning(
- message: str | Pattern | None = None,
- at: str | Path | None = None,
- code: str | None = None,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- severity: IssueSeverity = IssueSeverity.WARNING,
IsAWarning let us assert messages and locations of warnings to match against the real issue found in Validation Engine. This class is used in conjuntion to ValidationRuleTestCase.assertRule.
- message#
Regex pattern for the expected failure message.
- Type:
str | re.Pattern | None
- at#
Optional. The expected location of the expected failure.
- Type:
str | pxr.Sdf.Path | None
- class omni.asset_validator.tests.IsAnError(
- message: str | Pattern | None = None,
- at: str | Path | None = None,
- code: str | None = None,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- severity: IssueSeverity = IssueSeverity.ERROR,
IsAnError let us assert messages and locations of errors to match against the real issue found in Validation Engine. This class is used in conjuntion to ValidationRuleTestCase.assertRule.
- message#
Regex pattern for the expected failure message.
- Type:
str | re.Pattern | None
- at#
Optional. The expected location of the expected failure.
- Type:
str | pxr.Sdf.Path | None
- class omni.asset_validator.tests.IsAnInfo(
- message: str | Pattern | None = None,
- at: str | Path | None = None,
- code: str | None = None,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- severity: IssueSeverity = IssueSeverity.INFO,
IsAnInfo let us assert messages and locations of infos to match against the real info found in Validation Engine. This class is used in conjuntion to ValidationRuleTestCase.assertRule.
- message#
Regex pattern for the expected info message.
- Type:
str | re.Pattern | None
- at#
Optional. The expected location of the expected info.
- Type:
str | pxr.Sdf.Path | None
- class omni.asset_validator.tests.IsAnIssue(
- message: str | Pattern | None = None,
- at: str | Path | None = None,
- code: str | None = None,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- severity: IssueSeverity = IssueSeverity.INFO,
IsAnIssue let us assert severity, message and locations of issues to match against the real issues found in Validation Engine. Use
IsAFailure
,IsAWarning
andIsAnError
instead.- Parameters:
message – The expected message of the issue.
at – Optional. The expected location of the issue.
code – Optional. The expected code of the issue.
requirement – Optional. The expected requirement of the issue.
severity – Optional. The expected severity of the issue.
- class omni.asset_validator.tests.ValidationTestCaseMixin#
A mixin for test cases to simplify testing of individual Validation Rules.
Example
from unittest import TestCase from omni.asset_validator.tests import ValidationTestCaseMixin class ValidationTestCase(TestCase, ValidationTestCaseMixin): ... class MyTestCase(ValidationTestCase): def testMyRuleChecker(self): self.assertRule( asset='example.usd', rule=MyRuleChecker, asserts=[ IsAFailure("Prim.*has unsupported type.*"), ] )
- assertCapability(
- *,
- asset: str | Stage,
- capability: Capability,
- asserts: list[IsAnIssue],
Assert issues from validating one asset using one capability
- assertFailure(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
- predicate: IssuePredicate | None = None,
Assert that the asset is validated with failures.
- assertIssues(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
- asserts: list[IsAnIssue],
Assert issues from validating one asset using either a rule, requirement or capability.
Derived classes may use this to simplify testing of new rules with less consideration for the structure of omni.asset_validator.Results.
Note there will be only one enabled rule for the validation run, so all results will have necessarily been produced by the provided rule or by the engine itself (eg non-existent file).
- Parameters:
asset – A single asset to validate
rule – Either a BaseRuleChecker derived class or the str class name of such a class
asserts – A list of assertions.
- assertRequirement(
- *,
- asset: str | Stage,
- requirement: Requirement,
- asserts: list[IsAnIssue],
Assert issues from validating one asset using one requirement
- assertRule(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker],
- asserts: list[IsAnIssue],
Assert issues from validating one asset using one rule
- assertSuccess(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
- predicate: IssuePredicate | None = None,
Assert that the asset is validated successfully.
- assertSuggestion(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
- predicate: IssuePredicate | None = None,
Assert expected failures from validating one asset using one rule will be fixed using auto fix framework.
Derived classes may use this to simplify testing of new rules with less consideration for the structure of omni.asset_validator.IssueFixer.
Note there will be only one enabled rule for the validation run, so all results will have necessarily been produced by the provided rule or by the engine itself (eg non-existent file).
- Parameters:
asset – A single asset to validate
rule – Either a BaseRuleChecker derived class or the str class name of such a class
predicate – A predicate (i.e. Callable[[Issue], bool]) to filter out issues.
- validate(
- *,
- asset: str | Stage,
- rule: type[BaseRuleChecker] | None = None,
- requirement: Requirement | None = None,
- capability: Capability | None = None,
Validate the asset using the rule.
- Parameters:
asset – The asset to validate.
rule – The rule to use for validation.
- Returns:
The results of the validation.