manager
SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
- class omni.flux.validator.manager.core.manager.Iterable
Bases:
object
- class omni.flux.validator.manager.core.manager.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Bases:
object
Extensible JSON <http://json.org> encoder for Python data structures.
Supports the following objects and types by default:
Python
JSON
dict
object
list, tuple
array
str
string
int, float
number
True
true
False
false
None
null
To extend this to recognize other objects, subclass and implement a
.default()
method with another method that returns a serializable object foro
if possible, otherwise it should call the superclass implementation (to raiseTypeError
).- __init__(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Constructor for JSONEncoder, with sensible defaults.
If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.
If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.
If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an RecursionError). Otherwise, no such check takes place.
If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.
If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.
If specified, separators should be an (item_separator, key_separator) tuple. The default is (’, ‘, ‘: ‘) if indent is
None
and (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a
TypeError
.
- default(o)
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- encode(o)
Return a JSON string representation of a Python data structure.
>>> from json.encoder import JSONEncoder >>> JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}'
- item_separator = ', '
- iterencode(o, _one_shot=False)
Encode the given object and yield each string representation as available.
For example:
for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk)
- key_separator = ': '
- class omni.flux.validator.manager.core.manager.ManagerCore(schema: Dict)
Bases:
object
- __init__(schema: Dict)
Validation manager that will execute the validation.
- Parameters
schema – the schema to use for the validation. Please see the documentation.
Examples
>>> ManagerCore( >>> { >>> "context_plugin": {"name": "CurrentStage", "data": {"context_name": ""}}, >>> "check_plugins": [ >>> { >>> "name": "PrintPrims", >>> "selector_plugins": [{"name": "AllPrims", "data": {}}], >>> "resultor_plugins": [{"name": "MyResultor", "data": {}}], >>> "data": {} >>> } >>> ], >>> "resultor_plugins": [{"name": "ToJson", "data": {"json_path": "C:/result.json"}}], >>> } >>>)
- async deferred_run(print_result: bool = False, silent: bool = False, run_mode: omni.flux.validator.factory.plugins.plugin_base.ValidatorRunMode = ValidatorRunMode.BASE_ALL, instance_plugins: Optional[List[omni.flux.validator.factory.plugins.plugin_base.Base]] = None, queue_id: Optional[str] = None)
Run the validation using the current schema
- Parameters
print_result – print the result or not into stdout
silent – silent the stdout
run_mode – the mode to use to run the validator
instance_plugins – plugins used by the mode to run
queue_id – the queue ID to use. Needed if you have multiple widgets that shows different queues
- async deferred_run_with_exception(print_result: bool = False, silent: bool = False, run_mode: omni.flux.validator.factory.plugins.plugin_base.ValidatorRunMode = ValidatorRunMode.BASE_ALL, instance_plugins: Optional[List[omni.flux.validator.factory.plugins.plugin_base.Base]] = None, queue_id: str | None = None)
Run the validation using the current schema
- Parameters
print_result – print the result or not into stdout
silent – silent the stdout
run_mode – the mode to use to run the validator
instance_plugins – plugins used by the mode to run
queue_id – the queue ID to use. Needed if you have multiple widgets that shows different queues
- async deferred_set_mode(run_mode: omni.flux.validator.factory.plugins.plugin_base.ValidatorRunMode = ValidatorRunMode.BASE_ALL, instance_plugins: Optional[List[omni.flux.validator.factory.plugins.plugin_base.Base]] = None)
Run the validation using the current schema
- Parameters
run_mode – the mode to run. We can ask the validator to run everything (by default), or just one plugin…
instance_plugins – instance plugin where the call come from
- destroy()
- disable_some_plugins(run_mode: omni.flux.validator.factory.plugins.plugin_base.ValidatorRunMode = ValidatorRunMode.BASE_ALL, instance_plugins: Optional[List[omni.flux.validator.factory.plugins.plugin_base.Base]] = None)
Context manager that will disable some plugins usin a run mode
- Parameters
run_mode – the mode to use to run the validator
instance_plugins – plugins used by the mode to run
- enable(enable: bool)
Enable the validator or not
- Parameters
enable – True is enabled, else False
- get_progress()
- is_enabled()
Tell if the validator is enabled or not
- is_paused()
- is_ready_to_run() Dict[int, bool]
Tell if the validator is enabled or not
- is_run_finished()
- is_run_started()
- is_stopped()
- mass_build_queue_action_ui(default_actions: List[Callable[[], Any]], callback: Callable[[str], Any])
Default exposed action for Mass validation. The UI will be built into the delegate of the mass queue.
- property model: omni.flux.validator.manager.core.manager.ValidationSchema
Return the current model of the schema
- pause()
Pause the validator
- resume()
Resume the validator (if paused)
- run(catch_exception: bool = True, print_result: bool = False, silent: bool = False, run_mode: omni.flux.validator.factory.plugins.plugin_base.ValidatorRunMode = ValidatorRunMode.BASE_ALL, instance_plugins: Optional[List[omni.flux.validator.factory.plugins.plugin_base.Base]] = None, queue_id: Optional[str] = None)
Run the validation using the current schema
- Parameters
catch_exception – ignore async exception or not
print_result – print the result or not into stdout
silent – silent the stdout
run_mode – the mode to use to run the validator
instance_plugins – plugins used by the mode to run
queue_id – the queue ID to use. Needed if you have multiple widgets that shows different queues
- set_force_ignore_exception(value)
Ignore async exception or not
- set_ready_to_run(plugin_id: int, enable: bool)
Is the validator read to be run or not
- Parameters
plugin_id – the id of the plugin
enable – True is enabled, else False
- stop()
Stop the validator
- subscribe_run_finished(callback: Callable[[bool, Optional[str]], Any])
Return the object that will automatically unsubscribe when destroyed.
- subscribe_run_paused(callback: Callable[[bool], Any])
Return the object that will automatically unsubscribe when destroyed.
- subscribe_run_progress(callback: Callable[[float], Any])
Return the object that will automatically unsubscribe when destroyed.
- subscribe_run_started(callback: Callable[[], Any])
Return the object that will automatically unsubscribe when destroyed.
- subscribe_run_stopped(callback: Callable[[], Any])
Return the object that will automatically unsubscribe when destroyed.
- update_model(model: omni.flux.validator.manager.core.manager.ValidationSchema)
Return the current model of the schema
- class omni.flux.validator.manager.core.manager.ValidationSchema(*args: Any, **kwargs: Any)
Bases:
pydantic.BaseModel
- at_least_one(v)
Check if there is at least 1 check plugin
- check_plugins: List[omni.flux.validator.factory.plugins.check_base.Schema]
- context_plugin: omni.flux.validator.factory.plugins.context_base.Schema
- data: Optional[Dict[Any, Any]] = None
- finished: Optional[Tuple[bool, str]] = (False, 'Nothing')
- name: str
- progress: Optional[float] = 0.0
- resultor_plugins: Optional[List[omni.flux.validator.factory.plugins.resultor_base.Schema]] = None
- sanitize_uuid(v)
- send_request: Optional[bool] = False
- update(data: dict) omni.flux.validator.manager.core.manager.ValidationSchema
This function updates the attributes of a ValidationSchema instance with new values provided in a dictionary. The update is performed recursively for nested models and lists within the model.
- uuid: Optional[str] = None
- validation_passed: bool = False
- omni.flux.validator.manager.core.manager.disable_exception_traceback()
All traceback information is suppressed and only the exception type and value are printed
- omni.flux.validator.manager.core.manager.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)
Serialize
obj
to a JSON formattedstr
.If
skipkeys
is true thendict
keys that are not basic types (str
,int
,float
,bool
,None
) will be skipped instead of raising aTypeError
.If
ensure_ascii
is false, then the return value can contain non-ASCII characters if they appear in strings contained inobj
. Otherwise, all such characters are escaped in JSON strings.If
check_circular
is false, then the circular reference check for container types will be skipped and a circular reference will result in anRecursionError
(or worse).If
allow_nan
is false, then it will be aValueError
to serialize out of rangefloat
values (nan
,inf
,-inf
) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN
,Infinity
,-Infinity
).If
indent
is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines.None
is the most compact representation.If specified,
separators
should be an(item_separator, key_separator)
tuple. The default is(', ', ': ')
if indent isNone
and(',', ': ')
otherwise. To get the most compact JSON representation, you should specify(',', ':')
to eliminate whitespace.default(obj)
is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.If sort_keys is true (default:
False
), then the output of dictionaries will be sorted by key.To use a custom
JSONEncoder
subclass (e.g. one that overrides the.default()
method to serialize additional types), specify it with thecls
kwarg; otherwiseJSONEncoder
is used.
- omni.flux.validator.manager.core.manager.validation_schema_json_encoder(obj)