file_path
stringlengths
21
224
content
stringlengths
0
80.8M
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrimsV2.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnWritePrimsV2Database import OgnWritePrimsV2Database test_file_name = "OgnWritePrimsV2Template.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WritePrimsV2") database = OgnWritePrimsV2Database(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToExport")) attribute = test_node.get_attribute("inputs:attrNamesToExport") db_value = database.inputs.attrNamesToExport expected_value = "*" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("inputs:layerIdentifier")) attribute = test_node.get_attribute("inputs:layerIdentifier") db_value = database.inputs.layerIdentifier expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern")) attribute = test_node.get_attribute("inputs:pathPattern") db_value = database.inputs.pathPattern expected_value = "*" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:prims")) attribute = test_node.get_attribute("inputs:prims") db_value = database.inputs.prims self.assertTrue(test_node.get_attribute_exists("inputs:primsBundle")) attribute = test_node.get_attribute("inputs:primsBundle") db_value = database.inputs.primsBundle self.assertTrue(test_node.get_attribute_exists("inputs:scatterUnderTargets")) attribute = test_node.get_attribute("inputs:scatterUnderTargets") db_value = database.inputs.scatterUnderTargets expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:typePattern")) attribute = test_node.get_attribute("inputs:typePattern") db_value = database.inputs.typePattern expected_value = "*" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack")) attribute = test_node.get_attribute("inputs:usdWriteBack") db_value = database.inputs.usdWriteBack expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:execOut")) attribute = test_node.get_attribute("outputs:execOut") db_value = database.outputs.execOut self.assertTrue(test_node.get_attribute_exists("state:attrNamesToExport")) attribute = test_node.get_attribute("state:attrNamesToExport") db_value = database.state.attrNamesToExport self.assertTrue(test_node.get_attribute_exists("state:layerIdentifier")) attribute = test_node.get_attribute("state:layerIdentifier") db_value = database.state.layerIdentifier self.assertTrue(test_node.get_attribute_exists("state:pathPattern")) attribute = test_node.get_attribute("state:pathPattern") db_value = database.state.pathPattern self.assertTrue(test_node.get_attribute_exists("state:primBundleDirtyId")) attribute = test_node.get_attribute("state:primBundleDirtyId") db_value = database.state.primBundleDirtyId self.assertTrue(test_node.get_attribute_exists("state:scatterUnderTargets")) attribute = test_node.get_attribute("state:scatterUnderTargets") db_value = database.state.scatterUnderTargets self.assertTrue(test_node.get_attribute_exists("state:typePattern")) attribute = test_node.get_attribute("state:typePattern") db_value = database.state.typePattern self.assertTrue(test_node.get_attribute_exists("state:usdWriteBack")) attribute = test_node.get_attribute("state:usdWriteBack") db_value = database.state.usdWriteBack
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantQuatf.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantQuatfDatabase import OgnConstantQuatfDatabase test_file_name = "OgnConstantQuatfTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantQuatf") database = OgnConstantQuatfDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value expected_value = [0.0, 0.0, 0.0, 0.0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrimAttribute.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnWritePrimAttributeDatabase import OgnWritePrimAttributeDatabase test_file_name = "OgnWritePrimAttributeTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WritePrimAttribute") database = OgnWritePrimAttributeDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("inputs:name")) attribute = test_node.get_attribute("inputs:name") db_value = database.inputs.name expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:primPath")) attribute = test_node.get_attribute("inputs:primPath") db_value = database.inputs.primPath expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack")) attribute = test_node.get_attribute("inputs:usdWriteBack") db_value = database.inputs.usdWriteBack expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usePath")) attribute = test_node.get_attribute("inputs:usePath") db_value = database.inputs.usePath expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:execOut")) attribute = test_node.get_attribute("outputs:execOut") db_value = database.outputs.execOut self.assertTrue(test_node.get_attribute_exists("state:correctlySetup")) attribute = test_node.get_attribute("state:correctlySetup") db_value = database.state.correctlySetup self.assertTrue(test_node.get_attribute_exists("state:destAttrib")) attribute = test_node.get_attribute("state:destAttrib") db_value = database.state.destAttrib self.assertTrue(test_node.get_attribute_exists("state:destPath")) attribute = test_node.get_attribute("state:destPath") db_value = database.state.destPath self.assertTrue(test_node.get_attribute_exists("state:destPathToken")) attribute = test_node.get_attribute("state:destPathToken") db_value = database.state.destPathToken
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeVector4.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:x', {'type': 'float', 'value': 42.0}, False], ['inputs:y', {'type': 'float', 'value': 1.0}, False], ['inputs:z', {'type': 'float', 'value': 0}, False], ['inputs:w', {'type': 'float', 'value': 0}, False], ], 'outputs': [ ['outputs:tuple', {'type': 'float[4]', 'value': [42.0, 1.0, 0.0, 0.0]}, False], ], }, { 'inputs': [ ['inputs:x', {'type': 'float', 'value': 42.0}, False], ], 'outputs': [ ['outputs:tuple', {'type': 'float[4]', 'value': [42.0, 0.0, 0.0, 0.0]}, False], ], }, { 'inputs': [ ['inputs:x', {'type': 'float[]', 'value': [42, 1, 0]}, False], ['inputs:y', {'type': 'float[]', 'value': [0, 1, 2]}, False], ['inputs:z', {'type': 'float[]', 'value': [0, 2, 4]}, False], ['inputs:w', {'type': 'float[]', 'value': [5, 6, 7]}, False], ], 'outputs': [ ['outputs:tuple', {'type': 'float[4][]', 'value': [[42, 0, 0, 5], [1, 1, 2, 6], [0, 2, 4, 7]]}, False], ], }, { 'inputs': [ ['inputs:x', {'type': 'int', 'value': 42}, False], ['inputs:y', {'type': 'int', 'value': -42}, False], ['inputs:z', {'type': 'int', 'value': 5}, False], ['inputs:w', {'type': 'int', 'value': 6}, False], ], 'outputs': [ ['outputs:tuple', {'type': 'int[4]', 'value': [42, -42, 5, 6]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector4", "omni.graph.nodes.MakeVector4", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector4 User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector4","omni.graph.nodes.MakeVector4", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector4 User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeVector4", "omni.graph.nodes.MakeVector4", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeVector4 User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnMakeVector4Database import OgnMakeVector4Database test_file_name = "OgnMakeVector4Template.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeVector4") database = OgnMakeVector4Database(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetMatrix4Quaternion.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1]}, False], ['inputs:quaternion', {'type': 'quatd[4]', 'value': [0.3826834, 0, 0, 0.9238795]}, False], ], 'outputs': [ ['outputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1]}, False], ], }, { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 0, 0, 1]]}, False], ['inputs:quaternion', {'type': 'quatd[4][]', 'value': [[0.3826834, 0, 0, 0.9238795], [0.3826834, 0, 0, 0.9238795]]}, False], ], 'outputs': [ ['outputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 100, 0, 0, 1]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Quaternion", "omni.graph.nodes.SetMatrix4Quaternion", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Quaternion User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Quaternion","omni.graph.nodes.SetMatrix4Quaternion", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Quaternion User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SetMatrix4Quaternion", "omni.graph.nodes.SetMatrix4Quaternion", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SetMatrix4Quaternion User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnSetMatrix4QuaternionDatabase import OgnSetMatrix4QuaternionDatabase test_file_name = "OgnSetMatrix4QuaternionTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetMatrix4Quaternion") database = OgnSetMatrix4QuaternionDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrimDirectionVector.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnGetPrimDirectionVectorDatabase import OgnGetPrimDirectionVectorDatabase test_file_name = "OgnGetPrimDirectionVectorTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetPrimDirectionVector") database = OgnGetPrimDirectionVectorDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:primPath")) attribute = test_node.get_attribute("inputs:primPath") db_value = database.inputs.primPath expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usePath")) attribute = test_node.get_attribute("inputs:usePath") db_value = database.inputs.usePath expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:backwardVector")) attribute = test_node.get_attribute("outputs:backwardVector") db_value = database.outputs.backwardVector self.assertTrue(test_node.get_attribute_exists("outputs:downVector")) attribute = test_node.get_attribute("outputs:downVector") db_value = database.outputs.downVector self.assertTrue(test_node.get_attribute_exists("outputs:forwardVector")) attribute = test_node.get_attribute("outputs:forwardVector") db_value = database.outputs.forwardVector self.assertTrue(test_node.get_attribute_exists("outputs:leftVector")) attribute = test_node.get_attribute("outputs:leftVector") db_value = database.outputs.leftVector self.assertTrue(test_node.get_attribute_exists("outputs:rightVector")) attribute = test_node.get_attribute("outputs:rightVector") db_value = database.outputs.rightVector self.assertTrue(test_node.get_attribute_exists("outputs:upVector")) attribute = test_node.get_attribute("outputs:upVector") db_value = database.outputs.upVector
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTrig.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:a', {'type': 'float', 'value': 120.0}, False], ['inputs:operation', "COS", False], ], 'outputs': [ ['outputs:result', {'type': 'float', 'value': -0.5}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'double', 'value': -57.2958}, False], ['inputs:operation', "RADIANS", False], ], 'outputs': [ ['outputs:result', {'type': 'double', 'value': -1.0}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'double', 'value': -1.0}, False], ['inputs:operation', "ARCCOS", False], ], 'outputs': [ ['outputs:result', {'type': 'double', 'value': 180.0}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'float', 'value': 45.0}, False], ['inputs:operation', "SIN", False], ], 'outputs': [ ['outputs:result', {'type': 'float', 'value': 0.707107}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Trig", "omni.graph.nodes.Trig", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Trig User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Trig","omni.graph.nodes.Trig", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Trig User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Trig", "omni.graph.nodes.Trig", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Trig User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnTrigDatabase import OgnTrigDatabase test_file_name = "OgnTrigTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Trig") database = OgnTrigDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:operation")) attribute = test_node.get_attribute("inputs:operation") db_value = database.inputs.operation expected_value = "SIN" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGpuInteropRenderProductEntry.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnGpuInteropRenderProductEntryDatabase import OgnGpuInteropRenderProductEntryDatabase test_file_name = "OgnGpuInteropRenderProductEntryTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GpuInteropRenderProductEntry") database = OgnGpuInteropRenderProductEntryDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("outputs:exec")) attribute = test_node.get_attribute("outputs:exec") db_value = database.outputs.exec self.assertTrue(test_node.get_attribute_exists("outputs:gpu")) attribute = test_node.get_attribute("outputs:gpu") db_value = database.outputs.gpu self.assertTrue(test_node.get_attribute_exists("outputs:hydraTime")) attribute = test_node.get_attribute("outputs:hydraTime") db_value = database.outputs.hydraTime self.assertTrue(test_node.get_attribute_exists("outputs:rp")) attribute = test_node.get_attribute("outputs:rp") db_value = database.outputs.rp self.assertTrue(test_node.get_attribute_exists("outputs:simTime")) attribute = test_node.get_attribute("outputs:simTime") db_value = database.outputs.simTime
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnDistance3D.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:a', {'type': 'float[3]', 'value': [1, 2, 3]}, False], ['inputs:b', {'type': 'float[3]', 'value': [4, 6, 8]}, False], ], 'outputs': [ ['outputs:distance', {'type': 'float', 'value': 7.07107}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'float[3][]', 'value': [[1, 2, 3], [1, 2, 3]]}, False], ['inputs:b', {'type': 'float[3][]', 'value': [[1, 2, 3], [4, 6, 8]]}, False], ], 'outputs': [ ['outputs:distance', {'type': 'float[]', 'value': [0, 7.07107]}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'half[3][]', 'value': [[1, 2, 3], [4, 6, 8]]}, False], ['inputs:b', {'type': 'half[3]', 'value': [1, 2, 3]}, False], ], 'outputs': [ ['outputs:distance', {'type': 'half[]', 'value': [0, 7.0703125]}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'double[3]', 'value': [1, 2, 3]}, False], ['inputs:b', {'type': 'double[3]', 'value': [4, 6, 8]}, False], ], 'outputs': [ ['outputs:distance', {'type': 'double', 'value': 7.07107}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Distance3D", "omni.graph.nodes.Distance3D", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Distance3D User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Distance3D","omni.graph.nodes.Distance3D", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Distance3D User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Distance3D", "omni.graph.nodes.Distance3D", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Distance3D User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnDistance3DDatabase import OgnDistance3DDatabase test_file_name = "OgnDistance3DTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Distance3D") database = OgnDistance3DDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetMatrix4Translation.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1]}, False], ['inputs:translation', {'type': 'vectord[3]', 'value': [1, 2, 3]}, False], ], 'outputs': [ ['outputs:matrix', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 1, 2, 3, 1]}, False], ], }, { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 10, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1], [1.0, 15, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 0, 0, 1]]}, False], ['inputs:translation', {'type': 'vectord[3][]', 'value': [[45, 10, 10], [3, 2, 1]]}, False], ], 'outputs': [ ['outputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 10, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 45, 10, 10, 1], [1.0, 15, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3, 2, 1, 1]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Translation", "omni.graph.nodes.SetMatrix4Translation", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Translation User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Translation","omni.graph.nodes.SetMatrix4Translation", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Translation User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SetMatrix4Translation", "omni.graph.nodes.SetMatrix4Translation", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SetMatrix4Translation User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnSetMatrix4TranslationDatabase import OgnSetMatrix4TranslationDatabase test_file_name = "OgnSetMatrix4TranslationTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetMatrix4Translation") database = OgnSetMatrix4TranslationDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadVariable.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnReadVariableDatabase import OgnReadVariableDatabase test_file_name = "OgnReadVariableTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_core_ReadVariable") database = OgnReadVariableDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:variableName")) attribute = test_node.get_attribute("inputs:variableName") db_value = database.inputs.variableName expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIsPrimActive.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnIsPrimActiveDatabase import OgnIsPrimActiveDatabase test_file_name = "OgnIsPrimActiveTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_IsPrimActive") database = OgnIsPrimActiveDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:prim")) attribute = test_node.get_attribute("inputs:prim") db_value = database.inputs.prim expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:primTarget")) attribute = test_node.get_attribute("inputs:primTarget") db_value = database.inputs.primTarget self.assertTrue(test_node.get_attribute_exists("outputs:active")) attribute = test_node.get_attribute("outputs:active") db_value = database.outputs.active
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAdd.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:a', {'type': 'float[2]', 'value': [1.0, 2.0]}, False], ['inputs:b', {'type': 'float[2]', 'value': [0.5, 1.0]}, False], ], 'outputs': [ ['outputs:sum', {'type': 'float[2]', 'value': [1.5, 3.0]}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'int64', 'value': 10}, False], ['inputs:b', {'type': 'int64', 'value': 6}, False], ], 'outputs': [ ['outputs:sum', {'type': 'int64', 'value': 16}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False], ['inputs:b', {'type': 'double[2]', 'value': [5, 5]}, False], ], 'outputs': [ ['outputs:sum', {'type': 'double[2][]', 'value': [[15, 10], [6, 6]]}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False], ['inputs:b', {'type': 'double', 'value': 5}, False], ], 'outputs': [ ['outputs:sum', {'type': 'double[2][]', 'value': [[15, 10], [6, 6]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Add", "omni.graph.nodes.Add", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Add User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Add","omni.graph.nodes.Add", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Add User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Add", "omni.graph.nodes.Add", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Add User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnAddDatabase import OgnAddDatabase test_file_name = "OgnAddTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Add") database = OgnAddDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPrims.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantPrimsDatabase import OgnConstantPrimsDatabase test_file_name = "OgnConstantPrimsTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantPrims") database = OgnConstantPrimsDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNor.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:a', {'type': 'bool', 'value': False}, False], ['inputs:b', {'type': 'bool', 'value': True}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'bool[]', 'value': [False, False, True, True]}, False], ['inputs:b', {'type': 'bool[]', 'value': [False, True, False, True]}, False], ], 'outputs': [ ['outputs:result', [True, False, False, False], False], ], }, { 'inputs': [ ['inputs:a', {'type': 'bool', 'value': False}, False], ['inputs:b', {'type': 'bool[]', 'value': [False, True]}, False], ], 'outputs': [ ['outputs:result', [True, False], False], ], }, { 'inputs': [ ['inputs:a', {'type': 'bool[]', 'value': [False, True]}, False], ['inputs:b', {'type': 'bool', 'value': False}, False], ], 'outputs': [ ['outputs:result', [True, False], False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanNor", "omni.graph.nodes.BooleanNor", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanNor User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanNor","omni.graph.nodes.BooleanNor", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanNor User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BooleanNor", "omni.graph.nodes.BooleanNor", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BooleanNor User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnNorDatabase import OgnNorDatabase test_file_name = "OgnNorTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BooleanNor") database = OgnNorDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBundleInspector.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'outputs': [ ['outputs:count', 0, False], ['outputs:names', [], False], ['outputs:types', [], False], ['outputs:roles', [], False], ['outputs:arrayDepths', [], False], ['outputs:tupleCounts', [], False], ['outputs:values', [], False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BundleInspector", "omni.graph.nodes.BundleInspector", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BundleInspector User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BundleInspector","omni.graph.nodes.BundleInspector", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BundleInspector User test case #{i+1}", 16) async def test_data_access(self): from omni.graph.nodes.ogn.OgnBundleInspectorDatabase import OgnBundleInspectorDatabase test_file_name = "OgnBundleInspectorTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BundleInspector") database = OgnBundleInspectorDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:bundle")) attribute = test_node.get_attribute("inputs:bundle") db_value = database.inputs.bundle self.assertTrue(test_node.get_attribute_exists("inputs:inspectDepth")) attribute = test_node.get_attribute("inputs:inspectDepth") db_value = database.inputs.inspectDepth expected_value = 1 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:print")) attribute = test_node.get_attribute("inputs:print") db_value = database.inputs.print expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:arrayDepths")) attribute = test_node.get_attribute("outputs:arrayDepths") db_value = database.outputs.arrayDepths self.assertTrue(test_node.get_attribute_exists("outputs:attributeCount")) attribute = test_node.get_attribute("outputs:attributeCount") db_value = database.outputs.attributeCount self.assertTrue(test_node.get_attribute_exists("outputs_bundle")) attribute = test_node.get_attribute("outputs_bundle") db_value = database.outputs.bundle self.assertTrue(test_node.get_attribute_exists("outputs:childCount")) attribute = test_node.get_attribute("outputs:childCount") db_value = database.outputs.childCount self.assertTrue(test_node.get_attribute_exists("outputs:count")) attribute = test_node.get_attribute("outputs:count") db_value = database.outputs.count self.assertTrue(test_node.get_attribute_exists("outputs:names")) attribute = test_node.get_attribute("outputs:names") db_value = database.outputs.names self.assertTrue(test_node.get_attribute_exists("outputs:roles")) attribute = test_node.get_attribute("outputs:roles") db_value = database.outputs.roles self.assertTrue(test_node.get_attribute_exists("outputs:tupleCounts")) attribute = test_node.get_attribute("outputs:tupleCounts") db_value = database.outputs.tupleCounts self.assertTrue(test_node.get_attribute_exists("outputs:types")) attribute = test_node.get_attribute("outputs:types") db_value = database.outputs.types self.assertTrue(test_node.get_attribute_exists("outputs:values")) attribute = test_node.get_attribute("outputs:values") db_value = database.outputs.values
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetMatrix4Rotation.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1]}, False], ['inputs:fixedRotationAxis', "X", False], ['inputs:rotationAngle', {'type': 'double', 'value': 45}, False], ], 'outputs': [ ['outputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1]}, False], ], }, { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 0, 0, 1]]}, False], ['inputs:fixedRotationAxis', "X", False], ['inputs:rotationAngle', {'type': 'double[]', 'value': [45, 45]}, False], ], 'outputs': [ ['outputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 100, 0, 0, 1]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Rotation", "omni.graph.nodes.SetMatrix4Rotation", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Rotation User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Rotation","omni.graph.nodes.SetMatrix4Rotation", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Rotation User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SetMatrix4Rotation", "omni.graph.nodes.SetMatrix4Rotation", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SetMatrix4Rotation User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnSetMatrix4RotationDatabase import OgnSetMatrix4RotationDatabase test_file_name = "OgnSetMatrix4RotationTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetMatrix4Rotation") database = OgnSetMatrix4RotationDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:fixedRotationAxis")) attribute = test_node.get_attribute("inputs:fixedRotationAxis") db_value = database.inputs.fixedRotationAxis expected_value = "Y" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnEachZero.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 42.5}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -7.1}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.0}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.01}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -0.01}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 42.5}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -7.1}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.0}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.01}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -0.01}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [0, 0]}, False], ], 'outputs': [ ['outputs:result', [True, True], False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [0, 3]}, False], ], 'outputs': [ ['outputs:result', [True, False], False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [3, 0]}, False], ], 'outputs': [ ['outputs:result', [False, True], False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [3, 5]}, False], ], 'outputs': [ ['outputs:result', [False, False], False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3]', 'value': [1.7, 0.05, -4.3]}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', [False, True, False], False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3][]', 'value': [[1.7, 0.05, -4.3], [0.0, -0.1, 0.3]]}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', [False, False], False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3][]', 'value': [[1.7, 0.05, -4.3], [0.0, -0.1, 0.3]]}, False], ['inputs:tolerance', 0.5, False], ], 'outputs': [ ['outputs:result', [False, True], False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_EachZero", "omni.graph.nodes.EachZero", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.EachZero User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_EachZero","omni.graph.nodes.EachZero", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.EachZero User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_EachZero", "omni.graph.nodes.EachZero", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.EachZero User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnEachZeroDatabase import OgnEachZeroDatabase test_file_name = "OgnEachZeroTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_EachZero") database = OgnEachZeroDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:tolerance")) attribute = test_node.get_attribute("inputs:tolerance") db_value = database.inputs.tolerance expected_value = 0.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrims.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnGetPrimsDatabase import OgnGetPrimsDatabase test_file_name = "OgnGetPrimsTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetPrims") database = OgnGetPrimsDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:bundle")) attribute = test_node.get_attribute("inputs:bundle") db_value = database.inputs.bundle self.assertTrue(test_node.get_attribute_exists("inputs:inverse")) attribute = test_node.get_attribute("inputs:inverse") db_value = database.inputs.inverse expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern")) attribute = test_node.get_attribute("inputs:pathPattern") db_value = database.inputs.pathPattern expected_value = "*" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:typePattern")) attribute = test_node.get_attribute("inputs:typePattern") db_value = database.inputs.typePattern expected_value = "*" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs_bundle")) attribute = test_node.get_attribute("outputs_bundle") db_value = database.outputs.bundle
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTan.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 45.0}, False], ], 'outputs': [ ['outputs:value', {'type': 'float', 'value': 1.0}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Tan", "omni.graph.nodes.Tan", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Tan User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Tan","omni.graph.nodes.Tan", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Tan User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Tan", "omni.graph.nodes.Tan", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Tan User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnTanDatabase import OgnTanDatabase test_file_name = "OgnTanTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Tan") database = OgnTanDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAbsolute.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:input', {'type': 'double', 'value': -10.0}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'double', 'value': 10.0}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'float', 'value': -10.0}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'float', 'value': 10.0}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'half', 'value': -10.0}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'half', 'value': 10.0}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'int', 'value': -10}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'int', 'value': 10}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'int64', 'value': -10}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'int64', 'value': 10}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'uchar', 'value': 10}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'uchar', 'value': 10}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'uint', 'value': 10}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'uint', 'value': 10}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'uint64', 'value': 10}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'uint64', 'value': 10}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'double[3]', 'value': [-1.0, -2.0, -3.0]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'double[3]', 'value': [1.0, 2.0, 3.0]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'float[4]', 'value': [-2.0, 2.0, -2.0, 2.0]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'float[4]', 'value': [2.0, 2.0, 2.0, 2.0]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'int[2]', 'value': [3, -4]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'int[2]', 'value': [3, 4]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'half[2]', 'value': [3.0, -4.0]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'half[2]', 'value': [3.0, 4.0]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'double[]', 'value': [-1.0, -2.0, -2.0]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'double[]', 'value': [1.0, 2.0, 2.0]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'float[]', 'value': [-2.0, 2.0, -2.0, 2.0]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'float[]', 'value': [2.0, 2.0, 2.0, 2.0]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'half[]', 'value': [3.0, -4.0]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'half[]', 'value': [3.0, 4.0]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'int[]', 'value': [3, -4]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'int[]', 'value': [3, 4]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'int64[]', 'value': [3, -4]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'int64[]', 'value': [3, 4]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'uchar[]', 'value': [3, 4]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'uchar[]', 'value': [3, 4]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'uint[]', 'value': [3, 4]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'uint[]', 'value': [3, 4]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'uint64[]', 'value': [3, 4]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'uint64[]', 'value': [3, 4]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'int[3][]', 'value': [[1, -2, -2], [-4, 2, 6], [3, -2, 4], [1, -4, 2]]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'int[3][]', 'value': [[1, 2, 2], [4, 2, 6], [3, 2, 4], [1, 4, 2]]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'double[3][]', 'value': [[1.0, -2.0, -2.0], [-4.0, 2.0, 6.0], [3.0, -2.0, 4.0], [1.0, -4.0, 2.0]]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'double[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, 4.0, 2.0]]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'float[3][]', 'value': [[1.0, -2.0, -2.0], [-4.0, 2.0, 6.0], [3.0, -2.0, 4.0], [1.0, -4.0, 2.0]]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'float[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, 4.0, 2.0]]}, False], ], }, { 'inputs': [ ['inputs:input', {'type': 'half[3][]', 'value': [[1.0, -2.0, -2.0], [-4.0, 2.0, 6.0], [3.0, -2.0, 4.0], [1.0, -4.0, 2.0]]}, False], ], 'outputs': [ ['outputs:absolute', {'type': 'half[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, 4.0, 2.0]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Absolute", "omni.graph.nodes.Absolute", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Absolute User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Absolute","omni.graph.nodes.Absolute", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Absolute User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Absolute", "omni.graph.nodes.Absolute", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Absolute User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnAbsoluteDatabase import OgnAbsoluteDatabase test_file_name = "OgnAbsoluteTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Absolute") database = OgnAbsoluteDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayLength.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnArrayLengthDatabase import OgnArrayLengthDatabase test_file_name = "OgnArrayLengthTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayLength") database = OgnArrayLengthDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:attrName")) attribute = test_node.get_attribute("inputs:attrName") db_value = database.inputs.attrName expected_value = "points" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:data")) attribute = test_node.get_attribute("inputs:data") db_value = database.inputs.data self.assertTrue(test_node.get_attribute_exists("outputs:length")) attribute = test_node.get_attribute("outputs:length") db_value = database.outputs.length
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRandomUnitQuaternion.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:useSeed', True, False], ['inputs:seed', 123456789, False], ['inputs:execIn', 1, False], ['inputs:isNoise', True, False], ], 'outputs': [ ['outputs:random', [0.02489632, -0.05617058, 0.23986788, 0.9688594], False], ['outputs:execOut', 1, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomUnitQuaternion", "omni.graph.nodes.RandomUnitQuaternion", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomUnitQuaternion User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomUnitQuaternion","omni.graph.nodes.RandomUnitQuaternion", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomUnitQuaternion User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_RandomUnitQuaternion", "omni.graph.nodes.RandomUnitQuaternion", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.RandomUnitQuaternion User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnRandomUnitQuaternionDatabase import OgnRandomUnitQuaternionDatabase test_file_name = "OgnRandomUnitQuaternionTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RandomUnitQuaternion") database = OgnRandomUnitQuaternionDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("inputs:isNoise")) attribute = test_node.get_attribute("inputs:isNoise") db_value = database.inputs.isNoise expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:useSeed")) attribute = test_node.get_attribute("inputs:useSeed") db_value = database.inputs.useSeed expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:execOut")) attribute = test_node.get_attribute("outputs:execOut") db_value = database.outputs.execOut self.assertTrue(test_node.get_attribute_exists("outputs:random")) attribute = test_node.get_attribute("outputs:random") db_value = database.outputs.random self.assertTrue(test_node.get_attribute_exists("state:gen")) attribute = test_node.get_attribute("state:gen") db_value = database.state.gen
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnInterpolator.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:knots', [1.0, 2.0], False], ['inputs:values', [3.0, 4.0], False], ['inputs:param', 1.5, False], ], 'outputs': [ ['outputs:value', 3.5, False], ], }, { 'inputs': [ ['inputs:knots', [1.0, 2.0], False], ['inputs:values', [3.0, 4.0], False], ['inputs:param', 1.0, False], ], 'outputs': [ ['outputs:value', 3.0, False], ], }, { 'inputs': [ ['inputs:knots', [1.0, 2.0], False], ['inputs:values', [3.0, 4.0], False], ['inputs:param', 2.0, False], ], 'outputs': [ ['outputs:value', 4.0, False], ], }, { 'inputs': [ ['inputs:knots', [1.0, 2.0], False], ['inputs:values', [3.0, 4.0], False], ['inputs:param', 0.5, False], ], 'outputs': [ ['outputs:value', 3.0, False], ], }, { 'inputs': [ ['inputs:knots', [1.0, 2.0], False], ['inputs:values', [3.0, 4.0], False], ['inputs:param', 2.5, False], ], 'outputs': [ ['outputs:value', 4.0, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Interpolator", "omni.graph.nodes.Interpolator", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Interpolator User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Interpolator","omni.graph.nodes.Interpolator", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Interpolator User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Interpolator", "omni.graph.nodes.Interpolator", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Interpolator User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnInterpolatorDatabase import OgnInterpolatorDatabase test_file_name = "OgnInterpolatorTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Interpolator") database = OgnInterpolatorDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:knots")) attribute = test_node.get_attribute("inputs:knots") db_value = database.inputs.knots expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:param")) attribute = test_node.get_attribute("inputs:param") db_value = database.inputs.param expected_value = 0.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:values")) attribute = test_node.get_attribute("inputs:values") db_value = database.inputs.values expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:value")) attribute = test_node.get_attribute("outputs:value") db_value = database.outputs.value
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRemoveAttr.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnRemoveAttrDatabase import OgnRemoveAttrDatabase test_file_name = "OgnRemoveAttrTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RemoveAttribute") database = OgnRemoveAttrDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:allowRemovePrimInternal")) attribute = test_node.get_attribute("inputs:allowRemovePrimInternal") db_value = database.inputs.allowRemovePrimInternal expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToRemove")) attribute = test_node.get_attribute("inputs:attrNamesToRemove") db_value = database.inputs.attrNamesToRemove expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:data")) attribute = test_node.get_attribute("inputs:data") db_value = database.inputs.data self.assertTrue(test_node.get_attribute_exists("outputs_data")) attribute = test_node.get_attribute("outputs_data") db_value = database.outputs.data
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantQuatd.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantQuatdDatabase import OgnConstantQuatdDatabase test_file_name = "OgnConstantQuatdTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantQuatd") database = OgnConstantQuatdDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value expected_value = [0.0, 0.0, 0.0, 0.0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToRad.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:degrees', {'type': 'double', 'value': -57.2958}, False], ], 'outputs': [ ['outputs:radians', {'type': 'double', 'value': -1.0}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToRad", "omni.graph.nodes.ToRad", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToRad User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToRad","omni.graph.nodes.ToRad", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToRad User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToRad", "omni.graph.nodes.ToRad", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToRad User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnToRadDatabase import OgnToRadDatabase test_file_name = "OgnToRadTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToRad") database = OgnToRadDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrim.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnWritePrimDatabase import OgnWritePrimDatabase test_file_name = "OgnWritePrimTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WritePrim") database = OgnWritePrimDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("inputs:prim")) attribute = test_node.get_attribute("inputs:prim") db_value = database.inputs.prim self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack")) attribute = test_node.get_attribute("inputs:usdWriteBack") db_value = database.inputs.usdWriteBack expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:execOut")) attribute = test_node.get_attribute("outputs:execOut") db_value = database.outputs.execOut
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnInterpolateTo.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:current', {'type': 'float', 'value': 0.0}, False], ['inputs:target', {'type': 'float', 'value': 10.0}, False], ['inputs:deltaSeconds', 0.1, False], ], 'outputs': [ ['outputs:result', {'type': 'float', 'value': 1.9}, False], ], }, { 'inputs': [ ['inputs:current', {'type': 'double[3]', 'value': [0.0, 1.0, 2.0]}, False], ['inputs:target', {'type': 'double[3]', 'value': [10.0, 11.0, 12.0]}, False], ['inputs:deltaSeconds', 0.1, False], ], 'outputs': [ ['outputs:result', {'type': 'double[3]', 'value': [1.9, 2.9, 3.9]}, False], ], }, { 'inputs': [ ['inputs:current', {'type': 'float[]', 'value': [0.0, 1.0, 2.0]}, False], ['inputs:target', {'type': 'float[]', 'value': [10.0, 11.0, 12.0]}, False], ['inputs:deltaSeconds', 0.1, False], ], 'outputs': [ ['outputs:result', {'type': 'float[]', 'value': [1.9, 2.9, 3.9]}, False], ], }, { 'inputs': [ ['inputs:current', {'type': 'double[3][]', 'value': [[0.0, 1.0, 2.0], [0.0, 1.0, 2.0]]}, False], ['inputs:target', {'type': 'double[3][]', 'value': [[10.0, 11.0, 12.0], [10.0, 11.0, 12.0]]}, False], ['inputs:deltaSeconds', 0.1, False], ], 'outputs': [ ['outputs:result', {'type': 'double[3][]', 'value': [[1.9, 2.9, 3.9], [1.9, 2.9, 3.9]]}, False], ], }, { 'inputs': [ ['inputs:current', {'type': 'quatd[4]', 'value': [0, 0, 0, 1]}, False], ['inputs:target', {'type': 'quatd[4]', 'value': [0.7071068, 0, 0, 0.7071068]}, False], ['inputs:deltaSeconds', 0.5, False], ['inputs:exponent', 1, False], ], 'outputs': [ ['outputs:result', {'type': 'quatd[4]', 'value': [0.3826834, 0, 0, 0.9238795]}, False], ], }, { 'inputs': [ ['inputs:current', {'type': 'quatf[4]', 'value': [0, 0, 0, 1]}, False], ['inputs:target', {'type': 'quatf[4]', 'value': [0.7071068, 0, 0, 0.7071068]}, False], ['inputs:deltaSeconds', 0.5, False], ['inputs:exponent', 1, False], ], 'outputs': [ ['outputs:result', {'type': 'quatf[4]', 'value': [0.3826834, 0, 0, 0.9238795]}, False], ], }, { 'inputs': [ ['inputs:current', {'type': 'float[4]', 'value': [0, 0, 0, 1]}, False], ['inputs:target', {'type': 'float[4]', 'value': [0.7071068, 0, 0, 0.7071068]}, False], ['inputs:deltaSeconds', 0.5, False], ['inputs:exponent', 1, False], ], 'outputs': [ ['outputs:result', {'type': 'float[4]', 'value': [0.3535534, 0, 0, 0.8535534]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_InterpolateTo", "omni.graph.nodes.InterpolateTo", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.InterpolateTo User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_InterpolateTo","omni.graph.nodes.InterpolateTo", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.InterpolateTo User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_InterpolateTo", "omni.graph.nodes.InterpolateTo", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.InterpolateTo User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnInterpolateToDatabase import OgnInterpolateToDatabase test_file_name = "OgnInterpolateToTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_InterpolateTo") database = OgnInterpolateToDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:deltaSeconds")) attribute = test_node.get_attribute("inputs:deltaSeconds") db_value = database.inputs.deltaSeconds expected_value = 0.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:exponent")) attribute = test_node.get_attribute("inputs:exponent") db_value = database.inputs.exponent expected_value = 2.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:speed")) attribute = test_node.get_attribute("inputs:speed") db_value = database.inputs.speed expected_value = 1.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimAttributes.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnReadPrimAttributesDatabase import OgnReadPrimAttributesDatabase test_file_name = "OgnReadPrimAttributesTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadPrimAttributes") database = OgnReadPrimAttributesDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToImport")) attribute = test_node.get_attribute("inputs:attrNamesToImport") db_value = database.inputs.attrNamesToImport expected_value = "*" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:prim")) attribute = test_node.get_attribute("inputs:prim") db_value = database.inputs.prim self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode")) attribute = test_node.get_attribute("inputs:usdTimecode") db_value = database.inputs.usdTimecode expected_value = float("NaN") actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usePath")) attribute = test_node.get_attribute("inputs:usePath") db_value = database.inputs.usePath expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs_primBundle")) attribute = test_node.get_attribute("outputs_primBundle") db_value = database.outputs.primBundle self.assertTrue(test_node.get_attribute_exists("state:attrNamesToImport")) attribute = test_node.get_attribute("state:attrNamesToImport") db_value = database.state.attrNamesToImport self.assertTrue(test_node.get_attribute_exists("state:primPath")) attribute = test_node.get_attribute("state:primPath") db_value = database.state.primPath self.assertTrue(test_node.get_attribute_exists("state:usdTimecode")) attribute = test_node.get_attribute("state:usdTimecode") db_value = database.state.usdTimecode
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantInt2.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantInt2Database import OgnConstantInt2Database test_file_name = "OgnConstantInt2Template.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantInt2") database = OgnConstantInt2Database(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value expected_value = [0, 0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAppendString.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:value', {'type': 'token', 'value': '/'}, False], ['inputs:suffix', {'type': 'token', 'value': 'foo'}, False], ], 'outputs': [ ['outputs:value', {'type': 'token', 'value': '/foo'}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'token[]', 'value': ['/World', '/World2']}, False], ['inputs:suffix', {'type': 'token', 'value': '/foo'}, False], ], 'outputs': [ ['outputs:value', {'type': 'token[]', 'value': ['/World/foo', '/World2/foo']}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'token[]', 'value': ['/World', '/World2']}, False], ['inputs:suffix', {'type': 'token[]', 'value': ['/foo', '/bar']}, False], ], 'outputs': [ ['outputs:value', {'type': 'token[]', 'value': ['/World/foo', '/World2/bar']}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'string', 'value': '/'}, False], ['inputs:suffix', {'type': 'string', 'value': 'foo'}, False], ], 'outputs': [ ['outputs:value', {'type': 'string', 'value': '/foo'}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_AppendString", "omni.graph.nodes.AppendString", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.AppendString User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_AppendString","omni.graph.nodes.AppendString", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.AppendString User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_AppendString", "omni.graph.nodes.AppendString", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.AppendString User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnAppendStringDatabase import OgnAppendStringDatabase test_file_name = "OgnAppendStringTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_AppendString") database = OgnAppendStringDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToHalf.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:value', {'type': 'float[]', 'value': []}, False], ], 'outputs': [ ['outputs:converted', {'type': 'half[]', 'value': []}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'double', 'value': 2.5}, False], ], 'outputs': [ ['outputs:converted', {'type': 'half', 'value': 2.5}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 42}, False], ], 'outputs': [ ['outputs:converted', {'type': 'half', 'value': 42.0}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'double[2]', 'value': [2.5, 2.5]}, False], ], 'outputs': [ ['outputs:converted', {'type': 'half[2]', 'value': [2.5, 2.5]}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'half[3]', 'value': [2, 3, 4]}, False], ], 'outputs': [ ['outputs:converted', {'type': 'half[3]', 'value': [2, 3, 4]}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'half[3][]', 'value': [[2, 3, 4]]}, False], ], 'outputs': [ ['outputs:converted', {'type': 'half[3][]', 'value': [[2, 3, 4]]}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2][]', 'value': [[1, 2], [3, 4]]}, False], ], 'outputs': [ ['outputs:converted', {'type': 'half[2][]', 'value': [[1.0, 2.0], [3.0, 4.0]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToHalf", "omni.graph.nodes.ToHalf", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToHalf User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToHalf","omni.graph.nodes.ToHalf", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToHalf User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToHalf", "omni.graph.nodes.ToHalf", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToHalf User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnToHalfDatabase import OgnToHalfDatabase test_file_name = "OgnToHalfTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToHalf") database = OgnToHalfDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBuildString.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:a', {'type': 'token', 'value': '/'}, False], ['inputs:b', {'type': 'token', 'value': 'foo'}, False], ], 'outputs': [ ['outputs:value', {'type': 'token', 'value': '/foo'}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'token[]', 'value': ['/World', '/World2']}, False], ['inputs:b', {'type': 'token', 'value': '/foo'}, False], ], 'outputs': [ ['outputs:value', {'type': 'token[]', 'value': ['/World/foo', '/World2/foo']}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'token[]', 'value': ['/World', '/World2']}, False], ['inputs:b', {'type': 'token[]', 'value': ['/foo', '/bar']}, False], ], 'outputs': [ ['outputs:value', {'type': 'token[]', 'value': ['/World/foo', '/World2/bar']}, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'string', 'value': '/'}, False], ['inputs:b', {'type': 'string', 'value': 'foo'}, False], ], 'outputs': [ ['outputs:value', {'type': 'string', 'value': '/foo'}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BuildString", "omni.graph.nodes.BuildString", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BuildString User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BuildString","omni.graph.nodes.BuildString", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BuildString User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BuildString", "omni.graph.nodes.BuildString", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BuildString User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnBuildStringDatabase import OgnBuildStringDatabase test_file_name = "OgnBuildStringTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BuildString") database = OgnBuildStringDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetGraphTargetId.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnGetGraphTargetIdDatabase import OgnGetGraphTargetIdDatabase test_file_name = "OgnGetGraphTargetIdTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetGraphTargetId") database = OgnGetGraphTargetIdDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("outputs:targetId")) attribute = test_node.get_attribute("outputs:targetId") db_value = database.outputs.targetId
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRenameAttr.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnRenameAttrDatabase import OgnRenameAttrDatabase test_file_name = "OgnRenameAttrTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RenameAttribute") database = OgnRenameAttrDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:data")) attribute = test_node.get_attribute("inputs:data") db_value = database.inputs.data self.assertTrue(test_node.get_attribute_exists("inputs:inputAttrNames")) attribute = test_node.get_attribute("inputs:inputAttrNames") db_value = database.inputs.inputAttrNames expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:outputAttrNames")) attribute = test_node.get_attribute("inputs:outputAttrNames") db_value = database.inputs.outputAttrNames expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs_data")) attribute = test_node.get_attribute("outputs_data") db_value = database.outputs.data
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetMatrix4Rotation.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1]}, False], ], 'outputs': [ ['outputs:rotation', {'type': 'vectord[3]', 'value': [45, 0, 0]}, False], ], }, { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 100, 0, 0, 1]]}, False], ], 'outputs': [ ['outputs:rotation', {'type': 'vectord[3][]', 'value': [[45, 0, 0], [45, 0, 0]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetMatrix4Rotation", "omni.graph.nodes.GetMatrix4Rotation", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Rotation User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetMatrix4Rotation","omni.graph.nodes.GetMatrix4Rotation", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Rotation User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_GetMatrix4Rotation", "omni.graph.nodes.GetMatrix4Rotation", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.GetMatrix4Rotation User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnGetMatrix4RotationDatabase import OgnGetMatrix4RotationDatabase test_file_name = "OgnGetMatrix4RotationTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetMatrix4Rotation") database = OgnGetMatrix4RotationDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRotateVector.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:rotation', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1]}, False], ['inputs:vector', {'type': 'vectord[3]', 'value': [1, 2, 3]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectord[3]', 'value': [31, 32, 3]}, False], ], }, { 'inputs': [ ['inputs:rotation', {'type': 'matrixd[3]', 'value': [1, 0, 0, 0, 0, 1, 0, -1, 0]}, False], ['inputs:vector', {'type': 'vectorf[3]', 'value': [0, 0, 1]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectorf[3]', 'value': [0, -1, 0]}, False], ], }, { 'inputs': [ ['inputs:rotation', {'type': 'vectord[3]', 'value': [90, 0, 0]}, False], ['inputs:vector', {'type': 'vectord[3]', 'value': [0, 0, 1]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectord[3]', 'value': [0, -1, 0]}, False], ], }, { 'inputs': [ ['inputs:rotation', {'type': 'quatf[4]', 'value': [0.7071068, 0, 0, 0.7071068]}, False], ['inputs:vector', {'type': 'vectorf[3]', 'value': [0, 0, 1]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectorf[3]', 'value': [0, -1, 0]}, False], ], }, { 'inputs': [ ['inputs:rotation', {'type': 'vectorf[3][]', 'value': [[0, 90, 0], [90, 0, 0], [90, 90, 0]]}, False], ['inputs:vector', {'type': 'vectorf[3]', 'value': [0, 0, 1]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectorf[3][]', 'value': [[1, 0, 0], [0, -1, 0], [0, -1, 0]]}, False], ], }, { 'inputs': [ ['inputs:rotation', {'type': 'vectord[3]', 'value': [90, 90, 0]}, False], ['inputs:vector', {'type': 'vectord[3][]', 'value': [[0, 0, 1], [0, 1, 0], [1, 0, 0]]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectord[3][]', 'value': [[0, -1, 0], [1, 0, 0], [0, 0, -1]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RotateVector", "omni.graph.nodes.RotateVector", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RotateVector User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RotateVector","omni.graph.nodes.RotateVector", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RotateVector User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_RotateVector", "omni.graph.nodes.RotateVector", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.RotateVector User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnRotateVectorDatabase import OgnRotateVectorDatabase test_file_name = "OgnRotateVectorTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RotateVector") database = OgnRotateVectorDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTransformVector.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1]}, False], ['inputs:vector', {'type': 'vectord[3]', 'value': [1, 2, 3]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectord[3]', 'value': [81, 32, 3]}, False], ], }, { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1]]}, False], ['inputs:vector', {'type': 'vectorf[3][]', 'value': [[1, 2, 3], [1, 2, 3]]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectorf[3][]', 'value': [[81, 32, 3], [81, 32, 3]]}, False], ], }, { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1]}, False], ['inputs:vector', {'type': 'vectorf[3][]', 'value': [[1, 2, 3], [1, 2, 3]]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectorf[3][]', 'value': [[81, 32, 3], [81, 32, 3]]}, False], ], }, { 'inputs': [ ['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1]]}, False], ['inputs:vector', {'type': 'vectorf[3]', 'value': [1, 2, 3]}, False], ], 'outputs': [ ['outputs:result', {'type': 'vectorf[3][]', 'value': [[81, 32, 3], [81, 32, 3]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_TransformVector", "omni.graph.nodes.TransformVector", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.TransformVector User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_TransformVector","omni.graph.nodes.TransformVector", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.TransformVector User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_TransformVector", "omni.graph.nodes.TransformVector", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.TransformVector User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnTransformVectorDatabase import OgnTransformVectorDatabase test_file_name = "OgnTransformVectorTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_TransformVector") database = OgnTransformVectorDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayRotate.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False], ['inputs:steps', 0, False], ], 'outputs': [ ['outputs:array', {'type': 'int[]', 'value': [41, 42]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'int[]', 'value': [41, 42, 43]}, False], ['inputs:steps', 1, False], ], 'outputs': [ ['outputs:array', {'type': 'int[]', 'value': [43, 41, 42]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'float[2][]', 'value': [[1, 2], [3, 4], [5, 6]]}, False], ['inputs:steps', 1, False], ], 'outputs': [ ['outputs:array', {'type': 'float[2][]', 'value': [[5, 6], [1, 2], [3, 4]]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'int[]', 'value': [41, 42, 43]}, False], ['inputs:steps', -1, False], ], 'outputs': [ ['outputs:array', {'type': 'int[]', 'value': [42, 43, 41]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'bool[]', 'value': [True, False, True]}, False], ['inputs:steps', -1, False], ], 'outputs': [ ['outputs:array', {'type': 'bool[]', 'value': [False, True, True]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'int[]', 'value': [41, 42, 43]}, False], ['inputs:steps', -2, False], ], 'outputs': [ ['outputs:array', {'type': 'int[]', 'value': [43, 41, 42]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayRotate", "omni.graph.nodes.ArrayRotate", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRotate User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayRotate","omni.graph.nodes.ArrayRotate", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRotate User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayRotate", "omni.graph.nodes.ArrayRotate", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayRotate User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnArrayRotateDatabase import OgnArrayRotateDatabase test_file_name = "OgnArrayRotateTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayRotate") database = OgnArrayRotateDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:steps")) attribute = test_node.get_attribute("inputs:steps") db_value = database.inputs.steps expected_value = 0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayFill.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False], ['inputs:fillValue', {'type': 'int', 'value': 0}, False], ], 'outputs': [ ['outputs:array', {'type': 'int[]', 'value': [0, 0]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'int[2][]', 'value': [[41, 42], [43, 44]]}, False], ['inputs:fillValue', {'type': 'int[2]', 'value': [1, 2]}, False], ], 'outputs': [ ['outputs:array', {'type': 'int[2][]', 'value': [[1, 2], [1, 2]]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'int64[]', 'value': [41, 42]}, False], ['inputs:fillValue', {'type': 'int64', 'value': 0}, False], ], 'outputs': [ ['outputs:array', {'type': 'int64[]', 'value': [0, 0]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'uchar[]', 'value': [41, 42]}, False], ['inputs:fillValue', {'type': 'uchar', 'value': 0}, False], ], 'outputs': [ ['outputs:array', {'type': 'uchar[]', 'value': [0, 0]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'uint[]', 'value': [41, 42]}, False], ['inputs:fillValue', {'type': 'uint', 'value': 0}, False], ], 'outputs': [ ['outputs:array', {'type': 'uint[]', 'value': [0, 0]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'uint64[]', 'value': [41, 42]}, False], ['inputs:fillValue', {'type': 'uint64', 'value': 0}, False], ], 'outputs': [ ['outputs:array', {'type': 'uint64[]', 'value': [0, 0]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'bool[]', 'value': [True, True]}, False], ['inputs:fillValue', {'type': 'bool', 'value': False}, False], ], 'outputs': [ ['outputs:array', {'type': 'bool[]', 'value': [False, False]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'token[]', 'value': ['41', '42']}, False], ['inputs:fillValue', {'type': 'token', 'value': ''}, False], ], 'outputs': [ ['outputs:array', {'type': 'token[]', 'value': ['', '']}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'half[2][]', 'value': [[1.0, 2.0], [3.0, 4.0]]}, False], ['inputs:fillValue', {'type': 'half[2]', 'value': [5.0, 6.0]}, False], ], 'outputs': [ ['outputs:array', {'type': 'half[2][]', 'value': [[5.0, 6.0], [5.0, 6.0]]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'double[3][]', 'value': [[1.0, 2.0, 3.0], [3.0, 4.0, 5.0]]}, False], ['inputs:fillValue', {'type': 'double[3]', 'value': [5.0, 6.0, 7.0]}, False], ], 'outputs': [ ['outputs:array', {'type': 'double[3][]', 'value': [[5.0, 6.0, 7.0], [5.0, 6.0, 7.0]]}, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'int[4][]', 'value': [[1, 2, 3, 4], [3, 4, 5, 6]]}, False], ['inputs:fillValue', {'type': 'int[4]', 'value': [5, 6, 7, 8]}, False], ], 'outputs': [ ['outputs:array', {'type': 'int[4][]', 'value': [[5, 6, 7, 8], [5, 6, 7, 8]]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayFill", "omni.graph.nodes.ArrayFill", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayFill User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayFill","omni.graph.nodes.ArrayFill", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayFill User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayFill", "omni.graph.nodes.ArrayFill", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayFill User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnArrayFillDatabase import OgnArrayFillDatabase test_file_name = "OgnArrayFillTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayFill") database = OgnArrayFillDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayGetSize.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'half[]', 'value': [41, 42]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'token[]', 'value': []}, False], ], 'outputs': [ ['outputs:size', 0, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'int64[]', 'value': [41]}, False], ], 'outputs': [ ['outputs:size', 1, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'uchar[]', 'value': [41, 42]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'uint[]', 'value': [41, 42]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'uint64[]', 'value': [41, 42]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'bool[]', 'value': [False, True]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'half[2][]', 'value': [[41, 42], [43, 44]]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'double[3][]', 'value': [[41, 42, 43], [43, 44, 56]]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, { 'inputs': [ ['inputs:array', {'type': 'int[4][]', 'value': [[1, 2, 3, 4], [3, 4, 5, 6]]}, False], ], 'outputs': [ ['outputs:size', 2, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayGetSize", "omni.graph.nodes.ArrayGetSize", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayGetSize User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayGetSize","omni.graph.nodes.ArrayGetSize", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayGetSize User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayGetSize", "omni.graph.nodes.ArrayGetSize", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayGetSize User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnArrayGetSizeDatabase import OgnArrayGetSizeDatabase test_file_name = "OgnArrayGetSizeTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayGetSize") database = OgnArrayGetSizeDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("outputs:size")) attribute = test_node.get_attribute("outputs:size") db_value = database.outputs.size
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRenderPostprocessEntry.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnRenderPostprocessEntryDatabase import OgnRenderPostprocessEntryDatabase test_file_name = "OgnRenderPostprocessEntryTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RenderPostProcessEntry") database = OgnRenderPostprocessEntryDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:sourceName")) attribute = test_node.get_attribute("inputs:sourceName") db_value = database.inputs.sourceName expected_value = "ldrColor" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:cudaMipmappedArray")) attribute = test_node.get_attribute("outputs:cudaMipmappedArray") db_value = database.outputs.cudaMipmappedArray self.assertTrue(test_node.get_attribute_exists("outputs:format")) attribute = test_node.get_attribute("outputs:format") db_value = database.outputs.format self.assertTrue(test_node.get_attribute_exists("outputs:height")) attribute = test_node.get_attribute("outputs:height") db_value = database.outputs.height self.assertTrue(test_node.get_attribute_exists("outputs:hydraTime")) attribute = test_node.get_attribute("outputs:hydraTime") db_value = database.outputs.hydraTime self.assertTrue(test_node.get_attribute_exists("outputs:mipCount")) attribute = test_node.get_attribute("outputs:mipCount") db_value = database.outputs.mipCount self.assertTrue(test_node.get_attribute_exists("outputs:simTime")) attribute = test_node.get_attribute("outputs:simTime") db_value = database.outputs.simTime self.assertTrue(test_node.get_attribute_exists("outputs:stream")) attribute = test_node.get_attribute("outputs:stream") db_value = database.outputs.stream self.assertTrue(test_node.get_attribute_exists("outputs:width")) attribute = test_node.get_attribute("outputs:width") db_value = database.outputs.width
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimelineStart.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnTimelineStartDatabase import OgnTimelineStartDatabase test_file_name = "OgnTimelineStartTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_StartTimeline") database = OgnTimelineStartDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("outputs:execOut")) attribute = test_node.get_attribute("outputs:execOut") db_value = database.outputs.execOut
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnFloor.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:a', {'type': 'float', 'value': 4.1}, False], ], 'outputs': [ ['outputs:result', 4, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'half', 'value': -4.9}, False], ], 'outputs': [ ['outputs:result', -5, False], ], }, { 'inputs': [ ['inputs:a', {'type': 'double[3]', 'value': [1.3, 2.4, -3.7]}, False], ], 'outputs': [ ['outputs:result', [1, 2, -4], False], ], }, { 'inputs': [ ['inputs:a', {'type': 'double[]', 'value': [1.3, 2.4, -3.7, 4.5]}, False], ], 'outputs': [ ['outputs:result', [1, 2, -4, 4], False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Floor", "omni.graph.nodes.Floor", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Floor User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Floor","omni.graph.nodes.Floor", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Floor User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Floor", "omni.graph.nodes.Floor", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Floor User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnFloorDatabase import OgnFloorDatabase test_file_name = "OgnFloorTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Floor") database = OgnFloorDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrimsAtPath.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnGetPrimsAtPathDatabase import OgnGetPrimsAtPathDatabase test_file_name = "OgnGetPrimsAtPathTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetPrimsAtPath") database = OgnGetPrimsAtPathDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("outputs:prims")) attribute = test_node.get_attribute("outputs:prims") db_value = database.outputs.prims self.assertTrue(test_node.get_attribute_exists("state:path")) attribute = test_node.get_attribute("state:path") db_value = database.state.path
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBundleConstructor.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnBundleConstructorDatabase import OgnBundleConstructorDatabase test_file_name = "OgnBundleConstructorTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BundleConstructor") database = OgnBundleConstructorDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("outputs_bundle")) attribute = test_node.get_attribute("outputs_bundle") db_value = database.outputs.bundle
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRpResourceExampleDeformer.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnRpResourceExampleDeformerDatabase import OgnRpResourceExampleDeformerDatabase test_file_name = "OgnRpResourceExampleDeformerTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RpResourceExampleDeformer") database = OgnRpResourceExampleDeformerDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:deformScale")) attribute = test_node.get_attribute("inputs:deformScale") db_value = database.inputs.deformScale expected_value = 1.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:displacementAxis")) attribute = test_node.get_attribute("inputs:displacementAxis") db_value = database.inputs.displacementAxis expected_value = 0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:pointCountCollection")) attribute = test_node.get_attribute("inputs:pointCountCollection") db_value = database.inputs.pointCountCollection expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:positionScale")) attribute = test_node.get_attribute("inputs:positionScale") db_value = database.inputs.positionScale expected_value = 1.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:primPathCollection")) attribute = test_node.get_attribute("inputs:primPathCollection") db_value = database.inputs.primPathCollection expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:resourcePointerCollection")) attribute = test_node.get_attribute("inputs:resourcePointerCollection") db_value = database.inputs.resourcePointerCollection expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:runDeformerKernel")) attribute = test_node.get_attribute("inputs:runDeformerKernel") db_value = database.inputs.runDeformerKernel expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:stream")) attribute = test_node.get_attribute("inputs:stream") db_value = database.inputs.stream expected_value = 0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:timeScale")) attribute = test_node.get_attribute("inputs:timeScale") db_value = database.inputs.timeScale expected_value = 0.01 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:verbose")) attribute = test_node.get_attribute("inputs:verbose") db_value = database.inputs.verbose expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:pointCountCollection")) attribute = test_node.get_attribute("outputs:pointCountCollection") db_value = database.outputs.pointCountCollection self.assertTrue(test_node.get_attribute_exists("outputs:primPathCollection")) attribute = test_node.get_attribute("outputs:primPathCollection") db_value = database.outputs.primPathCollection self.assertTrue(test_node.get_attribute_exists("outputs:reload")) attribute = test_node.get_attribute("outputs:reload") db_value = database.outputs.reload self.assertTrue(test_node.get_attribute_exists("outputs:resourcePointerCollection")) attribute = test_node.get_attribute("outputs:resourcePointerCollection") db_value = database.outputs.resourcePointerCollection self.assertTrue(test_node.get_attribute_exists("outputs:stream")) attribute = test_node.get_attribute("outputs:stream") db_value = database.outputs.stream self.assertTrue(test_node.get_attribute_exists("state:sequenceCounter")) attribute = test_node.get_attribute("state:sequenceCounter") db_value = database.state.sequenceCounter
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAttrType.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnAttrTypeDatabase import OgnAttrTypeDatabase test_file_name = "OgnAttrTypeTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_AttributeType") database = OgnAttrTypeDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:attrName")) attribute = test_node.get_attribute("inputs:attrName") db_value = database.inputs.attrName expected_value = "input" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:data")) attribute = test_node.get_attribute("inputs:data") db_value = database.inputs.data self.assertTrue(test_node.get_attribute_exists("outputs:arrayDepth")) attribute = test_node.get_attribute("outputs:arrayDepth") db_value = database.outputs.arrayDepth self.assertTrue(test_node.get_attribute_exists("outputs:baseType")) attribute = test_node.get_attribute("outputs:baseType") db_value = database.outputs.baseType self.assertTrue(test_node.get_attribute_exists("outputs:componentCount")) attribute = test_node.get_attribute("outputs:componentCount") db_value = database.outputs.componentCount self.assertTrue(test_node.get_attribute_exists("outputs:fullType")) attribute = test_node.get_attribute("outputs:fullType") db_value = database.outputs.fullType self.assertTrue(test_node.get_attribute_exists("outputs:role")) attribute = test_node.get_attribute("outputs:role") db_value = database.outputs.role
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantHalf3.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantHalf3Database import OgnConstantHalf3Database test_file_name = "OgnConstantHalf3Template.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantHalf3") database = OgnConstantHalf3Database(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value expected_value = [0.0, 0.0, 0.0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnStopAllSound.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnStopAllSoundDatabase import OgnStopAllSoundDatabase test_file_name = "OgnStopAllSoundTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_StopAllSound") database = OgnStopAllSoundDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("outputs:execOut")) attribute = test_node.get_attribute("outputs:execOut") db_value = database.outputs.execOut
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantColor3f.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantColor3fDatabase import OgnConstantColor3fDatabase test_file_name = "OgnConstantColor3fTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantColor3f") database = OgnConstantColor3fDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value expected_value = [0.0, 0.0, 0.0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetGatheredAttribute.py
import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts import os class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnSetGatheredAttributeDatabase import OgnSetGatheredAttributeDatabase test_file_name = "OgnSetGatheredAttributeTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetGatheredAttribute") database = OgnSetGatheredAttributeDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("inputs:gatherId")) attribute = test_node.get_attribute("inputs:gatherId") db_value = database.inputs.gatherId expected_value = 0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:name")) attribute = test_node.get_attribute("inputs:name") db_value = database.inputs.name expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:execOut")) attribute = test_node.get_attribute("outputs:execOut") db_value = database.outputs.execOut
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetVariantSetNames.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnGetVariantSetNamesDatabase import OgnGetVariantSetNamesDatabase test_file_name = "OgnGetVariantSetNamesTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetVariantSetNames") database = OgnGetVariantSetNamesDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:prim")) attribute = test_node.get_attribute("inputs:prim") db_value = database.inputs.prim self.assertTrue(test_node.get_attribute_exists("outputs:variantSetNames")) attribute = test_node.get_attribute("outputs:variantSetNames") db_value = database.outputs.variantSetNames
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantInt4.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantInt4Database import OgnConstantInt4Database test_file_name = "OgnConstantInt4Template.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantInt4") database = OgnConstantInt4Database(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value expected_value = [0, 0, 0, 0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAppendPath.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:path', {'type': 'token', 'value': '/'}, False], ['inputs:suffix', "foo", False], ], 'outputs': [ ['outputs:path', {'type': 'token', 'value': '/foo'}, False], ], }, { 'inputs': [ ['inputs:path', {'type': 'token', 'value': '/World'}, False], ['inputs:suffix', "foo", False], ], 'outputs': [ ['outputs:path', {'type': 'token', 'value': '/World/foo'}, False], ], }, { 'inputs': [ ['inputs:path', {'type': 'token', 'value': '/World'}, False], ['inputs:suffix', "foo/bar", False], ], 'outputs': [ ['outputs:path', {'type': 'token', 'value': '/World/foo/bar'}, False], ], }, { 'inputs': [ ['inputs:path', {'type': 'token', 'value': '/World'}, False], ['inputs:suffix', "foo/bar.attrib", False], ], 'outputs': [ ['outputs:path', {'type': 'token', 'value': '/World/foo/bar.attrib'}, False], ], }, { 'inputs': [ ['inputs:path', {'type': 'token[]', 'value': ['/World', '/World2']}, False], ['inputs:suffix', "foo", False], ], 'outputs': [ ['outputs:path', {'type': 'token[]', 'value': ['/World/foo', '/World2/foo']}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_AppendPath", "omni.graph.nodes.AppendPath", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.AppendPath User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_AppendPath","omni.graph.nodes.AppendPath", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.AppendPath User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_AppendPath", "omni.graph.nodes.AppendPath", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.AppendPath User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnAppendPathDatabase import OgnAppendPathDatabase test_file_name = "OgnAppendPathTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_AppendPath") database = OgnAppendPathDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:suffix")) attribute = test_node.get_attribute("inputs:suffix") db_value = database.inputs.suffix expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("state:path")) attribute = test_node.get_attribute("state:path") db_value = database.state.path self.assertTrue(test_node.get_attribute_exists("state:suffix")) attribute = test_node.get_attribute("state:suffix") db_value = database.state.suffix
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAnyZero.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 42.5}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -7.1}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.0}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.01}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -0.01}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 42.5}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -7.1}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.0}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.01}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -0.01}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [0, 0]}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [0, 3]}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [3, 0]}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [3, 5]}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3]', 'value': [1.7, 0.05, -4.3]}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3][]', 'value': [[1.7, 0.05, -4.3], [0.0, -0.1, 0.3]]}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_AnyZero", "omni.graph.nodes.AnyZero", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.AnyZero User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_AnyZero","omni.graph.nodes.AnyZero", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.AnyZero User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_AnyZero", "omni.graph.nodes.AnyZero", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.AnyZero User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnAnyZeroDatabase import OgnAnyZeroDatabase test_file_name = "OgnAnyZeroTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_AnyZero") database = OgnAnyZeroDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:tolerance")) attribute = test_node.get_attribute("inputs:tolerance") db_value = database.inputs.tolerance expected_value = 0.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:result")) attribute = test_node.get_attribute("outputs:result") db_value = database.outputs.result
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRenderPreprocessEntry.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnRenderPreprocessEntryDatabase import OgnRenderPreprocessEntryDatabase test_file_name = "OgnRenderPreprocessEntryTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RenderPreProcessEntry") database = OgnRenderPreprocessEntryDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("outputs:hydraTime")) attribute = test_node.get_attribute("outputs:hydraTime") db_value = database.outputs.hydraTime self.assertTrue(test_node.get_attribute_exists("outputs:simTime")) attribute = test_node.get_attribute("outputs:simTime") db_value = database.outputs.simTime self.assertTrue(test_node.get_attribute_exists("outputs:stream")) attribute = test_node.get_attribute("outputs:stream") db_value = database.outputs.stream
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantColor4f.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantColor4fDatabase import OgnConstantColor4fDatabase test_file_name = "OgnConstantColor4fTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantColor4f") database = OgnConstantColor4fDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value expected_value = [0.0, 0.0, 0.0, 0.0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRpResourceExampleHydra.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnRpResourceExampleHydraDatabase import OgnRpResourceExampleHydraDatabase test_file_name = "OgnRpResourceExampleHydraTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RpResourceExampleHydra") database = OgnRpResourceExampleHydraDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:pointCountCollection")) attribute = test_node.get_attribute("inputs:pointCountCollection") db_value = database.inputs.pointCountCollection expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:primPathCollection")) attribute = test_node.get_attribute("inputs:primPathCollection") db_value = database.inputs.primPathCollection expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:resourcePointerCollection")) attribute = test_node.get_attribute("inputs:resourcePointerCollection") db_value = database.inputs.resourcePointerCollection expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:sendToHydra")) attribute = test_node.get_attribute("inputs:sendToHydra") db_value = database.inputs.sendToHydra expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:verbose")) attribute = test_node.get_attribute("inputs:verbose") db_value = database.inputs.verbose expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:reload")) attribute = test_node.get_attribute("outputs:reload") db_value = database.outputs.reload
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPoint3f.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnConstantPoint3fDatabase import OgnConstantPoint3fDatabase test_file_name = "OgnConstantPoint3fTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantPoint3f") database = OgnConstantPoint3fDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:value")) attribute = test_node.get_attribute("inputs:value") db_value = database.inputs.value expected_value = [0.0, 0.0, 0.0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAcos.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.707107}, False], ], 'outputs': [ ['outputs:value', {'type': 'float', 'value': 45.0}, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'double[]', 'value': [-0.5, -1.0]}, False], ], 'outputs': [ ['outputs:value', {'type': 'double[]', 'value': [120, 180]}, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Acos", "omni.graph.nodes.Acos", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Acos User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Acos","omni.graph.nodes.Acos", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Acos User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Acos", "omni.graph.nodes.Acos", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Acos User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnAcosDatabase import OgnAcosDatabase test_file_name = "OgnAcosTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Acos") database = OgnAcosDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMoveToTransform.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnMoveToTransformDatabase import OgnMoveToTransformDatabase test_file_name = "OgnMoveToTransformTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MoveToTransform") database = OgnMoveToTransformDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("inputs:exponent")) attribute = test_node.get_attribute("inputs:exponent") db_value = database.inputs.exponent expected_value = 2.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:speed")) attribute = test_node.get_attribute("inputs:speed") db_value = database.inputs.speed expected_value = 1.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:stop")) attribute = test_node.get_attribute("inputs:stop") db_value = database.inputs.stop self.assertTrue(test_node.get_attribute_exists("inputs:target")) attribute = test_node.get_attribute("inputs:target") db_value = database.inputs.target expected_value = [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usePath")) attribute = test_node.get_attribute("inputs:usePath") db_value = database.inputs.usePath expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:finished")) attribute = test_node.get_attribute("outputs:finished") db_value = database.outputs.finished
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIsZero.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): TEST_DATA = [ { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 42.5}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -7.1}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.0}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.01}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -0.01}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 42.5}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -7.1}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.0}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': 0.01}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float', 'value': -0.01}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 6}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': -3}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int', 'value': 0}, False], ['inputs:tolerance', 10.0, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [0, 0]}, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [0, 3]}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [3, 0]}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'int[2]', 'value': [3, 5]}, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3]', 'value': [1.7, 0.05, -4.3]}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3]', 'value': [0.02, 0.05, -0.03]}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3][]', 'value': [[1.7, 0.05, -4.3], [0.02, 0.05, -0.03]]}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', False, False], ], }, { 'inputs': [ ['inputs:value', {'type': 'float[3][]', 'value': [[0.0, 0.0, 0.0], [0.02, 0.05, -0.03]]}, False], ['inputs:tolerance', 0.1, False], ], 'outputs': [ ['outputs:result', True, False], ], }, ] async def test_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_IsZero", "omni.graph.nodes.IsZero", test_run, test_info) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.IsZero User test case #{i+1}") async def test_vectorized_generated(self): test_info = _TestGraphAndNode() controller = og.Controller() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_IsZero","omni.graph.nodes.IsZero", test_run, test_info, 16) await controller.evaluate(test_info.graph) _test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.IsZero User test case #{i+1}", 16) async def test_thread_safety(self): import omni.kit # Generate multiple instances of the test setup to run them concurrently instance_setup = dict() for n in range(24): instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode() for i, test_run in enumerate(self.TEST_DATA): await _test_clear_scene(self, test_run) for (key, test_info) in instance_setup.items(): test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_IsZero", "omni.graph.nodes.IsZero", test_run, test_info) self.assertEqual(len(og.get_all_graphs()), 24) # We want to evaluate all graphs concurrently. Kick them all. # Evaluate multiple times to skip 2 serial frames and increase chances for a race condition. for _ in range(10): await omni.kit.app.get_app().next_update_async() for (key, test_instance) in instance_setup.items(): _test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.IsZero User test case #{i+1}, instance{key}") async def test_data_access(self): from omni.graph.nodes.ogn.OgnIsZeroDatabase import OgnIsZeroDatabase test_file_name = "OgnIsZeroTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_IsZero") database = OgnIsZeroDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:tolerance")) attribute = test_node.get_attribute("inputs:tolerance") db_value = database.inputs.tolerance expected_value = 0.0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:result")) attribute = test_node.get_attribute("outputs:result") db_value = database.outputs.result
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadSetting.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnReadSettingDatabase import OgnReadSettingDatabase test_file_name = "OgnReadSettingTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadSetting") database = OgnReadSettingDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:settingPath")) attribute = test_node.get_attribute("inputs:settingPath") db_value = database.inputs.settingPath expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimBundle.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.nodes.ogn.OgnReadPrimBundleDatabase import OgnReadPrimBundleDatabase test_file_name = "OgnReadPrimBundleTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadPrimBundle") database = OgnReadPrimBundleDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 7) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToImport")) attribute = test_node.get_attribute("inputs:attrNamesToImport") db_value = database.inputs.attrNamesToImport expected_value = "*" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:computeBoundingBox")) attribute = test_node.get_attribute("inputs:computeBoundingBox") db_value = database.inputs.computeBoundingBox expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode")) attribute = test_node.get_attribute("inputs:usdTimecode") db_value = database.inputs.usdTimecode expected_value = float("NaN") actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usePath")) attribute = test_node.get_attribute("inputs:usePath") db_value = database.inputs.usePath expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs_primBundle")) attribute = test_node.get_attribute("outputs_primBundle") db_value = database.outputs.primBundle self.assertTrue(test_node.get_attribute_exists("state:attrNamesToImport")) attribute = test_node.get_attribute("state:attrNamesToImport") db_value = database.state.attrNamesToImport self.assertTrue(test_node.get_attribute_exists("state:computeBoundingBox")) attribute = test_node.get_attribute("state:computeBoundingBox") db_value = database.state.computeBoundingBox self.assertTrue(test_node.get_attribute_exists("state:primPath")) attribute = test_node.get_attribute("state:primPath") db_value = database.state.primPath self.assertTrue(test_node.get_attribute_exists("state:usdTimecode")) attribute = test_node.get_attribute("state:usdTimecode") db_value = database.state.usdTimecode self.assertTrue(test_node.get_attribute_exists("state:usePath")) attribute = test_node.get_attribute("state:usePath") db_value = database.state.usePath
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnRpResourceExampleDeformerTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnRpResourceExampleDeformer.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_RpResourceExampleDeformer" ( docs="""Allocate CUDA-interoperable RpResource""" ) { token node:type = "omni.graph.nodes.RpResourceExampleDeformer" int node:typeVersion = 1 # 10 attributes custom float inputs:deformScale = 1.0 ( docs="""Deformation control""" ) custom int inputs:displacementAxis = 0 ( docs="""dimension in which mesh is translated""" ) custom uint64[] inputs:pointCountCollection = [] ( docs="""Pointer to point counts collection""" ) custom float inputs:positionScale = 1.0 ( docs="""Deformation control""" ) custom token[] inputs:primPathCollection = [] ( docs="""Pointer to prim path collection""" ) custom uint64[] inputs:resourcePointerCollection = [] ( docs="""Pointer to RpResource collection""" ) custom bool inputs:runDeformerKernel = true ( docs="""Whether cuda kernel will be executed""" ) custom uint64 inputs:stream = 0 ( docs="""Pointer to the CUDA Stream""" ) custom float inputs:timeScale = 0.01 ( docs="""Deformation control""" ) custom bool inputs:verbose = false ( docs="""verbose printing""" ) # 5 attributes custom uint64[] outputs:pointCountCollection ( docs="""Point count for each prim being deformed""" ) custom token[] outputs:primPathCollection ( docs="""Path for each prim being deformed""" ) custom bool outputs:reload = false ( docs="""Force RpResource reload""" ) custom uint64[] outputs:resourcePointerCollection ( docs="""Pointers to RpResources (two resources per prim are assumed -- one for rest positions and one for deformed positions)""" ) custom uint64 outputs:stream ( docs="""Pointer to the CUDA Stream""" ) # 1 attribute custom uint64 state:sequenceCounter = 0 ( docs="""tick counter for animation""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnConstantQuatdTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnConstantQuatd.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ConstantQuatd" ( docs="""Holds a double-precision quaternion constant: A real coefficient and three imaginary coefficients""" ) { token node:type = "omni.graph.nodes.ConstantQuatd" int node:typeVersion = 1 # 1 attribute custom quatd inputs:value = (0.0, 0.0, 0.0, 0.0) ( docs="""The constant value""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnEaseTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnEase.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_Ease" ( docs="""Easing function which iterpolates between a start and end value. Vectors are eased component-wise. The easing functions can be applied to decimal types. Linear: Interpolates between start and finish at a fixed rate. EaseIn: Starts slowly and ends fast according to an exponential, the slope is determined by the 'exponent' input. EaseOut: Same as EaseIn, but starts fast and ends slow EaseInOut: Combines EaseIn and EaseOut SinIn: Starts slowly and ends fast according to a sinusoidal curve SinOut: Same as SinIn, but starts fast and ends slow SinInOut: Combines SinIn and SinOut""" ) { token node:type = "omni.graph.nodes.Ease" int node:typeVersion = 2 # 5 attributes custom token inputs:alpha ( docs="""The normalized time (0 - 1.0). Values outside this range will be clamped""" ) custom int inputs:blendExponent = 2 ( docs="""The blend exponent, which is the degree of the ease curve (1 = linear, 2 = quadratic, 3 = cubic, etc). This only applies to the Ease* functions""" ) custom token inputs:easeFunc = "EaseInOut" ( docs="""The easing function to apply (EaseIn, EaseOut, EaseInOut, Linear, SinIn, SinOut, SinInOut)""" ) custom token inputs:end ( docs="""The end value""" ) custom token inputs:start ( docs="""The start value""" ) # 1 attribute custom token outputs:result ( docs="""The eased result of the function applied to value""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnToRadTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnToRad.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ToRad" ( docs="""Convert degree input into radians""" ) { token node:type = "omni.graph.nodes.ToRad" int node:typeVersion = 1 # 1 attribute custom token inputs:degrees ( docs="""Angle value in degrees to be converted""" ) # 1 attribute custom token outputs:radians ( docs="""Angle value in radians""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnMakeTransformTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnMakeTransform.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_MakeTransform" ( docs="""Make a transformation matrix that performs a translation, rotation (in euler angles), and scale in that order""" ) { token node:type = "omni.graph.nodes.MakeTransform" int node:typeVersion = 1 # 3 attributes custom vector3d inputs:rotationXYZ = (0, 0, 0) ( docs="""The desired orientation in euler angles (XYZ)""" ) custom vector3d inputs:scale = (1, 1, 1) ( docs="""The desired scaling factor about the X, Y, and Z axis respectively""" ) custom vector3d inputs:translation = (0, 0, 0) ( docs="""the desired translation as a vector""" ) # 1 attribute custom matrix4d outputs:transform ( docs="""the resulting transformation matrix""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnModuloTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnModulo.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_Modulo" ( docs="""Computes the modulo of integer inputs (A % B), which is the remainder of A / B If B is zero, the result is zero. If A and B are both non-negative the result is non-negative, otherwise the sign of the result is undefined.""" ) { token node:type = "omni.graph.nodes.Modulo" int node:typeVersion = 1 # 2 attributes custom token inputs:a ( docs="""The dividend of (A % B)""" ) custom token inputs:b ( docs="""The divisor of (A % B)""" ) # 1 attribute custom token outputs:result ( docs="""Modulo (A % B), the remainder of A / B""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnWritePrimMaterialTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnWritePrimMaterial.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_WritePrimMaterial" ( docs="""Given a path to a prim and a path to a material on the current USD stage, assigns the material to the prim. Gives an error if the given prim or material can not be found.""" ) { token node:type = "omni.graph.nodes.WritePrimMaterial" int node:typeVersion = 1 # 3 attributes custom uint inputs:execIn ( docs="""Input execution""" ) custom string inputs:materialPath = "" ( docs="""The path of the material to be assigned to the prim""" ) custom string inputs:primPath = "" ( docs="""Path of the prim to be assigned a material.""" ) # 1 attribute custom uint outputs:execOut ( docs="""Output execution""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnConstantHalf3Template.usda
#usda 1.0 ( doc ="""Generated from node description file OgnConstantHalf3.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ConstantHalf3" ( docs="""Holds a 3-component half-precision constant.""" ) { token node:type = "omni.graph.nodes.ConstantHalf3" int node:typeVersion = 1 # 1 attribute custom half3 inputs:value = (0.0, 0.0, 0.0) ( docs="""The constant value""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnSubtractTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnSubtract.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_Subtract" ( docs="""Subtracts two values of any numeric type.""" ) { token node:type = "omni.graph.nodes.Subtract" int node:typeVersion = 1 # 2 attributes custom token inputs:a ( docs="""The number B is subtracted from""" ) custom token inputs:b ( docs="""The number to subtract from A""" ) # 1 attribute custom token outputs:difference ( docs="""Result of A-B""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnCurveTubeSTTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnCurveTubeST.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_CurveTubeST" ( docs="""Compute curve tube ST values""" ) { token node:type = "omni.graph.nodes.CurveTubeST" int node:typeVersion = 1 # 8 attributes custom int[] inputs:cols = [] ( docs="""Columns of the tubes""" ) custom int[] inputs:curveVertexCounts = [] ( docs="""Vertex counts for the curve points""" ) custom int[] inputs:curveVertexStarts = [] ( docs="""Vertex starting points""" ) custom bool inputs:scaleTLikeS = false ( docs="""If true then scale T the same as S""" ) custom float[] inputs:t = [] ( docs="""T values of the tubes""" ) custom int[] inputs:tubeQuadStarts = [] ( docs="""Vertex index values for the tube quad starting points""" ) custom int[] inputs:tubeSTStarts = [] ( docs="""Vertex index values for the tube ST starting points""" ) custom float[] inputs:width = [] ( docs="""Width of tube positions, if scaling T like S""" ) # 2 attributes custom float2[] outputs:primvars:st ( docs="""Array of computed ST values""" ) custom int[] outputs:primvars:st:indices ( docs="""Array of computed ST indices""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnReadKeyboardStateTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnReadKeyboardState.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ReadKeyboardState" ( docs="""Reads the current state of the keyboard""" ) { token node:type = "omni.graph.nodes.ReadKeyboardState" int node:typeVersion = 1 # 1 attribute custom token inputs:key = "A" ( docs="""The key to check the state of""" ) # 4 attributes custom bool outputs:altOut ( docs="""True if Alt is held""" ) custom bool outputs:ctrlOut ( docs="""True if Ctrl is held""" ) custom bool outputs:isPressed ( docs="""True if the key is currently pressed, false otherwise""" ) custom bool outputs:shiftOut ( docs="""True if Shift is held""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnAsinTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnAsin.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_Asin" ( docs="""Trigonometric operation arcsin of one input in degrees.""" ) { token node:type = "omni.graph.nodes.Asin" int node:typeVersion = 1 # 1 attribute custom token inputs:value ( docs="""Angle value in degrees whose inverse sine is to be found""" ) # 1 attribute custom token outputs:value ( docs="""The arcsin value of the input angle in degrees""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnScaleToSizeTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnScaleToSize.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ScaleToSize" ( docs="""Perform a smooth scaling maneuver, scaling a prim to a desired size tuple given a speed and easing factor""" ) { token node:type = "omni.graph.nodes.ScaleToSize" int node:typeVersion = 1 # 8 attributes custom uint inputs:execIn ( docs="""The input execution""" ) custom float inputs:exponent = 2.0 ( docs="""The blend exponent, which is the degree of the ease curve (1 = linear, 2 = quadratic, 3 = cubic, etc). """ ) custom rel inputs:prim ( docs="""The prim to be scaled""" ) custom string inputs:primPath ( docs="""The source prim to be transformed, used when 'usePath' is true""" ) custom double inputs:speed = 1.0 ( docs="""The peak speed of approach (Units / Second)""" ) custom uint inputs:stop ( docs="""Stops the maneuver""" ) custom vector3d inputs:target = (0.0, 0.0, 0.0) ( docs="""The desired local scale""" ) custom bool inputs:usePath = false ( docs="""When true, the 'primPath' attribute is used, otherwise it will read the connection at the 'prim' attribute""" ) # 1 attribute custom uint outputs:finished ( docs="""The output execution, sent one the maneuver is completed""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnGetMatrix4RotationTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnGetMatrix4Rotation.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_GetMatrix4Rotation" ( docs="""Gets the rotation of the given matrix4d value which represents a linear transformation. Returns euler angles (XYZ)""" ) { token node:type = "omni.graph.nodes.GetMatrix4Rotation" int node:typeVersion = 1 # 1 attribute custom token inputs:matrix ( docs="""The transformation matrix""" ) # 1 attribute custom token outputs:rotation ( docs="""vector representing the rotation component of the transformation (XYZ)""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnConstantQuatfTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnConstantQuatf.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ConstantQuatf" ( docs="""Holds a single-precision quaternion constant: A real coefficient and three imaginary coefficients.""" ) { token node:type = "omni.graph.nodes.ConstantQuatf" int node:typeVersion = 1 # 1 attribute custom quatf inputs:value = (0.0, 0.0, 0.0, 0.0) ( docs="""The constant value""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnCompareTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnCompare.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_Compare" ( docs="""Outputs the truth value of a comparison operation. Tuples are compared in lexicographic order. If one input is an array and the other is a scaler, the scaler will be broadcast to the size of the array""" ) { token node:type = "omni.graph.nodes.Compare" int node:typeVersion = 1 # 3 attributes custom token inputs:a = "any" ( docs="""Input A""" ) custom token inputs:b = "any" ( docs="""Input B""" ) custom token inputs:operation = ">" ( docs="""The comparison operation to perform (>,<,>=,<=,==,!=))""" ) # 1 attribute custom token outputs:result ( docs="""The result of the comparison operation""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnWriteVariableTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnWriteVariable.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_core_WriteVariable" ( docs="""Node that writes a value to a variable""" ) { token node:type = "omni.graph.core.WriteVariable" int node:typeVersion = 1 # 5 attributes custom uint inputs:execIn ( docs="""Input execution state""" ) custom rel inputs:graph ( docs="""Ignored. Do not use""" ) custom token inputs:targetPath ( docs="""Ignored. Do not use.""" ) custom token inputs:value = "any" ( docs="""The new value to be written""" ) custom token inputs:variableName = "" ( docs="""The name of the graph variable to use.""" ) # 2 attributes custom uint outputs:execOut ( docs="""Output execution""" ) custom token outputs:value = "any" ( docs="""The written variable value""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnBooleanExprTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnBooleanExpr.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_BooleanExpr" ( docs="""NOTE: DEPRECATED AS OF 1.26.0 IN FAVOUR OF INDIVIDAL BOOLEAN OP NODES Boolean operation on two inputs. The supported operations are: AND, OR, NAND, NOR, XOR, XNOR""" ) { token node:type = "omni.graph.nodes.BooleanExpr" int node:typeVersion = 1 # 3 attributes custom bool inputs:a = false ( docs="""Input A""" ) custom bool inputs:b = false ( docs="""Input B""" ) custom token inputs:operator = "AND" ( docs="""The boolean operation to perform (AND, OR, NAND, NOR, XOR, XNOR))""" ) # 1 attribute custom bool outputs:result ( docs="""The result of the boolean expression""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnRotateVectorTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnRotateVector.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_RotateVector" ( docs="""Rotates a 3d direction vector by a specified rotation. Accepts 3x3 matrices, 4x4 matrices, euler angles (XYZ), or quaternions For 4x4 matrices, the transformation information in the matrix is ignored and the vector is treated as a 4-component vector where the fourth component is zero. The result is then projected back to a 3-vector. Supports mixed array inputs, eg a single quaternion and an array of vectors.""" ) { token node:type = "omni.graph.nodes.RotateVector" int node:typeVersion = 1 # 2 attributes custom token inputs:rotation ( docs="""The rotation to be applied""" ) custom token inputs:vector ( docs="""The row vector(s) to be rotated""" ) # 1 attribute custom token outputs:result ( docs="""The transformed row vector(s)""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnMultiplyTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnMultiply.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_Multiply" ( docs="""Computes the element-wise product of two inputs A and B (multiplication). If one input has a higher dimension than the other, then the input with lower dimension will be repeated to match the dimension of the other input (broadcasting). eg: scalar * tuple, tuple * array of tuples, scalar * array of tuples.""" ) { token node:type = "omni.graph.nodes.Multiply" int node:typeVersion = 1 # 2 attributes custom token inputs:a ( docs="""First number to multiply""" ) custom token inputs:b ( docs="""Second number to multiply""" ) # 1 attribute custom token outputs:product ( docs="""Product of the two numbers""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnReadPrimBundleTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnReadPrimBundle.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ReadPrimBundle" ( docs="""Exposes the authored attributes for a single Prim on the USD stage as a bundle output on this node. When this node computes it will read the latest attribute values from the target Prim into the bundle attributes. It will also expose the world matrix if available under the attribute "worldMatrix". It can optionally compute the bounding box of the prim, and expose it under the following attributes: "bboxTransform", "bboxMinCorner", "bboxMaxCorner".""" ) { token node:type = "omni.graph.nodes.ReadPrimBundle" int node:typeVersion = 1 # 6 attributes custom bool inputs:computeBoundingBox = false ( docs="""Compute and store local bounding box of a prim and its children.""" ) custom bool inputs:forceUSDRead = false ( docs="""This flag forces to re-read from USD each time. If set, the node will re-fetch the value from USD on each execution. Otherwise it will read from USD only once if the value is not yet in Fabric""" ) custom rel inputs:prim ( docs="""The prim whose attributes are to be read""" ) custom token inputs:primPath ( docs="""The path of the prim to be read when 'usePath' is true""" ) custom timecode inputs:usdTimecode = -1 ( docs="""The time at which to evaluate the transform of the USD prim. A value of "-1" indicates that the default USD time stamp should be used""" ) custom bool inputs:usePath = false ( docs="""When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute""" ) # 1 attribute def Output "outputs_primBundle" ( docs="""A bundle of the source Prim attributes. In addition to the data attributes, there is a token attribute named sourcePrimPath which contains the path of the Prim being read""" ) { } # 2 attributes custom uint64 state:target = 0 ( docs="""The path ID of the targeted prim last frame""" ) custom timecode state:usdTimecode = -1 ( docs="""The time at which previous run has been evaluated""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnCopyAttrTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnCopyAttr.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_CopyAttribute" ( docs="""Copies all attributes from one input bundle and specified attributes from a second input bundle to the output bundle.""" ) { token node:type = "omni.graph.nodes.CopyAttribute" int node:typeVersion = 1 # 4 attributes custom rel inputs:fullData ( docs="""Collection of attributes to fully copy to the output""" ) custom token inputs:inputAttrNames = "" ( docs="""Comma or space separated text, listing the names of attributes to copy from partialData""" ) custom token inputs:outputAttrNames = "" ( docs="""Comma or space separated text, listing the new names of attributes copied from partialData""" ) custom rel inputs:partialData ( docs="""Collection of attributes from which to select named attributes""" ) # 1 attribute def Output "outputs_data" ( docs="""Collection of attributes consisting of all attributes from input 'fullData' and selected inputs from input 'partialData'""" ) { } } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnGpuInteropRenderProductEntryTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnGpuInteropRenderProductEntry.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_GpuInteropRenderProductEntry" ( docs="""Entry node for post-processing hydra render results for a single view """ ) { token node:type = "omni.graph.nodes.GpuInteropRenderProductEntry" int node:typeVersion = 1 # 4 attributes custom uint outputs:exec ( docs="""Trigger for scheduling dependencies""" ) custom uint64 outputs:gpu ( docs="""Pointer to shared context containing gpu foundations""" ) custom uint64 outputs:rp ( docs="""Pointer to render product for this view""" ) custom uint64 outputs:swhFrameNumber ( docs="""Fabric frame number""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnATan2Template.usda
#usda 1.0 ( doc ="""Generated from node description file OgnATan2.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ATan2" ( docs="""Outputs the arc tangent of a/b in degrees""" ) { token node:type = "omni.graph.nodes.ATan2" int node:typeVersion = 1 # 2 attributes custom token inputs:a ( docs="""Input A""" ) custom token inputs:b ( docs="""Input B""" ) # 1 attribute custom token outputs:result ( docs="""The result of ATan2(A,B)""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnPartialSumTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnPartialSum.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_PartialSum" ( docs="""Compute the partial sums of the input integer array named 'array' and put the result in an output integer array named 'partialSum'. A partial sum is the sum of all of the elements up to but not including a certain point in an array, so output element 0 is always 0, element 1 is array[0], element 2 is array[0] + array[1], etc.""" ) { token node:type = "omni.graph.nodes.PartialSum" int node:typeVersion = 1 # 1 attribute custom int[] inputs:array = [] ( docs="""List of integers whose partial sum is to be computed""" ) # 1 attribute custom int[] outputs:partialSum = [] ( docs="""Array whose nth value equals the nth partial sum of the input 'array'""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnNthRootTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnNthRoot.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_NthRoot" ( docs="""Computes the nth root of value. The result is the same type as the input value if the numerator is a decimal type. Otherwise the result is a double. If the input is a vector or matrix, then the node will calculate the square root of each element , and output a vector or matrix of the same size. Note that there are combinations of inputs that can result in a loss of precision due to different value ranges. Taking roots of a negative number will give a result of NaN except for cube root.""" ) { token node:type = "omni.graph.nodes.NthRoot" int node:typeVersion = 1 # 2 attributes custom int inputs:nthRoot = 2 ( docs="""Take the nth root""" ) custom token inputs:value ( docs="""The input value""" ) # 1 attribute custom token outputs:result ( docs="""Result of square root""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnReadOmniGraphValueTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnReadOmniGraphValue.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ReadOmniGraphValue" ( docs="""Imports a data value from the Fabric cache that is located at the given path and attribute name. This is for data that is not already present in OmniGraph as that data can be accessed through a direct connection to the underlying OmniGraph node.""" ) { token node:type = "omni.graph.nodes.ReadOmniGraphValue" int node:typeVersion = 1 # 2 attributes custom token inputs:name = "" ( docs="""The name of the attribute to be queried""" ) custom string inputs:path = "" ( docs="""The path to the Fabric data bucket in which the attribute being queried lives.""" ) # 1 attribute custom token outputs:value = "any" ( docs="""The attribute value""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnNormalizeTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnNormalize.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_Normalize" ( docs="""Normalize the input vector. If the input vector has a magnitude of zero, the null vector is returned.""" ) { token node:type = "omni.graph.nodes.Normalize" int node:typeVersion = 1 # 1 attribute custom token inputs:vector ( docs="""Vector to normalize""" ) # 1 attribute custom token outputs:result ( docs="""Normalized vector""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnArrayGetSizeTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnArrayGetSize.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ArrayGetSize" ( docs="""Returns the number of elements in an array""" ) { token node:type = "omni.graph.nodes.ArrayGetSize" int node:typeVersion = 1 # 1 attribute custom token inputs:array ( docs="""The array in question""" ) # 1 attribute custom int outputs:size ( docs="""The size of the array""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnIsPrimActiveTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnIsPrimActive.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_IsPrimActive" ( docs="""Query if a Prim is active or not in the stage.""" ) { token node:type = "omni.graph.nodes.IsPrimActive" int node:typeVersion = 1 # 1 attribute custom string inputs:prim = "" ( docs="""The prim to be queried""" ) # 1 attribute custom bool outputs:active ( docs="""Whether the prim is active or not""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnArrayFillTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnArrayFill.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ArrayFill" ( docs="""Creates a copy of the input array, filled with the given value""" ) { token node:type = "omni.graph.nodes.ArrayFill" int node:typeVersion = 1 # 2 attributes custom token inputs:array ( docs="""The array to be modified""" ) custom token inputs:fillValue ( docs="""The value to be repeated in the new array""" ) # 1 attribute custom token outputs:array ( docs="""The modified array""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnReadTimeTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnReadTime.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ReadTime" ( docs="""Holds the values related to the current global time and the timeline""" ) { token node:type = "omni.graph.nodes.ReadTime" int node:typeVersion = 1 # 6 attributes custom double outputs:absoluteSimTime ( docs="""The accumulated total of elapsed times between rendered frames""" ) custom double outputs:deltaSeconds ( docs="""The number of seconds elapsed since the last OmniGraph update""" ) custom double outputs:frame ( docs="""The global animation time in frames, equivalent to (time * fps), during playback""" ) custom bool outputs:isPlaying ( docs="""True during global animation timeline playback""" ) custom double outputs:time ( docs="""The global animation time in seconds during playback""" ) custom double outputs:timeSinceStart ( docs="""Elapsed time since the App started""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnReadPrimMaterialTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnReadPrimMaterial.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ReadPrimMaterial" ( docs="""Given a path to a prim on the current USD stage, outputs the material of the prim. Gives an error if the given prim can not be found.""" ) { token node:type = "omni.graph.nodes.ReadPrimMaterial" int node:typeVersion = 1 # 1 attribute custom string inputs:primPath = "" ( docs="""Path of the prim with the material to be read.""" ) # 1 attribute custom string outputs:material ( docs="""The material of the inputed prim""" ) } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/usd/OgnToDegTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnToDeg.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_nodes_ToDeg" ( docs="""Convert radian input into degrees""" ) { token node:type = "omni.graph.nodes.ToDeg" int node:typeVersion = 1 # 1 attribute custom token inputs:radians ( docs="""Angle value in radians to be converted""" ) # 1 attribute custom token outputs:degrees ( docs="""Angle value in degrees""" ) } }