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)
alias of TypeVar(‘AssetType’, str, ~pxr.Usd.Stage)
- 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.
alias of TypeVar(‘AssetLocatedCallback’, bound=
Callable
[[AssetType
],None
])
- 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.
alias of TypeVar(‘AssetValidatedCallback’, bound=
Callable
[[Results
],None
])
- 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.
alias of TypeVar(‘AssetProgressCallback’, bound=
Callable
[[AssetProgress
],None
])
- 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
alias of TypeVar(‘AtType’, ~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#
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[BaseRuleChecker]]#
An immutable list of rules.
- add(
- category: str,
- rule: Type[BaseRuleChecker],
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,
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[BaseRuleChecker],
Removes a rule from the registry.
- Parameters:
rule – The rule to remove from the registry.
- find_rule(
- rule_name: str,
- Returns:
Find rule by name. Returns None otherwise.
- get_category(
- rule: Type[BaseRuleChecker],
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() 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() CategoryRuleRegistry #
- Returns:
A singleton mutable category rule registry. By default, this includes all rules found in this module except for AtomicAsset rules.
- 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: AtType,
- Parameters:
obj (AtType) – An Usd Object.
- Returns:
A stateful representation of an Usd object.
- 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.
- as_str() str #
- Returns:
Pretty print representation of this object. Useful for testing.
- 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,
- tags: Tuple[str, ...] | None = 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]
- code#
Optional. The code or identifierof the issue.
- Type:
Optional[str]
- requirement#
Optional. The requirement that this issue belongs to. When requirement is provided, code and message are ignored.
- Type:
Optional[Requirement]
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"), )
- classmethod from_message(
- severity: IssueSeverity,
- message: str,
Deprecated since version 0.4.0: Use Issue constructor.
- classmethod from_(
- severity: IssueSeverity,
- rule: RuleType,
- message: str,
Deprecated since version 0.4.0: Use Issue constructor.
- classmethod none()#
Returns: Singleton object representing no Issue.
- 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()
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 Any() IssuePredicate #
- Returns:
A dummy filter that does not filter.
- static IsFailure() IssuePredicate #
- Returns:
A filter for Issues marked as failure.
- static IsWarning() IssuePredicate #
- Returns:
A filter for Issues marked as warnings.
- static IsError() IssuePredicate #
- Returns:
A filter for Issues marked as errors.
- static IsInfo() IssuePredicate #
- Returns:
A filter for Issues marked as infos.
- static IsSuccess() IssuePredicate #
- Returns:
A filter for Issues marked as success, i.e. IssueSeverity.NONE.
- static ContainsMessage(
- text: str,
- Parameters:
text – A specific text to filter the message in issues.
- Returns:
A filter for messages containing
text
.
- static HasLocation() IssuePredicate #
- Returns:
A filter for issues with location, i.e. at
- static And(
- *predicates,
- Parameters:
predicates – One or more IssuePredicate.
- Returns:
A predicate joining predicates by
and
condition.
- static Or(
- *predicates,
- Parameters:
predicates – One or more IssuePredicate.
- Returns:
A predicate joining predicates by
or
condition.
- static Not(
- predicate: IssuePredicate,
- Returns:
A predicate joining predicates by
not
condition.
- static HasCode() IssuePredicate #
- Returns:
A filter for issues with requirement identifier.
- static MatchesCode(
- code: str,
- Returns:
A filter for issues with matching code.
- static MatchesAnyCode(
- codes: Sequence[str],
- Returns:
A filter for issues with matching code.
- static MatchesToken(
- token: str,
- Returns:
A filter for issues with matching token.
- static HasTag(
- tag: str,
- Returns:
A filter for issues with specific tag.
- 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>}
- classmethod code() IssueGroupBy #
Returns a list of tuples with the issue code and the issue.
- classmethod requirement() IssueGroupBy #
Returns a list of tuples with the issue requirement and the issue.
- 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.Any | None = None,
A list of issues, provides convenient features to filter/group by issues.
- 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.
- 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.
- get_spec_ids() List[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.List[~omni.asset_validator.issues.Issue] | ~omni.asset_validator.issues.IssuesList = <factory>,
A collection of
Issue
.Provides convenience mechanisms to filter
Issue
byIssuePredicates
.- 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 (Union[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.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.
- property identifier: str#
Deprecated since version 0.4.0: Use
StageId.root_layer
attribute.
- 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.
- as_str() str #
- Returns:
Pretty print representation of this object. Useful for testing.
- 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.
- 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.
- get_spec_ids() List[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: 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.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.
- 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.
- as_str() str #
- Returns:
Pretty print representation of this object. Useful for testing.
- 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.
- prim_id#
(PrimId) An identifier to the prim containing this property.
- 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.
- 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.
- as_str() str #
- Returns:
Pretty print representation of this object. Useful for testing.
- class omni.asset_validator.IssueSeverity(
- value,
- names=None,
- *,
- 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.
- 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.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
- description#
A complete description of the requirement (optional)
- Type:
str | None
- path#
Relative path in documentation (optional)
- Type:
str | None
- 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.
- 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()
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) )
- 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: AssetType,
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: AssetType,
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[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
- 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_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:
rule (Type[Requirement]) – A Requirement to be enabled
- enable_capability(
- capability: Capabilities,
Enable a given capability on this engine.
This gives control to client code to enable capabilities one by one. Capabilities must be a member of the
Capability
enum. Enabling a capability will enable all requirements that belong to it.- Parameters:
rule (Type[Capabilities]) – A Capability to be enabled
- validate(
- asset: AssetType,
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: AssetType,
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: AssetType,
- 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 stats: ValidationStats#
Returns Statistics about each validation run.
- enableRule(
- rule: Type[BaseRuleChecker],
Deprecated since version 0.11.5: Use
ValidationEngine.enable_rule()
.
- disableRule(
- rule: Type[BaseRuleChecker],
Deprecated since version 0.11.5: Use
ValidationEngine.disable_rule()
.
- classmethod isAssetSupported(
- asset: AssetType,
Deprecated since version 0.11.5: Use
ValidationEngine.is_asset_supported()
.
- class omni.asset_validator.ValidationNamespaceExec(namespace: 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: str | None#
Returns: The asset option value.
- property fix: bool#
Returns: The fix option value.
- property rules: List[Type[BaseRuleChecker]]#
Returns: The rules option value.
- property requirements: List[str]#
Returns: The requirements option value.
- property capabilities: List[str]#
Returns: The capabilities option value.
- property enabled_rules: List[Type[BaseRuleChecker]]#
Returns: The enable_rules option value.
- property disabled_rules: List[Type[BaseRuleChecker]]#
Returns: The disable_rules option value.
- property category_rules: List[Type[BaseRuleChecker]]#
Returns: The category options value.
- property enabled_category_rules: List[Type[BaseRuleChecker]]#
Returns: The enable_category options value.
- property disable_category_rules: List[Type[BaseRuleChecker]]#
Returns: The disable_category option value.
- property csv_output: str | None#
Returns: The csv-output option value.
- class omni.asset_validator.FixStatus(
- value,
- names=None,
- *,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
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( )#
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.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 # 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 (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[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:
IOError – If writing permissions are not granted.