omni.asset_validator API

class omni.asset_validator.AssetType

A typedef for the assets that ValidationEngine can process. When it is a str, it is expected to be an URI that can be accessed. When it is a Usd.Stage, it will be validated directly without ever locating a file on disk/server. Note using a live Stage necessarily bypasses some validations (i.e. file I/O checks)

class omni.asset_validator.AssetLocatedCallback

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

A typedef for the notification of asset results found during ValidationEngine.validate_with_callbacks().

Parameters

results (Results) – The results for a specific asset.

class omni.asset_validator.AssetProgressCallback

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

Location of an issue or a fix.

Can be any of:
  • pxr.Sdf.Layer

  • pxr.Usd.Stage

  • pxr.Usd.Prim

  • pxr.Usd.Property

  • pxr.Usd.Attribute

  • pxr.Usd.Relationship

  • pxr.Usd.SchemaBase

  • pxr.UsdGeom.Primvar

  • pxr.Sdf.PrimSpec

  • pxr.Sdf.PropertySpec

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

classmethod GetDescription()

Returns the docstring describing the rule.

CheckStage(usdStage)

Check the given usdStage.

CheckDiagnostics(diagnostics)

Check the diagnostic messages that were generated when opening the USD stage. The diagnostic messages are collected using a UsdUtilsCoalescingDiagnosticDelegate.

CheckUnresolvedPaths(unresolvedPaths)

Check or process any unresolved asset paths that were found when analysing the dependencies.

CheckDependencies(usdStage, layerDeps, assetDeps)

Check usdStage’s layer and asset dependencies that were gathered using UsdUtils.ComputeAllDependencies().

CheckLayer(layer)

Check the given SdfLayer.

CheckZipFile(zipFile, packagePath)

Check the zipFile object created by opening the package at path packagePath.

CheckPrim(prim)

Check the given prim, which may only exist is a specific combination of variant selections on the UsdStage.

ResetCaches()

Reset any caches the rule owns. Called whenever stage authoring occurs, such as when we iterate through VariantSet combinations.

class omni.asset_validator.CategoryRuleRegistry(_rules: typing.Dict[str, typing.List[typing.Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]] = <factory>)

A registry of all rules grouped by categories. The global registry is managed by get_category_rules_registry().

property categories: Sequence[str]

An immutable list of categories.

property rules: Sequence[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]

An immutable list of rules.

add(category: str, rule: Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]) None

Associate a rule to a specific category. If the rule was associated to a previous category, it is removed and added into the new category.

Parameters
  • category (str) – The category to associate to the rule.

  • rule (Type[BaseRuleChecker]) – The rule class.

clear() None

Clears the registry.

get_rules(category: str) Set[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]

Get the rules associated to a specific category in the registry.

Parameters

category – The category in the registry.

Returns

The rules associated to the category.

remove(rule: Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]) None

Removes a rule from the registry.

Parameters

rule – The rule to remove from the registry.

find_rule(rule_name: str) Optional[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]
Returns

Find rule by name. Returns None otherwise.

get_category(rule: Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]) Optional[str]

Returns the category under the rule is associated.

Parameters

rule – The rule in the registry.

Returns

The category under the rule is associated. Returns None if the rule is not registered.

omni.asset_validator.create_validation_parser() argparse.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.get_category_rules_registry() omni.asset_validator.registry.CategoryRuleRegistry
Returns

A singleton mutable category rule registry. By default, this includes all rules found in this module except ARKit.

omni.asset_validator.get_version()
Returns

The version of this module.

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: omni.asset_validator.identifiers.AtType) omni.asset_validator.identifiers.Identifier[omni.asset_validator.identifiers.AtType]
Parameters

obj (AtType) – An Usd Object.

Returns

A stateful representation of an Usd object.

restore(stage: pxr.Usd.Stage) omni.asset_validator.identifiers.AtType

Convert this stateful identifier to a live object.

Parameters

stage (Usd.Stage) – The stage to use to restore the object.

Returns

An Usd object.

as_str() str
Returns

Pretty print representation of this object. Useful for testing.

get_layer_ids() List[omni.asset_validator.identifiers.LayerId]

Deprecated since version 0.13.2: Use get_spec_ids.

get_spec_ids() List[omni.asset_validator.identifiers.SpecId]
Returns

The list of all possible prim specs i.e., path and layer ids associated to this identifier.

class omni.asset_validator.Issue(message: str, severity: omni.asset_validator.issues.IssueSeverity, rule: Optional[omni.asset_validator.issues.RuleType] = None, at: Optional[omni.asset_validator.identifiers.Identifier[omni.asset_validator.identifiers.AtType]] = None, suggestion: Optional[omni.asset_validator.issues.Suggestion] = None, asset: Optional[omni.asset_validator.identifiers.StageId] = None)

Issues capture information related to Validation Rules:

message

The reason this issue is mentioned.

Type

str

severity

The severity associated with the issue.

Type

IssueSeverity

rule

Optional. The class of rule detecting this issue.

Type

Optional[Type[BaseRuleChecker]]

at

Optional. The Prim/Stage/Layer/SdfLayer/SdfPrim/etc.. where this issue arises.

Type

Optional[Identifier[AtType]]

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

Optional[Suggestion]

asset

Optional. The asset where this Issue happens.

Type

Optional[StageId]

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(
    message="The reason this issue is mentioned",
    severity=IssueSeverity.ERROR,
    rule=MyRule,
    at=stage,
    suggestion=Suggestion(my_suggestion, "A good suggestion"),
)
classmethod from_message(severity: omni.asset_validator.issues.IssueSeverity, message: str) omni.asset_validator.issues.Issue

Deprecated since version 0.4.0: Use Issue constructor.

classmethod from_(severity: omni.asset_validator.issues.IssueSeverity, rule: omni.asset_validator.issues.RuleType, message: str) omni.asset_validator.issues.Issue

Deprecated since version 0.4.0: Use Issue constructor.

classmethod none()

Returns: Singleton object representing no Issue.

property all_fix_sites: List[omni.asset_validator.identifiers.SpecId]

Returns: A list of all possible fix sites.

property default_fix_site: Optional[omni.asset_validator.identifiers.SpecId]

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.

class omni.asset_validator.IssuePredicate

An IssuePredicate is a callable that returns True or False for a specific Issue.

class omni.asset_validator.IssuePredicates

Convenient methods to filter issues. Additionally, provides IssuePredicates.And() and IssuePredicates.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 Any() omni.asset_validator.issues.IssuePredicate
Returns

A dummy filter that does not filter.

static IsFailure() omni.asset_validator.issues.IssuePredicate
Returns

A filter for Issues marked as failure.

static IsWarning() omni.asset_validator.issues.IssuePredicate
Returns

A filter for Issues marked as warnings.

static IsError() omni.asset_validator.issues.IssuePredicate
Returns

A filter for Issues marked as errors.

static IsInfo() omni.asset_validator.issues.IssuePredicate
Returns

A filter for Issues marked as infos.

static ContainsMessage(text: str) omni.asset_validator.issues.IssuePredicate
Parameters

text – A specific text to filter the message in issues.

Returns

A filter for messages containing text.

static HasLocation() omni.asset_validator.issues.IssuePredicate
Returns

A filter for issues with location, i.e. at

static And(*predicates) omni.asset_validator.issues.IssuePredicate
Parameters

predicates – One or more IssuePredicate.

Returns

A predicate joining predicates by and condition.

static Or(*predicates) omni.asset_validator.issues.IssuePredicate
Parameters

predicates – One or more IssuePredicate.

Returns

A predicate joining predicates by or condition.

class omni.asset_validator.IssueGroupBy

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>}
class omni.asset_validator.IssuesList(issues: typing.List[omni.asset_validator.issues.Issue] = <factory>, success: typing.List[omni.asset_validator.issues.Issue] = <factory>, name: typing.Optional[typing.Any] = None)

A list of issues, provides convenient features to filter/group by issues.

filter_by(predicate: Optional[omni.asset_validator.issues.IssuePredicate] = None) omni.asset_validator.issues.IssuesList
Parameters

predicate – The predicate to filter issues.

Returns

A subset of the issues for which the predicate is True.

group_by(group_by: Optional[omni.asset_validator.issues.IssueGroupBy] = None) List[omni.asset_validator.issues.IssuesList]
Parameters

group_by – A grouping function.

Returns

All groups generated by the grouping function.

merge(other: omni.asset_validator.issues.IssuesList) omni.asset_validator.issues.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: pxr.Sdf.Layer) omni.asset_validator.identifiers.LayerId
Parameters

obj (AtType) – An Usd Object.

Returns

A stateful representation of an Usd object.

restore(stage: pxr.Usd.Stage) pxr.Sdf.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.

get_spec_ids() List[omni.asset_validator.identifiers.SpecId]
Returns

The list of all possible prim specs i.e., path and layer ids associated to this identifier.

as_str()
Returns

Pretty print representation of this object. Useful for testing.

class omni.asset_validator.Results(asset: str, issues: typing.Union[typing.List[omni.asset_validator.issues.Issue], omni.asset_validator.issues.IssuesList] = <factory>)

A collection of Issue.

Provides convenience mechanisms to filter Issue by IssuePredicates.

classmethod create(asset: Union[pxr.Usd.Stage, str], issues: Sequence[omni.asset_validator.issues.Issue]) omni.asset_validator.results.Results

Convenience method. The only difference with constructor is that it will link the issues with the asset.

Parameters
  • asset (Union[Usd.Stage, str]) – The asset.

  • issues (List[Issue]) – A list of issues to associate with asset.

Returns

A new Results object.

class omni.asset_validator.StageId(root_layer: omni.asset_validator.identifiers.LayerId)

A unique identifier to stage, i.e. identifier.

root_layer

Identifier representing the root layer.

Type

LayerId

classmethod from_(stage: pxr.Usd.Stage) omni.asset_validator.identifiers.StageId
Parameters

obj (AtType) – An Usd Object.

Returns

A stateful representation of an Usd object.

property identifier: str

Deprecated since version 0.4.0: Use StageId.root_layer attribute.

restore(stage: pxr.Usd.Stage) pxr.Usd.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.

as_str() str
Returns

Pretty print representation of this object. Useful for testing.

get_spec_ids() List[omni.asset_validator.identifiers.SpecId]
Returns

The list of all possible prim specs i.e., path and layer ids associated to this identifier.

class omni.asset_validator.SpecId(layer_id: omni.asset_validator.identifiers.LayerId, path: pxr.Sdf.Path)

A snapshot of a Prim Specification.

layer_id

The layer where this identifier exists.

Type

LayerId

path

The path to this specification.

Type

Sdf.Path

classmethod from_(spec: pxr.Sdf.Spec) omni.asset_validator.identifiers.SpecId
Parameters

obj (AtType) – An Usd Object.

Returns

A stateful representation of an Usd object.

restore(stage: pxr.Usd.Stage) pxr.Sdf.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.

get_spec_ids() List[omni.asset_validator.identifiers.SpecId]
Returns

The list of all possible prim specs i.e., path and layer ids associated to this identifier.

as_str() str
Returns

Pretty print representation of this object. Useful for testing.

class omni.asset_validator.SpecIdList(root_path: pxr.Sdf.Path, spec_ids: List[omni.asset_validator.identifiers.SpecId])

A snapshot of a list of PcpNodeRefs.

root_path

The prim path in stage.

Type

Sdf.Path

spec_ids

The list of prim specifications.

Type

List[SpecId]

class omni.asset_validator.PrimId(stage_id: omni.asset_validator.identifiers.StageId, spec_ids: omni.asset_validator.identifiers.SpecIdList, variant_selection_path: pxr.Sdf.Path = Sdf.Path.emptyPath)

A unique identifier of a prim, i.e. a combination of Stage definition and a list of Specs.

stage_id

An identifier to the stage this prim exists.

Type

StageId

spec_ids

The list of specifications as found in the stage.

Type

SpecIdList

classmethod from_(prim: pxr.Usd.Prim) omni.asset_validator.identifiers.PrimId
Parameters

obj (AtType) – An Usd Object.

Returns

A stateful representation of an Usd object.

restore(stage: pxr.Usd.Stage) pxr.Usd.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.

as_str() str
Returns

Pretty print representation of this object. Useful for testing.

get_spec_ids() List[omni.asset_validator.identifiers.SpecId]
Returns

The list of all possible prim specs i.e., path and layer ids associated to this identifier.

class omni.asset_validator.PropertyId(prim_id: omni.asset_validator.identifiers.PrimId, path: pxr.Sdf.Path)

A unique identifier of a property, i.e. a combination of prim definition and property path.

prim_id

(PrimId) An identifier to the prim containing this property.

Type

omni.asset_validator.identifiers.PrimId

path

The path to this property.

Type

Sdf.Path

classmethod from_(prop: pxr.Usd.Property) omni.asset_validator.identifiers.PropertyId
Parameters

obj (AtType) – An Usd Object.

Returns

A stateful representation of an Usd object.

restore(stage: pxr.Usd.Stage) pxr.Usd.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.

as_str() str
Returns

Pretty print representation of this object. Useful for testing.

get_spec_ids() List[omni.asset_validator.identifiers.SpecId]
Returns

The list of all possible prim specs i.e., path and layer ids associated to this identifier.

class omni.asset_validator.IssueSeverity(value)

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 a specific Fule.

WARNING = 2

A warning is a suggestion to improve USD, it could be related to performance or memory.

INFO = 3

Information that needs to be reported by the validation rules.

NONE = 4

No issue.

class omni.asset_validator.PatternTree(root: omni.asset_validator.expression.PatternNode = <factory>)

A tree of patterns. The root of a pattern tree is a Wildcard (i.e. .*), the leaves are Literal expressions ( i.e. do not contain Wildcards). The further down in the tree the more specific the patterns are.

insert(message: str) None
Parameters

message – The message to insert into the pattern tree.

as_dict() Dict[str, List[str]]
Returns

Internal method to return this tree as a python dict.

class omni.asset_validator.Suggestion(callable: Callable[[pxr.Usd.Stage, omni.asset_validator.identifiers.AtType], None], message: str, at: Optional[List[omni.asset_validator.identifiers.Identifier[omni.asset_validator.identifiers.AtType]]] = 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

Optional[List[Identifier[AtType]]]

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() or validate_with_callbacks()) or blocking (via validate()).

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) )
property init_rules: bool

Returns: Whether to initialize rules from get_category_rules_registry().

property variants: bool

Returns: Whether to process all variants.

classmethod is_asset_supported(asset: omni.asset_validator.assets.AssetType) 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.

classmethod describe(asset: omni.asset_validator.assets.AssetType) 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.

enable_rule(rule: Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]) None

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 the ValidationRulesRegistry before they are enabled on this engine.

Parameters

rule (Type[BaseRuleChecker]) – A BaseRuleChecker derived class to be enabled

disable_rule(rule: Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]) None

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

classmethod is_uri_found(identifier: str) bool
Parameters

identifier – An asset identifier or Prefix identifier.

Returns

True if asset exists.

classmethod is_uri_prefix(identifier: str) bool
Parameters

identifier – The asset identifier.

Returns

True if it may contain multiple assets, i.e. folder.

classmethod list_uris(prefix: str) List[str]
Parameters

prefix

Returns

A list of resources under this asset prefix.

validate(asset: omni.asset_validator.assets.AssetType) omni.asset_validator.results.Results

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() or validate_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: omni.asset_validator.assets.AssetType) omni.asset_validator.results.ResultsList

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: omni.asset_validator.assets.AssetType, asset_located_fn: Optional[omni.asset_validator.assets.AssetLocatedCallback] = None, asset_validated_fn: Optional[omni.asset_validator.assets.AssetValidatedCallback] = None, asset_progress_fn: Optional[omni.asset_validator.assets.AssetProgressCallback] = None) _asyncio.Task

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 stats: omni.asset_validator.stats.ValidationStats

Returns Statistics about each validation run.

enableRule(rule: Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]) None

Deprecated since version 0.11.5: Use ValidationEngine.enable_rule().

disableRule(rule: Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]) None

Deprecated since version 0.11.5: Use ValidationEngine.disable_rule().

classmethod isAssetSupported(asset: omni.asset_validator.assets.AssetType) bool

Deprecated since version 0.11.5: Use ValidationEngine.is_asset_supported().

class omni.asset_validator.ValidationNamespaceExec(namespace: argparse.Namespace)

Uses Argument Parser Namespace to run validation. Useful for CLI tools.

property variants: bool

Returns: The variants option value.

property init_rules: bool

Returns: The init_rules option value.

property asset: Optional[str]

Returns: The asset option value.

property fix: bool

Returns: The fix option value.

property rules: List[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]

Returns: The rules option value.

property enabled_rules: List[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]

Returns: The enable_rules option value.

property disabled_rules: List[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]

Returns: The disable_rules option value.

property category_rules: List[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]

Returns: The category options value.

property enabled_category_rules: List[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]

Returns: The enable_category options value.

property disable_category_rules: List[Type[omni.asset_validator.base_rule_checker.BaseRuleChecker]]

Returns: The disable_category option value.

property csv_output: Optional[str]

Returns: The csv-output option value.

class omni.asset_validator.FixStatus(value)

Result of fix status.

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.

FAILURE = 2

A fix was applied, however it resulted into a failure (i.e. Exception). Check stack trace for more information.

SUCCESS = 3

A fix was successfully applied.

NO_LAYER = 4

A fix was applied at a specific layer, however the layer is not found in the layer stack.

INVALID_LOCATION = 5

A fix could not be performed as the location is no longer valid.

class omni.asset_validator.FixResult(issue: omni.asset_validator.issues.Issue, status: omni.asset_validator.fix.FixStatus, exception: Optional[Exception] = None)

FixResult is a combination of input and output to the IssueFixer.

issue

The issue originating this result. Useful for back tracing.

Type

Issue

status

The status of processing the issue, See FixStatus.

Type

FixStatus

exception

Optional. If the status is a Failure, it will contain the thrown exception.

Type

Exception

class omni.asset_validator.IssueFixer(asset: omni.asset_validator.assets.AssetType, layers: typing.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.core

# validate a layer file
engine = omni.asset_validator.core.ValidationEngine()
results = engine.validate('omniverse://localhost/NVIDIA/Samples/Astronaut/Astronaut.usd')
issues = results.issues()

# fix that layer file
fixer = omni.asset_validator.core.IssueFixer('omniverse://localhost/NVIDIA/Samples/Astronaut/Astronaut.usd')
fixer.fix(issues)
fixer.save()

# fix a live stage directly
stage = Usd.Stage.Open('omniverse://localhost/NVIDIA/Samples/Astronaut/Astronaut.usd')
engine = omni.asset_validator.core.ValidationEngine()
results = engine.validate(stage)
issues = results.issues()

# fix that same stage in-memory
fixer = omni.asset_validator.core.IssueFixer(stage)
fixer.fix(issues)
fixer.save()
apply(issue: omni.asset_validator.issues.Issue, at: Optional[omni.asset_validator.identifiers.Identifier[omni.asset_validator.identifiers.AtType]] = None) omni.asset_validator.fix.FixResult

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 (Optional[Identifier[AtType]]) – Optional. Apply the changes in a different site.

Returns

An array with the resulting status (i.e. FixResult) of each issue.

fix(issues: List[omni.asset_validator.issues.Issue]) Sequence[omni.asset_validator.fix.FixResult]

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[omni.asset_validator.issues.Issue], layer: pxr.Sdf.Layer) Sequence[omni.asset_validator.fix.FixResult]

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[pxr.Sdf.Layer]

Returns: The layers affected by fix or fix_at methods.

save() None

Save the Asset to disk.

Raises

IOError – If writing permissions are not granted.

omni.asset_validator.AuthoringLayers(at: Union[omni.asset_validator.identifiers.AtType, List[omni.asset_validator.identifiers.AtType]]) List[pxr.Sdf.Layer]
Parameters

at (Union[AtType, List[AtType]]) – The location to compute the authoring layers.

Returns

The layers (from stronger to weaker) where the at is authored.