omni.flux.validator.manager.core#

  • 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

  • https://www.apache.org/licenses/LICENSE-2.0

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

omni.flux.validator.manager.core.cli.main()#
async omni.flux.validator.manager.core.cli.run(json_path: str, print_result: bool, queue_id: str | None)#
  • 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

  • https://www.apache.org/licenses/LICENSE-2.0

  • 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.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 for o if possible, otherwise it should call the superclass implementation (to raise 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 a TypeError).

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

async deferred_run(
print_result: bool = False,
silent: bool = False,
run_mode: ValidatorRunMode = ValidatorRunMode.BASE_ALL,
instance_plugins: list[Base] | None = 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_run_with_exception(
print_result: bool = False,
silent: bool = False,
run_mode: ValidatorRunMode = ValidatorRunMode.BASE_ALL,
instance_plugins: list[Base] | None = 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: ValidatorRunMode = ValidatorRunMode.BASE_ALL,
instance_plugins: list[Base] | None = 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: ValidatorRunMode = ValidatorRunMode.BASE_ALL,
instance_plugins: list[Base] | None = 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: 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: ValidatorRunMode = ValidatorRunMode.BASE_ALL,
instance_plugins: list[Base] | None = None,
queue_id: str | None = 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, str | None], 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: ValidationSchema,
)#

Return the current model of the schema

pydantic model omni.flux.validator.manager.core.manager.ValidationSchema#

Bases: BaseModel

Show JSON schema
{
   "title": "ValidationSchema",
   "type": "object",
   "properties": {
      "on_progress_callback": {
         "default": null,
         "title": "On Progress Callback"
      },
      "on_finished_callback": {
         "default": null,
         "title": "On Finished Callback"
      },
      "name": {
         "title": "Name",
         "type": "string"
      },
      "uuid": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Uuid"
      },
      "data": {
         "anyOf": [
            {
               "additionalProperties": true,
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Data"
      },
      "progress": {
         "default": 0.0,
         "title": "Progress",
         "type": "number"
      },
      "send_request": {
         "default": false,
         "title": "Send Request",
         "type": "boolean"
      },
      "context_plugin": {
         "$ref": "#/$defs/omni__flux__validator__factory__plugins__context_base__Schema"
      },
      "check_plugins": {
         "items": {
            "$ref": "#/$defs/omni__flux__validator__factory__plugins__check_base__Schema"
         },
         "title": "Check Plugins",
         "type": "array"
      },
      "resultor_plugins": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/omni__flux__validator__factory__plugins__resultor_base__Schema"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Resultor Plugins"
      },
      "validation_passed": {
         "default": false,
         "title": "Validation Passed",
         "type": "boolean"
      },
      "finished": {
         "default": [
            false,
            "Nothing"
         ],
         "maxItems": 2,
         "minItems": 2,
         "prefixItems": [
            {
               "type": "boolean"
            },
            {
               "type": "string"
            }
         ],
         "title": "Finished",
         "type": "array"
      }
   },
   "$defs": {
      "Data": {
         "properties": {},
         "title": "Data",
         "type": "object"
      },
      "omni__flux__validator__factory__plugins__check_base__Schema": {
         "additionalProperties": false,
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "enabled": {
               "default": true,
               "title": "Enabled",
               "type": "boolean"
            },
            "data": {
               "$ref": "#/$defs/Data"
            },
            "context_plugin": {
               "$ref": "#/$defs/omni__flux__validator__factory__plugins__context_base__Schema"
            },
            "selector_plugins": {
               "items": {
                  "$ref": "#/$defs/omni__flux__validator__factory__plugins__selector_base__Schema"
               },
               "title": "Selector Plugins",
               "type": "array"
            },
            "resultor_plugins": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/omni__flux__validator__factory__plugins__resultor_base__Schema"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Resultor Plugins"
            },
            "stop_if_fix_failed": {
               "default": false,
               "title": "Stop If Fix Failed",
               "type": "boolean"
            },
            "pause_if_fix_failed": {
               "default": true,
               "title": "Pause If Fix Failed",
               "type": "boolean"
            }
         },
         "required": [
            "name",
            "data",
            "context_plugin",
            "selector_plugins"
         ],
         "title": "Schema",
         "type": "object"
      },
      "omni__flux__validator__factory__plugins__context_base__Schema": {
         "additionalProperties": false,
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "enabled": {
               "default": true,
               "title": "Enabled",
               "type": "boolean"
            },
            "data": {
               "$ref": "#/$defs/Data"
            },
            "resultor_plugins": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/omni__flux__validator__factory__plugins__resultor_base__Schema"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Resultor Plugins"
            }
         },
         "required": [
            "name",
            "data"
         ],
         "title": "Schema",
         "type": "object"
      },
      "omni__flux__validator__factory__plugins__resultor_base__Schema": {
         "additionalProperties": false,
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "enabled": {
               "default": true,
               "title": "Enabled",
               "type": "boolean"
            },
            "data": {
               "$ref": "#/$defs/Data"
            }
         },
         "required": [
            "name",
            "data"
         ],
         "title": "Schema",
         "type": "object"
      },
      "omni__flux__validator__factory__plugins__selector_base__Schema": {
         "additionalProperties": false,
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "enabled": {
               "default": true,
               "title": "Enabled",
               "type": "boolean"
            },
            "data": {
               "$ref": "#/$defs/Data"
            }
         },
         "required": [
            "name",
            "data"
         ],
         "title": "Schema",
         "type": "object"
      }
   },
   "required": [
      "name",
      "context_plugin",
      "check_plugins"
   ]
}

Config:
  • validate_assignment: bool = True

Fields:
Validators:
field check_plugins: list[Schema] [Required]#
Validated by:
field context_plugin: Schema [Required]#
field data: dict[Any, Any] | None = None#
field finished: tuple[bool, str] = (False, 'Nothing')#
Validated by:
  • _fire_finished_callback

field name: str [Required]#
field on_finished_callback: Callable[[bool, str, bool], None] | None = None#
field on_progress_callback: Callable[[float, bool], None] | None = None#
field progress: float = 0.0#
Validated by:
  • _fire_progress_callback

field resultor_plugins: list[Schema] | None = None#
field send_request: bool = False#
field uuid: str | None = None#
Validated by:
field validation_passed: bool = False#
validator at_least_one  »  check_plugins#
validator sanitize_uuid  »  uuid#
update(
data: dict,
) 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.

omni.flux.validator.manager.core.manager.disable_exception_traceback()#

All traceback information is suppressed and only the exception type and value are printed

class omni.flux.validator.manager.core.manager.redirect_stderr(new_target)#

Bases: _RedirectStream

Context manager for temporarily redirecting stderr to another file.

omni.flux.validator.manager.core.manager.validation_schema_json_encoder(obj)#