omni.asset_validator.core API
- class omni.asset_validator.core.AssetType
A typedef for the assets that ValidationEngine can process. When it is a str, it is expected to be an Omniverse URI that can be accessed via the Omni Client Library. 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.core.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.core.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.core.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.core.ValidationEngine(initRules: bool = True, variants: bool = True)
An engine for running rule-checkers on a given Omniverse Asset.
Rules are
BaseRuleChecker
derived classes which perform specific validation checks over various aspects of a USD layer/stage. Rules must be registered with theValidationRulesRegistry
and subsequently enabled on each instance of theValidationEngine
.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.core engine = omni.asset_validator.core.ValidationEngine() # Validate a single Omniverse file print( engine.validate('omniverse://localhost/NVIDIA/Samples/Astronaut/Astronaut.usd') ) # Validate a local file on disk. Windows paths must be pre-converted to Omniverse compatible paths import omni.client ( status, localFile ) = omni.client.get_local_file('C:\\Users\\Public\\Documents\\test.usda') if status == omni.client.Result.OK : print( engine.validate(localFile) ) # Search an Omniverse folder and recursively validate all USD files asynchronously # note a running asyncio EvenLoop is required task = engine.validate_with_callbacks( 'omniverse://localhost/NVIDIA/Assets/ArchVis/Industrial/Containers/', 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('omniverse://localhost/NVIDIA/Assets/ArchVis/Industrial/Containers/')) # Load a a layer onto a stage and validate it in-memory, including any unsaved edits from pxr import Usd, Kind stage = Usd.Stage.Open('omniverse://localhost/NVIDIA/Samples/Astronaut/Astronaut.usd') prim = stage.DefinePrim(f'{stage.GetDefaultPrim().GetPath()}/MyCube', 'cube') Usd.ModelAPI(prim).SetKind(Kind.Tokens.component) print( engine.validate(stage) ) # Validate the current stage in any Kit based app (eg Create, View) import omni.usd print( engine.validate( omni.usd.get_context().get_stage() ) )
- Parameters
initRules – Flag to default-enable Rules on this engine based on carb settings. Clients may wish to opt-out of this behavior to gain finer control over rule enabling at runtime.
- static isAssetSupported(asset: omni.asset_validator.core.engine.AssetType) bool
Determines if the provided asset can be validated by the engine.
- Parameters
asset (AssetType) – A single Omniverse 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.
- static describe(asset: omni.asset_validator.core.engine.AssetType) str
Provides a description of an Omniverse Asset.
- Parameters
asset (AssetType) – A single Omniverse Asset pointing to a file URI, folder/container URI, or a live Usd.Stage.
- Returns
The str description of the asset that was validated.
- enableRule(rule: Type[omni.asset_validator.core.complianceChecker.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 theValidationRulesRegistry
before they are enabled on this engine.Note many rules may have been pre-enabled if the engine was default-constructed with initRules=True.
- Parameters
rule (Type[BaseRuleChecker]) – A BaseRuleChecker derived class to be enabled
- disableRule(rule: Type[omni.asset_validator.core.complianceChecker.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.Note many rules may have been pre-enabled if the engine was default-constructed with initRules=True.
- Parameters
rule (Type[BaseRuleChecker]) – A BaseRuleChecker derived class to be enabled
- validate(asset: omni.asset_validator.core.engine.AssetType) omni.asset_validator.core.autofix.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()
orvalidate_with_callbacks()
to recursively validate a folder.- Parameters
asset (AssetType) – A single Omniverse 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.core.engine.AssetType) omni.asset_validator.core.autofix.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 Omniverse 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.core.engine.AssetType, asset_located_fn: Optional[omni.asset_validator.core.engine.AssetLocatedCallback] = None, asset_validated_fn: Optional[omni.asset_validator.core.engine.AssetValidatedCallback] = None, asset_progress_fn: Optional[omni.asset_validator.core.engine.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 Omniverse 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.core.stats.ValidationStats
Returns Statistics about each validation run.
- class omni.asset_validator.core.ValidationRulesRegistry
A registry enabling external clients to add new rules to the engine.
Rules must derive from
BaseRuleChecker
and should re-implement the necessary virtual methods required for their specific check, as well as documenting with an appropriate user-facing message.Rules are registered to specific categories (str labels) to provide bulk enabling/disabling via carb settings and to make logical grouping in UIs or other documentation easier.
Example
Define a new Rule that requires all prims to be meshes or xforms (e.g. if your app only handles these types) and register it with the validation framework under a custom category:
import omni.asset_validator.core @omni.asset_validator.core.registerRule("MyOwnRules") class MyRuleChecker(omni.asset_validator.core.BaseRuleChecker): '''Check that all prims are meshes for xforms''' def CheckPrim(self, prim) -> None: self._Msg("Checking prim <%s>." % prim.GetPath()) if prim.GetTypeName() not in ("Mesh", "Xform"): self._AddFailedCheck( f"Prim <{prim.GetPath()}> has unsupported type '{prim.GetTypeName()}'." )
By default all rules that ship with USD itself are registered into “Basic” and “ARKit” categories, though “ARKit” rules have been default disabled via carb settings.
- static categories(enabledOnly: bool = False) Tuple[str, ...]
Query all registered categories
- Parameters
enabledOnly – Filter the results to only categories that are enabled (via carb settings)
- Returns
A tuple of category strings that can be used in
rules()
- static rules(category: str, enabledOnly: bool = False) Tuple[Type[omni.asset_validator.core.complianceChecker.BaseRuleChecker], ...]
Query all registered rules in a given category
- Parameters
category – Filter for rules only in a specific category
enabledOnly – Filter the results to only rules that are enabled (via carb settings)
- Returns
A tuple of BaseRuleChecker derived classes
- static registerRule(rule: Type[omni.asset_validator.core.complianceChecker.BaseRuleChecker], category: str) None
Register a new Rule to a specific category
- Parameters
rule – A BaseRuleChecker derived class that implements a specific check
category – The label with which this rule will be associated
- static deregisterRule(rule: Type[omni.asset_validator.core.complianceChecker.BaseRuleChecker]) None
Remove a specific Rule from the registry
For convenience it is not required to specify the category, the rule will be removed from all categories, and subsequent empty categories will be removed from the registry.
- Parameters
rule – A BaseRuleChecker derived class that implements a specific check
- static rule(name: str) Optional[Type[omni.asset_validator.core.complianceChecker.BaseRuleChecker]]
Query a registered rule by class name
- Parameters
name – The exact (case sensitive) class name of a previously registered rule
- Returns
A BaseRuleChecker derived class or None
- static category(rule: Type[omni.asset_validator.core.complianceChecker.BaseRuleChecker]) str
Query the category of a specific rule
- Parameters
rule – A previously registered BaseRuleChecker derived class
- Returns
A valid category name or empty string
- @omni.asset_validator.core.registerRule
Decorator. Register a new
BaseRuleChecker
to a specific category.Example
Register MyRule into the category “MyCategory” so that becomes part of the default initialized ValidationEngine.
@registerRule("MyCategory") class MyRule(BaseRuleChecker): pass
- Parameters
category (str) – The label with which this rule will be associated
- class omni.asset_validator.core.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 general public/community (eg limit file types)
assetLevelChecks – Expand checks with asset (top) level coverage
- classmethod GetDescription()
Description used to describe 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.core.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.UsdGeom.Primvar
pxr.Sdf.PrimSpec
pxr.Sdf.PropertySpec
- class omni.asset_validator.core.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.core.autofix.AtType) omni.asset_validator.core.autofix.Identifier[omni.asset_validator.core.autofix.AtType]
- Parameters
obj (AtType) – An Usd Object.
- Returns
A stateful representation of an Usd object.
- restore(stage: pxr.Usd.Stage) omni.asset_validator.core.autofix.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.core.autofix.LayerId]
- Returns
The list of all possible layer ids associated to this identifier.
- get_spec_ids() List[omni.asset_validator.core.autofix.SpecId]
- Returns
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- class omni.asset_validator.core.LayerId(identifier)
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.core.autofix.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_layer_ids() List[omni.asset_validator.core.autofix.LayerId]
- Returns
The list of all possible layer ids associated to this identifier.
- get_spec_ids() List[omni.asset_validator.core.autofix.SpecId]
- Returns
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- class omni.asset_validator.core.StageId(root_layer: LayerId)
A unique identifier to stage, i.e. identifier.
- classmethod from_(stage: pxr.Usd.Stage) omni.asset_validator.core.autofix.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_layer_ids() List[omni.asset_validator.core.autofix.LayerId]
- Returns
The list of all possible layer ids associated to this identifier.
- get_spec_ids() List[omni.asset_validator.core.autofix.SpecId]
- Returns
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- class omni.asset_validator.core.SpecId(layer_id: LayerId, path: Sdf.Path)
A snapshot of a Prim Specification.
- path
The path to this specification.
- Type
Sdf.Path
- classmethod from_(spec: pxr.Sdf.Spec) omni.asset_validator.core.autofix.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_layer_ids() List[omni.asset_validator.core.autofix.LayerId]
- Returns
The list of all possible layer ids associated to this identifier.
- get_spec_ids() List[omni.asset_validator.core.autofix.SpecId]
- Returns
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- class omni.asset_validator.core.SpecIdList(root_path: Sdf.Path, spec_ids: List[SpecId])
A snapshot of a list of PcpNodeRefs.
- root_path
The prim path in stage.
- Type
Sdf.Path
- property nodes: List[omni.asset_validator.core.autofix.SpecId]
Deprecated since version 0.4.0: Please use
SpecIdList.spec_ids
.
- class omni.asset_validator.core.PrimId(stage_id: StageId, spec_ids: SpecIdList)
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: pxr.Usd.Prim) omni.asset_validator.core.autofix.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.
- property nodes: omni.asset_validator.core.autofix.SpecIdList
Deprecated since version 0.4.0: Please use
PrimId.spec_ids
.
- get_layer_ids() List[omni.asset_validator.core.autofix.LayerId]
- Returns
The list of all possible layer ids associated to this identifier.
- get_spec_ids() List[omni.asset_validator.core.autofix.SpecId]
- Returns
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- class omni.asset_validator.core.PropertyId(prim_id: PrimId, path: 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.
- path
The path to this property.
- Type
Sdf.Path
- classmethod from_(prop: pxr.Usd.Property) omni.asset_validator.core.autofix.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_layer_ids() List[omni.asset_validator.core.autofix.LayerId]
- Returns
The list of all possible layer ids associated to this identifier.
- get_spec_ids() List[omni.asset_validator.core.autofix.SpecId]
- Returns
The list of all possible prim specs i.e., path and layer ids associated to this identifier.
- class omni.asset_validator.core.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.
- NONE = 3
No issue.
- class omni.asset_validator.core.Issue(message: str, severity: IssueSeverity, rule: Optional[RuleType] = None, at=None, suggestion: Optional[Suggestion] = None, asset=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
- 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]
The following exemplifies the expected arguments of an issue:
import omni.asset_validator.core class MyRule(BaseRuleChecker): pass stage = Usd.Stage.Open('omniverse://localhost/NVIDIA/Samples/Astronaut/Astronaut.usd') prim = stage.GetPrimAtPath("/"); def my_suggestion(stage: Usd.Stage, at: Usd.Prim): pass issue = omni.asset_validator.core.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.core.autofix.IssueSeverity, message: str) omni.asset_validator.core.autofix.Issue
Deprecated since version 0.4.0: Use Issue constructor.
- classmethod from_(severity: omni.asset_validator.core.autofix.IssueSeverity, rule: omni.asset_validator.core.autofix.RuleType, message: str) omni.asset_validator.core.autofix.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.core.autofix.SpecId]
Returns: A list of all possible fix sites.
- property default_fix_site: Optional[omni.asset_validator.core.autofix.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.core.Results(asset: str, issues)
A collection of
Issue
.Provides convenience mechanisms to filter
Issue
byIssuePredicates
.- classmethod create(asset: Union[pxr.Usd.Stage, str], issues: Sequence[omni.asset_validator.core.autofix.Issue]) omni.asset_validator.core.autofix.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.
- property asset: str
Returns: The Asset corresponding to these Results. Either a path or the result of Usd.Describe.
- property errors: List[str]
Deprecated since version 0.4.0: Use the issues method instead.
- property warnings: List[str]
Deprecated since version 0.4.0: Use the issues method instead.
- property failures: List[str]
Deprecated since version 0.4.0: Use the issues method instead.
- issues(predicate: Optional[omni.asset_validator.core.autofix.IssuePredicate] = None) omni.asset_validator.core.autofix.IssuesList
Filter Issues using an option IssuePredicate.
- Parameters
predicate – Optional. A predicate to filter the issues.
- Returns
An issue group.
- class omni.asset_validator.core.IssuePredicate
An IssuePredicate is a callable that returns True or False for a specific Issue.
- class omni.asset_validator.core.IssuePredicates
Convenient methods to filter issues. Additionally, provides
IssuePredicates.And()
andIssuePredicates.Or()
predicates to chain multiple predicates, see example below.import omni.asset_validator.core issues = [ omni.asset_validator.core.Issue( severity=omni.asset_validator.core.IssueSeverity.ERROR, message="This is an error"), omni.asset_validator.core.Issue( severity=omni.asset_validator.core.IssueSeverity.WARNING, message="Important warning!"), ] filtered = list(filter( omni.asset_validator.core.IssuePredicates.And( omni.asset_validator.core.IssuePredicates.IsError(), omni.asset_validator.core.IssuePredicates.ContainsMessage("Important"), ), issues ))
- static Any() omni.asset_validator.core.autofix.IssuePredicate
- Returns
A dummy filter that does not filter.
- static IsFailure() omni.asset_validator.core.autofix.IssuePredicate
- Returns
A filter for Issues marked as failure.
- static IsWarning() omni.asset_validator.core.autofix.IssuePredicate
- Returns
A filter for Issues marked as warnings.
- static IsError() omni.asset_validator.core.autofix.IssuePredicate
- Returns
A filter for Issues marked as errors.
- static ContainsMessage(text: str) omni.asset_validator.core.autofix.IssuePredicate
- Parameters
text – A specific text to filter the message in issues.
- Returns
A filter for messages containing
text
.
- static HasLocation() omni.asset_validator.core.autofix.IssuePredicate
- Returns
A filter for issues with location, i.e. at
- static And(lh: omni.asset_validator.core.autofix.IssuePredicate, rh: omni.asset_validator.core.autofix.IssuePredicate) omni.asset_validator.core.autofix.IssuePredicate
- Parameters
lh – First predicate.
rh – Second predicate.
- Returns
A predicate joining two predicates by
and
condition.
- static Or(lh: omni.asset_validator.core.autofix.IssuePredicate, rh: omni.asset_validator.core.autofix.IssuePredicate) omni.asset_validator.core.autofix.IssuePredicate
- Parameters
lh – First predicate.
rh – Second predicate.
- Returns
A predicate joining two predicates by
or
condition.
- class omni.asset_validator.core.IssueGroupBy
An IssueGroupBy is a callable that returns a list linking an Issue to a specific group.
- class omni.asset_validator.core.IssueGroupsBy
Convenient methods to group issues.
Examples
Group by messages.
import collections import omni.asset_validator.core issues = [ omni.asset_validator.core.Issue( severity=omni.asset_validator.core.IssueSeverity.ERROR, message="This is an error at Prim1", rule=omni.asset_validator.core.TypeChecker), omni.asset_validator.core.Issue( severity=omni.asset_validator.core.IssueSeverity.ERROR, message="This is an error at Prim2", rule=omni.asset_validator.core.TypeChecker), ] groups = set() for group, issue in omni.asset_validator.core.IssueGroupsBy.message()(issues): groups.add(group) print(groups)
Output
{'This is an error at .*'}
Groups by rule.
import collections import omni.asset_validator.core issues = [ omni.asset_validator.core.Issue( severity=omni.asset_validator.core.IssueSeverity.ERROR, message="This is an error at Prim1", rule=omni.asset_validator.core.TypeChecker), omni.asset_validator.core.Issue( severity=omni.asset_validator.core.IssueSeverity.ERROR, message="This is an error at Prim2", rule=omni.asset_validator.core.TypeChecker), ] groups = set() for group, issue in omni.asset_validator.core.IssueGroupsBy.rule()(issues): groups.add(group) print(groups)
Output
{<class 'omni.asset_validator.core.TypeChecker'>}
Groups by severity.
import collections import omni.asset_validator.core issues = [ omni.asset_validator.core.Issue( severity=omni.asset_validator.core.IssueSeverity.ERROR, message="This is an error at Prim1", rule=omni.asset_validator.core.TypeChecker), omni.asset_validator.core.Issue( severity=omni.asset_validator.core.IssueSeverity.ERROR, message="This is an error at Prim2", rule=omni.asset_validator.core.TypeChecker), ] groups = set() for group, issue in omni.asset_validator.core.IssueGroupsBy.severity()(issues): groups.add(group) print(groups)
{<IssueSeverity.ERROR: 0>}
- class omni.asset_validator.core.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.core.FixResult(issue: Issue, status: FixStatus, exception: Optional[Exception] = None)
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.core.IssueFixer(asset)
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.core.autofix.Issue, at: Optional[omni.asset_validator.core.autofix.Identifier[omni.asset_validator.core.autofix.AtType]] = None) omni.asset_validator.core.autofix.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.core.autofix.Issue]) List[omni.asset_validator.core.autofix.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.core.autofix.Issue], layer: pxr.Sdf.Layer) List[omni.asset_validator.core.autofix.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.
- class omni.asset_validator.core.Suggestion(callable: Callable[[Usd.Stage, AtType], None], message: str, at=None)
A suggestion is a combination of a callable and a message describing the suggestion.
- 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]]]
- omni.asset_validator.core.AuthoringLayers(at: Union[omni.asset_validator.core.autofix.AtType, List[omni.asset_validator.core.autofix.AtType]]) List[pxr.Sdf.Layer]
- class omni.asset_validator.core.PatternTree(root: PatternNode = NOTHING)
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.