file_path
stringlengths 21
224
| content
stringlengths 0
80.8M
|
---|---|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial26/OgnTutorialGenericMathNode.ogn | {
"GenericMathNode": {
"description": [
"This is a tutorial node. It is functionally equivalent to the built-in Multiply node,",
"but written in python as a practical demonstration of using extended attributes to ",
"write math nodes that work with any numeric types, including arrays and tuples."
],
"version": 1,
"language": "python",
"uiName": "Tutorial Python Node: Generic Math Node",
"categories": "tutorials",
"inputs": {
"a": {
"type": ["numerics"],
"description": "First number to multiply",
"uiName": "A"
},
"b": {
"type": ["numerics"],
"description": "Second number to multiply",
"uiName": "B"
}
},
"outputs": {
"product": {
"type": ["numerics"],
"description": "Product of the two numbers",
"uiName": "Product"
}
},
"tests" : [
{ "inputs:a": {"type": "int", "value": 2}, "inputs:b": {"type": "int", "value": 3}, "outputs:product": {"type": "int", "value": 6} },
{ "inputs:a": {"type": "int", "value": 2}, "inputs:b": {"type": "int64", "value": 3}, "outputs:product": {"type": "int64", "value": 6} },
{ "inputs:a": {"type": "int", "value": 2}, "inputs:b": {"type": "half", "value": 3}, "outputs:product": {"type": "float", "value": 6} },
{ "inputs:a": {"type": "int", "value": 2}, "inputs:b": {"type": "float", "value": 3}, "outputs:product": {"type": "float", "value": 6} },
{ "inputs:a": {"type": "int", "value": 2}, "inputs:b": {"type": "double", "value": 3}, "outputs:product": {"type": "double", "value": 6} },
{ "inputs:a": {"type": "int64", "value": 2}, "inputs:b": {"type": "int64", "value": 3}, "outputs:product": {"type": "int64", "value": 6} },
{ "inputs:a": {"type": "int64", "value": 2}, "inputs:b": {"type": "half", "value": 3}, "outputs:product": {"type": "double", "value": 6} },
{ "inputs:a": {"type": "int64", "value": 2}, "inputs:b": {"type": "float", "value": 3}, "outputs:product": {"type": "double", "value": 6} },
{ "inputs:a": {"type": "int64", "value": 2}, "inputs:b": {"type": "double", "value": 3}, "outputs:product": {"type": "double", "value": 6} },
{ "inputs:a": {"type": "half", "value": 2}, "inputs:b": {"type": "half", "value": 3}, "outputs:product": {"type": "half", "value": 6} },
{ "inputs:a": {"type": "half", "value": 2}, "inputs:b": {"type": "float", "value": 3}, "outputs:product": {"type": "float", "value": 6} },
{ "inputs:a": {"type": "half", "value": 2}, "inputs:b": {"type": "double", "value": 3}, "outputs:product": {"type": "double", "value": 6} },
{ "inputs:a": {"type": "float", "value": 2}, "inputs:b": {"type": "float", "value": 3}, "outputs:product": {"type": "float", "value": 6} },
{ "inputs:a": {"type": "float", "value": 2}, "inputs:b": {"type": "double", "value": 3}, "outputs:product": {"type": "double", "value": 6} },
{ "inputs:a": {"type": "double", "value": 2}, "inputs:b": {"type": "double", "value": 3}, "outputs:product": {"type": "double", "value": 6} },
{
"inputs:a": {"type": "double[2]", "value": [1.0, 42.0]}, "inputs:b": {"type": "double[2]", "value": [2.0, 1.0]},
"outputs:product": {"type": "double[2]", "value": [2.0, 42.0]}
},
{
"inputs:a": {"type": "double[]", "value": [1.0, 42.0]}, "inputs:b": {"type": "double", "value": 2.0},
"outputs:product": {"type": "double[]", "value": [2.0, 84.0]}
},
{
"inputs:a": {"type": "double[2][]", "value": [[10, 5], [1, 1]]},
"inputs:b": {"type": "double[2]", "value": [5, 5]},
"outputs:product": {"type": "double[2][]", "value": [[50, 25], [5, 5]]}
}
]
}
} |
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialTupleData.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:a_double2', [2.1, 3.2], False],
['outputs:a_float2', [5.4, 6.5], False],
['outputs:a_half2', [8.0, 9.0], False],
['outputs:a_int2', [11, 12], False],
['outputs:a_float3', [7.6, 8.7, 9.8], False],
['outputs:a_double3', [2.1, 3.2, 4.3], False],
],
},
{
'inputs': [
['inputs:a_double2', [2.1, 3.2], False],
['inputs:a_float2', [5.1, 6.2], False],
['inputs:a_half2', [8.0, 9.0], False],
['inputs:a_int2', [11, 12], False],
['inputs:a_float3', [7.1, 8.2, 9.3], False],
['inputs:a_double3', [10.1, 11.2, 12.3], False],
],
'outputs': [
['outputs:a_double2', [3.1, 4.2], False],
['outputs:a_float2', [6.1, 7.2], False],
['outputs:a_half2', [9.0, 10.0], False],
['outputs:a_int2', [12, 13], False],
['outputs:a_float3', [8.1, 9.2, 10.3], False],
['outputs:a_double3', [11.1, 12.2, 13.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_tutorials_TupleData", "omni.tutorials.TupleData", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.tutorials.TupleData 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_tutorials_TupleData","omni.tutorials.TupleData", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.tutorials.TupleData 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_tutorials_TupleData", "omni.tutorials.TupleData", 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.tutorials.TupleData User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialTupleDataDatabase import OgnTutorialTupleDataDatabase
test_file_name = "OgnTutorialTupleDataTemplate.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_tutorials_TupleData")
database = OgnTutorialTupleDataDatabase(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:a_double2"))
attribute = test_node.get_attribute("inputs:a_double2")
db_value = database.inputs.a_double2
expected_value = [1.1, 2.2]
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:a_double3"))
attribute = test_node.get_attribute("inputs:a_double3")
db_value = database.inputs.a_double3
expected_value = [1.1, 2.2, 3.3]
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:a_float2"))
attribute = test_node.get_attribute("inputs:a_float2")
db_value = database.inputs.a_float2
expected_value = [4.4, 5.5]
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:a_float3"))
attribute = test_node.get_attribute("inputs:a_float3")
db_value = database.inputs.a_float3
expected_value = [6.6, 7.7, 8.8]
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:a_half2"))
attribute = test_node.get_attribute("inputs:a_half2")
db_value = database.inputs.a_half2
expected_value = [7.0, 8.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:a_int2"))
attribute = test_node.get_attribute("inputs:a_int2")
db_value = database.inputs.a_int2
expected_value = [10, 11]
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:a_double2"))
attribute = test_node.get_attribute("outputs:a_double2")
db_value = database.outputs.a_double2
self.assertTrue(test_node.get_attribute_exists("outputs:a_double3"))
attribute = test_node.get_attribute("outputs:a_double3")
db_value = database.outputs.a_double3
self.assertTrue(test_node.get_attribute_exists("outputs:a_float2"))
attribute = test_node.get_attribute("outputs:a_float2")
db_value = database.outputs.a_float2
self.assertTrue(test_node.get_attribute_exists("outputs:a_float3"))
attribute = test_node.get_attribute("outputs:a_float3")
db_value = database.outputs.a_float3
self.assertTrue(test_node.get_attribute_exists("outputs:a_half2"))
attribute = test_node.get_attribute("outputs:a_half2")
db_value = database.outputs.a_half2
self.assertTrue(test_node.get_attribute_exists("outputs:a_int2"))
attribute = test_node.get_attribute("outputs:a_int2")
db_value = database.outputs.a_int2
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialCpuGpuBundlesPy.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.tutorials.ogn.OgnTutorialCpuGpuBundlesPyDatabase import OgnTutorialCpuGpuBundlesPyDatabase
test_file_name = "OgnTutorialCpuGpuBundlesPyTemplate.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_tutorials_CpuGpuBundlesPy")
database = OgnTutorialCpuGpuBundlesPyDatabase(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:cpuBundle"))
attribute = test_node.get_attribute("inputs:cpuBundle")
db_value = database.inputs.cpuBundle
self.assertTrue(test_node.get_attribute_exists("inputs:gpu"))
attribute = test_node.get_attribute("inputs:gpu")
db_value = database.inputs.gpu
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:gpuBundle"))
attribute = test_node.get_attribute("inputs:gpuBundle")
self.assertTrue(test_node.get_attribute_exists("outputs_cpuGpuBundle"))
attribute = test_node.get_attribute("outputs_cpuGpuBundle")
db_value = database.outputs.cpuGpuBundle
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialCpuGpuExtended.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:cpuData', {'type': 'pointf[3][]', 'value': [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]}, False],
['inputs:gpuData', {'type': 'pointf[3][]', 'value': [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]]}, True],
['inputs:gpu', False, False],
],
'outputs': [
['outputs:cpuGpuSum', {'type': 'pointf[3][]', 'value': [[8.0, 10.0, 12.0], [14.0, 16.0, 18.0]]}, False],
],
},
{
'inputs': [
['inputs:cpuData', {'type': 'pointf[3][]', 'value': [[4.0, 5.0, 6.0]]}, False],
['inputs:gpuData', {'type': 'pointf[3][]', 'value': [[7.0, 8.0, 9.0]]}, True],
['inputs:gpu', True, False],
],
'outputs': [
['outputs:cpuGpuSum', {'type': 'pointf[3][]', 'value': [[11.0, 13.0, 15.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_tutorials_CpuGpuExtended", "omni.graph.tutorials.CpuGpuExtended", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.CpuGpuExtended 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_tutorials_CpuGpuExtended","omni.graph.tutorials.CpuGpuExtended", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.CpuGpuExtended User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialCpuGpuExtendedDatabase import OgnTutorialCpuGpuExtendedDatabase
test_file_name = "OgnTutorialCpuGpuExtendedTemplate.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_tutorials_CpuGpuExtended")
database = OgnTutorialCpuGpuExtendedDatabase(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:gpu"))
attribute = test_node.get_attribute("inputs:gpu")
db_value = database.inputs.gpu
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))
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialDynamicAttributes.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.tutorials.ogn.OgnTutorialDynamicAttributesDatabase import OgnTutorialDynamicAttributesDatabase
test_file_name = "OgnTutorialDynamicAttributesTemplate.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_tutorials_DynamicAttributes")
database = OgnTutorialDynamicAttributesDatabase(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
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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialCpuGpuBundles.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.tutorials.ogn.OgnTutorialCpuGpuBundlesDatabase import OgnTutorialCpuGpuBundlesDatabase
test_file_name = "OgnTutorialCpuGpuBundlesTemplate.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_tutorials_CpuGpuBundles")
database = OgnTutorialCpuGpuBundlesDatabase(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:cpuBundle"))
attribute = test_node.get_attribute("inputs:cpuBundle")
db_value = database.inputs.cpuBundle
self.assertTrue(test_node.get_attribute_exists("inputs:gpu"))
attribute = test_node.get_attribute("inputs:gpu")
db_value = database.inputs.gpu
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:gpuBundle"))
attribute = test_node.get_attribute("inputs:gpuBundle")
self.assertTrue(test_node.get_attribute_exists("outputs_cpuGpuBundle"))
attribute = test_node.get_attribute("outputs_cpuGpuBundle")
db_value = database.outputs.cpuGpuBundle
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialCudaDataCpu.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:multiplier', [1.0, 2.0, 3.0], True],
['inputs:points', [[1.0, 1.0, 1.0], [2.0, 2.0, 2.0], [3.0, 3.0, 3.0]], True],
],
'outputs': [
['outputs:points', [[1.0, 2.0, 3.0], [2.0, 4.0, 6.0], [3.0, 6.0, 9.0]], True],
],
},
]
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_tutorials_CudaCpuArrays", "omni.graph.tutorials.CudaCpuArrays", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.CudaCpuArrays 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_tutorials_CudaCpuArrays","omni.graph.tutorials.CudaCpuArrays", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.CudaCpuArrays User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialCudaDataCpuDatabase import OgnTutorialCudaDataCpuDatabase
test_file_name = "OgnTutorialCudaDataCpuTemplate.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_tutorials_CudaCpuArrays")
database = OgnTutorialCudaDataCpuDatabase(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:multiplier"))
attribute = test_node.get_attribute("inputs:multiplier")
expected_value = [1.0, 1.0, 1.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("inputs:points"))
attribute = test_node.get_attribute("inputs:points")
db_value = database.inputs.points.cpu
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:points"))
attribute = test_node.get_attribute("outputs:points")
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialCudaDataCpuPy.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.tutorials.ogn.OgnTutorialCudaDataCpuPyDatabase import OgnTutorialCudaDataCpuPyDatabase
test_file_name = "OgnTutorialCudaDataCpuPyTemplate.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_tutorials_CudaCpuArraysPy")
database = OgnTutorialCudaDataCpuPyDatabase(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:multiplier"))
attribute = test_node.get_attribute("inputs:multiplier")
expected_value = [1.0, 1.0, 1.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("inputs:points"))
attribute = test_node.get_attribute("inputs:points")
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("outputs_outBundle"))
attribute = test_node.get_attribute("outputs_outBundle")
db_value = database.outputs.outBundle
self.assertTrue(test_node.get_attribute_exists("outputs:points"))
attribute = test_node.get_attribute("outputs:points")
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialDynamicAttributesPy.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.tutorials.ogn.OgnTutorialDynamicAttributesPyDatabase import OgnTutorialDynamicAttributesPyDatabase
test_file_name = "OgnTutorialDynamicAttributesPyTemplate.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_tutorials_DynamicAttributesPy")
database = OgnTutorialDynamicAttributesPyDatabase(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
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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialSIMDAdd.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.tutorials.ogn.OgnTutorialSIMDAddDatabase import OgnTutorialSIMDAddDatabase
test_file_name = "OgnTutorialSIMDAddTemplate.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_tutorials_TutorialSIMDFloatAdd")
database = OgnTutorialSIMDAddDatabase(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:a"))
attribute = test_node.get_attribute("inputs:a")
db_value = database.inputs.a
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:b"))
attribute = test_node.get_attribute("inputs:b")
db_value = database.inputs.b
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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialStateAttributesPy.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 = [
{
'state_set': [
['state:monotonic', 7, False],
],
'state_get': [
['state:reset', False, False],
['state:monotonic', 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_tutorials_StateAttributesPy", "omni.graph.tutorials.StateAttributesPy", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.StateAttributesPy 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_tutorials_StateAttributesPy","omni.graph.tutorials.StateAttributesPy", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.StateAttributesPy User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialStateAttributesPyDatabase import OgnTutorialStateAttributesPyDatabase
test_file_name = "OgnTutorialStateAttributesPyTemplate.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_tutorials_StateAttributesPy")
database = OgnTutorialStateAttributesPyDatabase(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:ignored"))
attribute = test_node.get_attribute("inputs:ignored")
db_value = database.inputs.ignored
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("state:monotonic"))
attribute = test_node.get_attribute("state:monotonic")
db_value = database.state.monotonic
self.assertTrue(test_node.get_attribute_exists("state:reset"))
attribute = test_node.get_attribute("state:reset")
db_value = database.state.reset
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialArrayData.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:original', [1.0, 2.0, 3.0], False],
['inputs:gates', [True, False, True], False],
['inputs:multiplier', 2.0, False],
],
'outputs': [
['outputs:result', [2.0, 2.0, 6.0], False],
['outputs:negativeValues', [False, False, False], False],
['outputs:infoSize', 13, False],
],
},
{
'inputs': [
['inputs:original', [10.0, -20.0, 30.0], False],
['inputs:gates', [True, False, True], False],
],
'outputs': [
['outputs:result', [10.0, -20.0, 30.0], False],
['outputs:negativeValues', [False, True, False], False],
],
},
{
'inputs': [
['inputs:info', ["Hello", "lamp\"post", "what'cha", "knowing"], False],
],
'outputs': [
['outputs:infoSize', 29, 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_tutorials_ArrayData", "omni.graph.tutorials.ArrayData", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.ArrayData 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_tutorials_ArrayData","omni.graph.tutorials.ArrayData", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.ArrayData 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_tutorials_ArrayData", "omni.graph.tutorials.ArrayData", 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.tutorials.ArrayData User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialArrayDataDatabase import OgnTutorialArrayDataDatabase
test_file_name = "OgnTutorialArrayDataTemplate.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_tutorials_ArrayData")
database = OgnTutorialArrayDataDatabase(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:gates"))
attribute = test_node.get_attribute("inputs:gates")
db_value = database.inputs.gates
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:info"))
attribute = test_node.get_attribute("inputs:info")
db_value = database.inputs.info
expected_value = ['There', 'is', 'no', 'data']
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:multiplier"))
attribute = test_node.get_attribute("inputs:multiplier")
db_value = database.inputs.multiplier
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:original"))
attribute = test_node.get_attribute("inputs:original")
db_value = database.inputs.original
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:infoSize"))
attribute = test_node.get_attribute("outputs:infoSize")
db_value = database.outputs.infoSize
self.assertTrue(test_node.get_attribute_exists("outputs:negativeValues"))
attribute = test_node.get_attribute("outputs:negativeValues")
db_value = database.outputs.negativeValues
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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialBundlesPy.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.tutorials.ogn.OgnTutorialBundlesPyDatabase import OgnTutorialBundlesPyDatabase
test_file_name = "OgnTutorialBundlesPyTemplate.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_tutorials_BundleManipulationPy")
database = OgnTutorialBundlesPyDatabase(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:filteredBundle"))
attribute = test_node.get_attribute("inputs:filteredBundle")
db_value = database.inputs.filteredBundle
self.assertTrue(test_node.get_attribute_exists("inputs:filters"))
attribute = test_node.get_attribute("inputs:filters")
db_value = database.inputs.filters
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:fullBundle"))
attribute = test_node.get_attribute("inputs:fullBundle")
db_value = database.inputs.fullBundle
self.assertTrue(test_node.get_attribute_exists("outputs_combinedBundle"))
attribute = test_node.get_attribute("outputs_combinedBundle")
db_value = database.outputs.combinedBundle
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialTokens.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:valuesToCheck', ["red", "Red", "magenta", "green", "cyan", "blue", "yellow"], False],
],
'outputs': [
['outputs:isColor', [True, False, False, True, False, 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_tutorials_Tokens", "omni.graph.tutorials.Tokens", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.Tokens 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_tutorials_Tokens","omni.graph.tutorials.Tokens", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.Tokens 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_tutorials_Tokens", "omni.graph.tutorials.Tokens", 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.tutorials.Tokens User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialTokensDatabase import OgnTutorialTokensDatabase
test_file_name = "OgnTutorialTokensTemplate.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_tutorials_Tokens")
database = OgnTutorialTokensDatabase(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:valuesToCheck"))
attribute = test_node.get_attribute("inputs:valuesToCheck")
db_value = database.inputs.valuesToCheck
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:isColor"))
attribute = test_node.get_attribute("outputs:isColor")
db_value = database.outputs.isColor
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialVectorizedABIPassthrough.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', 1, False],
],
'outputs': [
['outputs:value', 1, False],
],
},
{
'inputs': [
['inputs:value', 2, False],
],
'outputs': [
['outputs:value', 2, False],
],
},
{
'inputs': [
['inputs:value', 3, False],
],
'outputs': [
['outputs:value', 3, False],
],
},
{
'inputs': [
['inputs:value', 4, False],
],
'outputs': [
['outputs:value', 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_tutorials_TutorialVectorizedABIPassThrough", "omni.graph.tutorials.TutorialVectorizedABIPassThrough", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.TutorialVectorizedABIPassThrough 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_tutorials_TutorialVectorizedABIPassThrough","omni.graph.tutorials.TutorialVectorizedABIPassThrough", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.TutorialVectorizedABIPassThrough User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialVectorizedABIPassthroughDatabase import OgnTutorialVectorizedABIPassthroughDatabase
test_file_name = "OgnTutorialVectorizedABIPassthroughTemplate.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_tutorials_TutorialVectorizedABIPassThrough")
database = OgnTutorialVectorizedABIPassthroughDatabase(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))
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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialABIPy.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:color', [0.2, 0.4, 0.4], False],
],
'outputs': [
['outputs:h', 0.5, False],
['outputs:s', 0.5, False],
['outputs:v', 0.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_tutorials_AbiPy", "omni.graph.tutorials.AbiPy", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.AbiPy 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_tutorials_AbiPy","omni.graph.tutorials.AbiPy", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.AbiPy User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialABIPyDatabase import OgnTutorialABIPyDatabase
test_file_name = "OgnTutorialABIPyTemplate.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_tutorials_AbiPy")
database = OgnTutorialABIPyDatabase(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:color"))
attribute = test_node.get_attribute("inputs:color")
db_value = database.inputs.color
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))
self.assertTrue(test_node.get_attribute_exists("outputs:h"))
attribute = test_node.get_attribute("outputs:h")
db_value = database.outputs.h
self.assertTrue(test_node.get_attribute_exists("outputs:s"))
attribute = test_node.get_attribute("outputs:s")
db_value = database.outputs.s
self.assertTrue(test_node.get_attribute_exists("outputs:v"))
attribute = test_node.get_attribute("outputs:v")
db_value = database.outputs.v
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialCpuGpuData.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:is_gpu', False, False],
['inputs:a', 1.0, True],
['inputs:b', 2.0, True],
],
'outputs': [
['outputs:sum', 3.0, False],
],
},
{
'inputs': [
['inputs:is_gpu', False, False],
['inputs:a', 5.0, True],
['inputs:b', 3.0, True],
],
'outputs': [
['outputs:sum', 8.0, False],
],
},
{
'inputs': [
['inputs:is_gpu', False, False],
['inputs:points', [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]], True],
['inputs:multiplier', [2.0, 3.0, 4.0], True],
],
'outputs': [
['outputs:points', [[2.0, 6.0, 12.0], [4.0, 9.0, 16.0]], False],
],
},
{
'inputs': [
['inputs:is_gpu', True, False],
['inputs:a', 1.0, True],
['inputs:b', 2.0, True],
['inputs:points', [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]], True],
['inputs:multiplier', [2.0, 3.0, 4.0], True],
],
},
]
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_tutorials_CpuGpuData", "omni.graph.tutorials.CpuGpuData", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.CpuGpuData 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_tutorials_CpuGpuData","omni.graph.tutorials.CpuGpuData", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.CpuGpuData User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialCpuGpuDataDatabase import OgnTutorialCpuGpuDataDatabase
test_file_name = "OgnTutorialCpuGpuDataTemplate.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_tutorials_CpuGpuData")
database = OgnTutorialCpuGpuDataDatabase(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:a"))
attribute = test_node.get_attribute("inputs:a")
db_value = database.inputs.a.cpu
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:b"))
attribute = test_node.get_attribute("inputs:b")
db_value = database.inputs.b.cpu
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:is_gpu"))
attribute = test_node.get_attribute("inputs:is_gpu")
db_value = database.inputs.is_gpu
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:multiplier"))
attribute = test_node.get_attribute("inputs:multiplier")
db_value = database.inputs.multiplier.cpu
expected_value = [1.0, 1.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:points"))
attribute = test_node.get_attribute("inputs:points")
db_value = database.inputs.points.cpu
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:points"))
attribute = test_node.get_attribute("outputs:points")
db_value = database.outputs.points.cpu
self.assertTrue(test_node.get_attribute_exists("outputs:sum"))
attribute = test_node.get_attribute("outputs:sum")
db_value = database.outputs.sum.cpu
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialBundleDataPy.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.tutorials.ogn.OgnTutorialBundleDataPyDatabase import OgnTutorialBundleDataPyDatabase
test_file_name = "OgnTutorialBundleDataPyTemplate.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_tutorials_BundleDataPy")
database = OgnTutorialBundleDataPyDatabase(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:bundle"))
attribute = test_node.get_attribute("inputs:bundle")
db_value = database.inputs.bundle
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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialCudaData.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', 1.0, True],
['inputs:b', 2.0, True],
['inputs:half', 1.0, True],
['inputs:color', [0.5, 0.6, 0.7], True],
['inputs:matrix', [1.0, 2.0, 3.0, 4.0, 2.0, 3.0, 4.0, 5.0, 3.0, 4.0, 5.0, 6.0, 4.0, 5.0, 6.0, 7.0], True],
['inputs:points', [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]], True],
['inputs:multiplier', [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_tutorials_CudaData", "omni.graph.tutorials.CudaData", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.CudaData 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_tutorials_CudaData","omni.graph.tutorials.CudaData", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.CudaData 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_tutorials_CudaData", "omni.graph.tutorials.CudaData", 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.tutorials.CudaData User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialCudaDataDatabase import OgnTutorialCudaDataDatabase
test_file_name = "OgnTutorialCudaDataTemplate.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_tutorials_CudaData")
database = OgnTutorialCudaDataDatabase(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:a"))
attribute = test_node.get_attribute("inputs:a")
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("inputs:b"))
attribute = test_node.get_attribute("inputs:b")
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("inputs:color"))
attribute = test_node.get_attribute("inputs:color")
expected_value = [1.0, 0.5, 1.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("inputs:half"))
attribute = test_node.get_attribute("inputs:half")
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("inputs:matrix"))
attribute = test_node.get_attribute("inputs:matrix")
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))
self.assertTrue(test_node.get_attribute_exists("inputs:multiplier"))
attribute = test_node.get_attribute("inputs:multiplier")
db_value = database.inputs.multiplier
expected_value = [1.0, 1.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:points"))
attribute = test_node.get_attribute("inputs:points")
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("outputs:color"))
attribute = test_node.get_attribute("outputs:color")
self.assertTrue(test_node.get_attribute_exists("outputs:half"))
attribute = test_node.get_attribute("outputs:half")
self.assertTrue(test_node.get_attribute_exists("outputs:matrix"))
attribute = test_node.get_attribute("outputs:matrix")
self.assertTrue(test_node.get_attribute_exists("outputs:points"))
attribute = test_node.get_attribute("outputs:points")
self.assertTrue(test_node.get_attribute_exists("outputs:sum"))
attribute = test_node.get_attribute("outputs:sum")
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialGenericMathNode.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': 'int', 'value': 2}, False],
['inputs:b', {'type': 'int', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'int', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 2}, False],
['inputs:b', {'type': 'int64', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'int64', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 2}, False],
['inputs:b', {'type': 'half', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'float', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 2}, False],
['inputs:b', {'type': 'float', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'float', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 2}, False],
['inputs:b', {'type': 'double', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 2}, False],
['inputs:b', {'type': 'int64', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'int64', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 2}, False],
['inputs:b', {'type': 'half', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 2}, False],
['inputs:b', {'type': 'float', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 2}, False],
['inputs:b', {'type': 'double', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 2}, False],
['inputs:b', {'type': 'half', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'half', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 2}, False],
['inputs:b', {'type': 'float', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'float', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 2}, False],
['inputs:b', {'type': 'double', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 2}, False],
['inputs:b', {'type': 'float', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'float', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 2}, False],
['inputs:b', {'type': 'double', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 2}, False],
['inputs:b', {'type': 'double', 'value': 3}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 6}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2]', 'value': [1.0, 42.0]}, False],
['inputs:b', {'type': 'double[2]', 'value': [2.0, 1.0]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2]', 'value': [2.0, 42.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[]', 'value': [1.0, 42.0]}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:product', {'type': 'double[]', 'value': [2.0, 84.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:b', {'type': 'double[2]', 'value': [5, 5]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2][]', 'value': [[50, 25], [5, 5]]}, 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_tutorials_GenericMathNode", "omni.graph.tutorials.GenericMathNode", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.GenericMathNode 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_tutorials_GenericMathNode","omni.graph.tutorials.GenericMathNode", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.GenericMathNode User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialGenericMathNodeDatabase import OgnTutorialGenericMathNodeDatabase
test_file_name = "OgnTutorialGenericMathNodeTemplate.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_tutorials_GenericMathNode")
database = OgnTutorialGenericMathNodeDatabase(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.tutorials/omni/graph/tutorials/ogn/tests/__init__.py | """====== GENERATED BY omni.graph.tools - DO NOT EDIT ======"""
import omni.graph.tools._internal as ogi
ogi.import_tests_in_directory(__file__, __name__)
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialSimpleDataPy.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_bool', False, False],
],
'outputs': [
['outputs:a_bool', True, False],
],
},
{
'inputs': [
['inputs:a_bool', True, False],
],
'outputs': [
['outputs:a_bool', False, False],
['outputs:a_a_boolUiName', "Simple Boolean Input", False],
['outputs:a_nodeTypeUiName', "Tutorial Python Node: Attributes With Simple Data", False],
],
},
{
'inputs': [
['inputs:a_path', "/World/Domination", False],
],
'outputs': [
['outputs:a_path', "/World/Domination/Child", False],
],
},
{
'inputs': [
['inputs:a_bool', False, False],
['inputs:a_double', 1.1, False],
['inputs:a_float', 3.3, False],
['inputs:a_half', 5.0, False],
['inputs:a_int', 7, False],
['inputs:a_int64', 9, False],
['inputs:a_token', "helloToken", False],
['inputs:a_string', "helloString", False],
['inputs:a_objectId', 10, False],
['inputs:a_uchar', 11, False],
['inputs:a_uint', 13, False],
['inputs:a_uint64', 15, False],
],
'outputs': [
['outputs:a_bool', True, False],
['outputs:a_double', 2.1, False],
['outputs:a_float', 4.3, False],
['outputs:a_half', 6.0, False],
['outputs:a_int', 8, False],
['outputs:a_int64', 10, False],
['outputs:a_token', "worldToken", False],
['outputs:a_string', "worldString", False],
['outputs:a_objectId', 11, False],
['outputs:a_uchar', 12, False],
['outputs:a_uint', 14, False],
['outputs:a_uint64', 16, 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_tutorials_SimpleDataPy", "omni.graph.tutorials.SimpleDataPy", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.SimpleDataPy 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_tutorials_SimpleDataPy","omni.graph.tutorials.SimpleDataPy", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.SimpleDataPy User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialSimpleDataPyDatabase import OgnTutorialSimpleDataPyDatabase
test_file_name = "OgnTutorialSimpleDataPyTemplate.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_tutorials_SimpleDataPy")
database = OgnTutorialSimpleDataPyDatabase(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:a_constant_input"))
attribute = test_node.get_attribute("inputs:a_constant_input")
db_value = database.inputs.a_constant_input
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:a_double"))
attribute = test_node.get_attribute("inputs:a_double")
db_value = database.inputs.a_double
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:a_float"))
attribute = test_node.get_attribute("inputs:a_float")
db_value = database.inputs.a_float
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:a_half"))
attribute = test_node.get_attribute("inputs:a_half")
db_value = database.inputs.a_half
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:a_int"))
attribute = test_node.get_attribute("inputs:a_int")
db_value = database.inputs.a_int
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:a_int64"))
attribute = test_node.get_attribute("inputs:a_int64")
db_value = database.inputs.a_int64
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:a_objectId"))
attribute = test_node.get_attribute("inputs:a_objectId")
db_value = database.inputs.a_objectId
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:a_path"))
attribute = test_node.get_attribute("inputs:a_path")
db_value = database.inputs.a_path
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:a_string"))
attribute = test_node.get_attribute("inputs:a_string")
db_value = database.inputs.a_string
expected_value = "helloString"
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:a_token"))
attribute = test_node.get_attribute("inputs:a_token")
db_value = database.inputs.a_token
expected_value = "helloToken"
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:a_uchar"))
attribute = test_node.get_attribute("inputs:a_uchar")
db_value = database.inputs.a_uchar
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:a_uint"))
attribute = test_node.get_attribute("inputs:a_uint")
db_value = database.inputs.a_uint
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:a_uint64"))
attribute = test_node.get_attribute("inputs:a_uint64")
db_value = database.inputs.a_uint64
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("outputs:a_a_boolUiName"))
attribute = test_node.get_attribute("outputs:a_a_boolUiName")
db_value = database.outputs.a_a_boolUiName
self.assertTrue(test_node.get_attribute_exists("outputs:a_bool"))
attribute = test_node.get_attribute("outputs:a_bool")
db_value = database.outputs.a_bool
self.assertTrue(test_node.get_attribute_exists("outputs:a_double"))
attribute = test_node.get_attribute("outputs:a_double")
db_value = database.outputs.a_double
self.assertTrue(test_node.get_attribute_exists("outputs:a_float"))
attribute = test_node.get_attribute("outputs:a_float")
db_value = database.outputs.a_float
self.assertTrue(test_node.get_attribute_exists("outputs:a_half"))
attribute = test_node.get_attribute("outputs:a_half")
db_value = database.outputs.a_half
self.assertTrue(test_node.get_attribute_exists("outputs:a_int"))
attribute = test_node.get_attribute("outputs:a_int")
db_value = database.outputs.a_int
self.assertTrue(test_node.get_attribute_exists("outputs:a_int64"))
attribute = test_node.get_attribute("outputs:a_int64")
db_value = database.outputs.a_int64
self.assertTrue(test_node.get_attribute_exists("outputs:a_nodeTypeUiName"))
attribute = test_node.get_attribute("outputs:a_nodeTypeUiName")
db_value = database.outputs.a_nodeTypeUiName
self.assertTrue(test_node.get_attribute_exists("outputs:a_objectId"))
attribute = test_node.get_attribute("outputs:a_objectId")
db_value = database.outputs.a_objectId
self.assertTrue(test_node.get_attribute_exists("outputs:a_path"))
attribute = test_node.get_attribute("outputs:a_path")
db_value = database.outputs.a_path
self.assertTrue(test_node.get_attribute_exists("outputs:a_string"))
attribute = test_node.get_attribute("outputs:a_string")
db_value = database.outputs.a_string
self.assertTrue(test_node.get_attribute_exists("outputs:a_token"))
attribute = test_node.get_attribute("outputs:a_token")
db_value = database.outputs.a_token
self.assertTrue(test_node.get_attribute_exists("outputs:a_uchar"))
attribute = test_node.get_attribute("outputs:a_uchar")
db_value = database.outputs.a_uchar
self.assertTrue(test_node.get_attribute_exists("outputs:a_uint"))
attribute = test_node.get_attribute("outputs:a_uint")
db_value = database.outputs.a_uint
self.assertTrue(test_node.get_attribute_exists("outputs:a_uint64"))
attribute = test_node.get_attribute("outputs:a_uint64")
db_value = database.outputs.a_uint64
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialSimpleData.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_bool', False, False],
],
'outputs': [
['outputs:a_bool', True, False],
],
},
{
'inputs': [
['inputs:a_bool', True, False],
],
'outputs': [
['outputs:a_bool', False, False],
],
},
{
'inputs': [
['inputs:a_bool', False, False],
['inputs:a_double', 1.1, False],
['inputs:a_float', 3.3, False],
['inputs:a_half', 5.0, False],
['inputs:a_int', 7, False],
['inputs:a_int64', 9, False],
['inputs:a_token', "helloToken", False],
['inputs:a_string', "helloString", False],
['inputs:a_objectId', 5, False],
['inputs:unsigned:a_uchar', 11, False],
['inputs:unsigned:a_uint', 13, False],
['inputs:unsigned:a_uint64', 15, False],
],
'outputs': [
['outputs:a_bool', True, False],
['outputs:a_double', 2.1, False],
['outputs:a_float', 4.3, False],
['outputs:a_half', 6.0, False],
['outputs:a_int', 8, False],
['outputs:a_int64', 10, False],
['outputs:a_token', "worldToken", False],
['outputs:a_string', "worldString", False],
['outputs:a_objectId', 6, False],
['outputs:unsigned:a_uchar', 12, False],
['outputs:unsigned:a_uint', 14, False],
['outputs:unsigned:a_uint64', 16, False],
],
},
{
'inputs': [
['inputs:a_token', "hello'Token", False],
['inputs:a_string', "hello\"String", False],
],
'outputs': [
['outputs:a_token', "world'Token", False],
['outputs:a_string', "world\"String", False],
],
},
{
'inputs': [
['inputs:a_path', "/World/Domination", False],
],
'outputs': [
['outputs:a_path', "/World/Domination/Child", False],
],
},
{
'outputs': [
['outputs:a_token', "worldToken", False],
['outputs:a_string', "worldString", 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_tutorials_SimpleData", "omni.graph.tutorials.SimpleData", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.SimpleData 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_tutorials_SimpleData","omni.graph.tutorials.SimpleData", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.SimpleData 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_tutorials_SimpleData", "omni.graph.tutorials.SimpleData", 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.tutorials.SimpleData User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialSimpleDataDatabase import OgnTutorialSimpleDataDatabase
test_file_name = "OgnTutorialSimpleDataTemplate.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_tutorials_SimpleData")
database = OgnTutorialSimpleDataDatabase(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:a_bool"))
attribute = test_node.get_attribute("inputs:a_bool")
db_value = database.inputs.a_bool
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:a_constant_input"))
attribute = test_node.get_attribute("inputs:a_constant_input")
db_value = database.inputs.a_constant_input
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:a_double"))
attribute = test_node.get_attribute("inputs:a_double")
db_value = database.inputs.a_double
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:a_float"))
attribute = test_node.get_attribute("inputs:a_float")
db_value = database.inputs.a_float
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:a_half"))
attribute = test_node.get_attribute("inputs:a_half")
db_value = database.inputs.a_half
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:a_int"))
attribute = test_node.get_attribute("inputs:a_int")
db_value = database.inputs.a_int
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:a_int64"))
attribute = test_node.get_attribute("inputs:a_int64")
db_value = database.inputs.a_int64
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:a_objectId"))
attribute = test_node.get_attribute("inputs:a_objectId")
db_value = database.inputs.a_objectId
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:a_path"))
attribute = test_node.get_attribute("inputs:a_path")
db_value = database.inputs.a_path
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:a_string"))
attribute = test_node.get_attribute("inputs:a_string")
db_value = database.inputs.a_string
expected_value = "helloString"
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:a_token"))
attribute = test_node.get_attribute("inputs:a_token")
db_value = database.inputs.a_token
expected_value = "helloToken"
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:unsigned:a_uchar"))
attribute = test_node.get_attribute("inputs:unsigned:a_uchar")
db_value = database.inputs.unsigned_a_uchar
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:unsigned:a_uint"))
attribute = test_node.get_attribute("inputs:unsigned:a_uint")
db_value = database.inputs.unsigned_a_uint
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:unsigned:a_uint64"))
attribute = test_node.get_attribute("inputs:unsigned:a_uint64")
db_value = database.inputs.unsigned_a_uint64
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("outputs:a_bool"))
attribute = test_node.get_attribute("outputs:a_bool")
db_value = database.outputs.a_bool
self.assertTrue(test_node.get_attribute_exists("outputs:a_double"))
attribute = test_node.get_attribute("outputs:a_double")
db_value = database.outputs.a_double
self.assertTrue(test_node.get_attribute_exists("outputs:a_float"))
attribute = test_node.get_attribute("outputs:a_float")
db_value = database.outputs.a_float
self.assertTrue(test_node.get_attribute_exists("outputs:a_half"))
attribute = test_node.get_attribute("outputs:a_half")
db_value = database.outputs.a_half
self.assertTrue(test_node.get_attribute_exists("outputs:a_int"))
attribute = test_node.get_attribute("outputs:a_int")
db_value = database.outputs.a_int
self.assertTrue(test_node.get_attribute_exists("outputs:a_int64"))
attribute = test_node.get_attribute("outputs:a_int64")
db_value = database.outputs.a_int64
self.assertTrue(test_node.get_attribute_exists("outputs:a_objectId"))
attribute = test_node.get_attribute("outputs:a_objectId")
db_value = database.outputs.a_objectId
self.assertTrue(test_node.get_attribute_exists("outputs:a_path"))
attribute = test_node.get_attribute("outputs:a_path")
db_value = database.outputs.a_path
self.assertTrue(test_node.get_attribute_exists("outputs:a_string"))
attribute = test_node.get_attribute("outputs:a_string")
db_value = database.outputs.a_string
self.assertTrue(test_node.get_attribute_exists("outputs:a_token"))
attribute = test_node.get_attribute("outputs:a_token")
db_value = database.outputs.a_token
self.assertTrue(test_node.get_attribute_exists("outputs:unsigned:a_uchar"))
attribute = test_node.get_attribute("outputs:unsigned:a_uchar")
db_value = database.outputs.unsigned_a_uchar
self.assertTrue(test_node.get_attribute_exists("outputs:unsigned:a_uint"))
attribute = test_node.get_attribute("outputs:unsigned:a_uint")
db_value = database.outputs.unsigned_a_uint
self.assertTrue(test_node.get_attribute_exists("outputs:unsigned:a_uint64"))
attribute = test_node.get_attribute("outputs:unsigned:a_uint64")
db_value = database.outputs.unsigned_a_uint64
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialBundleData.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.tutorials.ogn.OgnTutorialBundleDataDatabase import OgnTutorialBundleDataDatabase
test_file_name = "OgnTutorialBundleDataTemplate.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_tutorials_BundleData")
database = OgnTutorialBundleDataDatabase(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:bundle"))
attribute = test_node.get_attribute("inputs:bundle")
db_value = database.inputs.bundle
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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialStatePy.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:overrideValue', 5, False],
['inputs:override', True, False],
],
'outputs': [
['outputs:monotonic', 5, 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_tutorials_StatePy", "omni.graph.tutorials.StatePy", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.StatePy 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_tutorials_StatePy","omni.graph.tutorials.StatePy", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.StatePy User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialStatePyDatabase import OgnTutorialStatePyDatabase
test_file_name = "OgnTutorialStatePyTemplate.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_tutorials_StatePy")
database = OgnTutorialStatePyDatabase(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:override"))
attribute = test_node.get_attribute("inputs:override")
db_value = database.inputs.override
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:overrideValue"))
attribute = test_node.get_attribute("inputs:overrideValue")
db_value = database.inputs.overrideValue
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("outputs:monotonic"))
attribute = test_node.get_attribute("outputs:monotonic")
db_value = database.outputs.monotonic
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialOverrideType.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:data', [1.0, 2.0, 3.0], False],
],
'outputs': [
['outputs:data', [2.0, 3.0, 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_tutorials_OverrideType", "omni.graph.tutorials.OverrideType", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.OverrideType 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_tutorials_OverrideType","omni.graph.tutorials.OverrideType", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.OverrideType 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_tutorials_OverrideType", "omni.graph.tutorials.OverrideType", 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.tutorials.OverrideType User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialOverrideTypeDatabase import OgnTutorialOverrideTypeDatabase
test_file_name = "OgnTutorialOverrideTypeTemplate.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_tutorials_OverrideType")
database = OgnTutorialOverrideTypeDatabase(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
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))
self.assertTrue(test_node.get_attribute_exists("inputs:typedData"))
attribute = test_node.get_attribute("inputs:typedData")
db_value = database.inputs.typedData
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))
self.assertTrue(test_node.get_attribute_exists("outputs:data"))
attribute = test_node.get_attribute("outputs:data")
db_value = database.outputs.data
self.assertTrue(test_node.get_attribute_exists("outputs:typedData"))
attribute = test_node.get_attribute("outputs:typedData")
db_value = database.outputs.typedData
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialBundleAddAttributesPy.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.tutorials.ogn.OgnTutorialBundleAddAttributesPyDatabase import OgnTutorialBundleAddAttributesPyDatabase
test_file_name = "OgnTutorialBundleAddAttributesPyTemplate.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_tutorials_BundleAddAttributesPy")
database = OgnTutorialBundleAddAttributesPyDatabase(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:addedAttributeNames"))
attribute = test_node.get_attribute("inputs:addedAttributeNames")
db_value = database.inputs.addedAttributeNames
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:removedAttributeNames"))
attribute = test_node.get_attribute("inputs:removedAttributeNames")
db_value = database.inputs.removedAttributeNames
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:typesToAdd"))
attribute = test_node.get_attribute("inputs:typesToAdd")
db_value = database.inputs.typesToAdd
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:useBatchedAPI"))
attribute = test_node.get_attribute("inputs:useBatchedAPI")
db_value = database.inputs.useBatchedAPI
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_bundle"))
attribute = test_node.get_attribute("outputs_bundle")
db_value = database.outputs.bundle
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialTupleArrays.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', [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]], False],
['inputs:b', [[10.0, 5.0, 1.0], [1.0, 5.0, 10.0]], False],
],
'outputs': [
['outputs:result', [23.0, 57.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_tutorials_TupleArrays", "omni.graph.tutorials.TupleArrays", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.TupleArrays 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_tutorials_TupleArrays","omni.graph.tutorials.TupleArrays", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.TupleArrays 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_tutorials_TupleArrays", "omni.graph.tutorials.TupleArrays", 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.tutorials.TupleArrays User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialTupleArraysDatabase import OgnTutorialTupleArraysDatabase
test_file_name = "OgnTutorialTupleArraysTemplate.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_tutorials_TupleArrays")
database = OgnTutorialTupleArraysDatabase(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:a"))
attribute = test_node.get_attribute("inputs:a")
db_value = database.inputs.a
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:b"))
attribute = test_node.get_attribute("inputs:b")
db_value = database.inputs.b
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:result"))
attribute = test_node.get_attribute("outputs:result")
db_value = database.outputs.result
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialABI.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:namespace:a_bool', True, False],
],
'outputs': [
['outputs:namespace:a_bool', 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_tutorials_Abi", "omni.graph.tutorials.Abi", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.Abi 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_tutorials_Abi","omni.graph.tutorials.Abi", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.Abi User test case #{i+1}", 16)
async def test_data_access(self):
test_file_name = "OgnTutorialABITemplate.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_tutorials_Abi")
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:namespace:a_bool"))
attribute = test_node.get_attribute("inputs:namespace:a_bool")
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
self.assertTrue(test_node.get_attribute_exists("outputs:namespace:a_bool"))
attribute = test_node.get_attribute("outputs:namespace:a_bool")
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialVectorizedPassthrough.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', 1, False],
],
'outputs': [
['outputs:value', 1, False],
],
},
{
'inputs': [
['inputs:value', 2, False],
],
'outputs': [
['outputs:value', 2, False],
],
},
{
'inputs': [
['inputs:value', 3, False],
],
'outputs': [
['outputs:value', 3, False],
],
},
{
'inputs': [
['inputs:value', 4, False],
],
'outputs': [
['outputs:value', 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_tutorials_TutorialVectorizedPassThrough", "omni.graph.tutorials.TutorialVectorizedPassThrough", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.TutorialVectorizedPassThrough 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_tutorials_TutorialVectorizedPassThrough","omni.graph.tutorials.TutorialVectorizedPassThrough", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.TutorialVectorizedPassThrough User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialVectorizedPassthroughDatabase import OgnTutorialVectorizedPassthroughDatabase
test_file_name = "OgnTutorialVectorizedPassthroughTemplate.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_tutorials_TutorialVectorizedPassThrough")
database = OgnTutorialVectorizedPassthroughDatabase(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))
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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialExtendedTypes.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.tutorials.ogn.OgnTutorialExtendedTypesDatabase import OgnTutorialExtendedTypesDatabase
test_file_name = "OgnTutorialExtendedTypesTemplate.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_tutorials_ExtendedTypes")
database = OgnTutorialExtendedTypesDatabase(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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialExtendedTypesPy.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.tutorials.ogn.OgnTutorialExtendedTypesPyDatabase import OgnTutorialExtendedTypesPyDatabase
test_file_name = "OgnTutorialExtendedTypesPyTemplate.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_tutorials_ExtendedTypesPy")
database = OgnTutorialExtendedTypesPyDatabase(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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialBundles.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.tutorials.ogn.OgnTutorialBundlesDatabase import OgnTutorialBundlesDatabase
test_file_name = "OgnTutorialBundlesTemplate.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_tutorials_BundleManipulation")
database = OgnTutorialBundlesDatabase(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:filteredBundle"))
attribute = test_node.get_attribute("inputs:filteredBundle")
db_value = database.inputs.filteredBundle
self.assertTrue(test_node.get_attribute_exists("inputs:filters"))
attribute = test_node.get_attribute("inputs:filters")
db_value = database.inputs.filters
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:fullBundle"))
attribute = test_node.get_attribute("inputs:fullBundle")
db_value = database.inputs.fullBundle
self.assertTrue(test_node.get_attribute_exists("outputs_combinedBundle"))
attribute = test_node.get_attribute("outputs_combinedBundle")
db_value = database.outputs.combinedBundle
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialComplexDataPy.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:a_productArray', [], False],
],
},
{
'inputs': [
['inputs:a_inputArray', [1.0, 2.0, 3.0, 4.0, 5.0], False],
['inputs:a_vectorMultiplier', [6.0, 7.0, 8.0], False],
],
'outputs': [
['outputs:a_productArray', [[6.0, 7.0, 8.0], [12.0, 14.0, 16.0], [18.0, 21.0, 24.0], [24.0, 28.0, 32.0], [30.0, 35.0, 40.0]], False],
['outputs:a_tokenArray', ["1.0", "2.0", "3.0", "4.0", "5.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_tutorials_ComplexDataPy", "omni.graph.tutorials.ComplexDataPy", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.ComplexDataPy 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_tutorials_ComplexDataPy","omni.graph.tutorials.ComplexDataPy", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.ComplexDataPy User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialComplexDataPyDatabase import OgnTutorialComplexDataPyDatabase
test_file_name = "OgnTutorialComplexDataPyTemplate.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_tutorials_ComplexDataPy")
database = OgnTutorialComplexDataPyDatabase(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:a_inputArray"))
attribute = test_node.get_attribute("inputs:a_inputArray")
db_value = database.inputs.a_inputArray
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:a_vectorMultiplier"))
attribute = test_node.get_attribute("inputs:a_vectorMultiplier")
db_value = database.inputs.a_vectorMultiplier
expected_value = [1.0, 2.0, 3.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:a_productArray"))
attribute = test_node.get_attribute("outputs:a_productArray")
db_value = database.outputs.a_productArray
self.assertTrue(test_node.get_attribute_exists("outputs:a_tokenArray"))
attribute = test_node.get_attribute("outputs:a_tokenArray")
db_value = database.outputs.a_tokenArray
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialEmpty.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.tutorials.ogn.OgnTutorialEmptyDatabase import OgnTutorialEmptyDatabase
test_file_name = "OgnTutorialEmptyTemplate.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_tutorials_Empty")
database = OgnTutorialEmptyDatabase(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.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialTokensPy.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:valuesToCheck', ["red", "Red", "magenta", "green", "cyan", "blue", "yellow"], False],
],
'outputs': [
['outputs:isColor', [True, False, False, True, False, 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_tutorials_TokensPy", "omni.graph.tutorials.TokensPy", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.TokensPy 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_tutorials_TokensPy","omni.graph.tutorials.TokensPy", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.TokensPy User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialTokensPyDatabase import OgnTutorialTokensPyDatabase
test_file_name = "OgnTutorialTokensPyTemplate.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_tutorials_TokensPy")
database = OgnTutorialTokensPyDatabase(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:valuesToCheck"))
attribute = test_node.get_attribute("inputs:valuesToCheck")
db_value = database.inputs.valuesToCheck
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:isColor"))
attribute = test_node.get_attribute("outputs:isColor")
db_value = database.outputs.isColor
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialRoleData.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_color3d', [1.0, 2.0, 3.0], False],
['inputs:a_color3f', [11.0, 12.0, 13.0], False],
['inputs:a_color3h', [21.0, 22.0, 23.0], False],
['inputs:a_color4d', [1.0, 2.0, 3.0, 4.0], False],
['inputs:a_color4f', [11.0, 12.0, 13.0, 14.0], False],
['inputs:a_color4h', [21.0, 22.0, 23.0, 24.0], False],
['inputs:a_frame', [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0], False],
['inputs:a_matrix2d', [1.0, 2.0, 3.0, 4.0], False],
['inputs:a_matrix3d', [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0], False],
['inputs:a_matrix4d', [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0], False],
['inputs:a_normal3d', [1.0, 2.0, 3.0], False],
['inputs:a_normal3f', [11.0, 12.0, 13.0], False],
['inputs:a_normal3h', [21.0, 22.0, 23.0], False],
['inputs:a_point3d', [1.0, 2.0, 3.0], False],
['inputs:a_point3f', [11.0, 12.0, 13.0], False],
['inputs:a_point3h', [21.0, 22.0, 23.0], False],
['inputs:a_quatd', [1.0, 2.0, 3.0, 4.0], False],
['inputs:a_quatf', [11.0, 12.0, 13.0, 14.0], False],
['inputs:a_quath', [21.0, 22.0, 23.0, 24.0], False],
['inputs:a_texcoord2d', [1.0, 2.0], False],
['inputs:a_texcoord2f', [11.0, 12.0], False],
['inputs:a_texcoord2h', [21.0, 22.0], False],
['inputs:a_texcoord3d', [1.0, 2.0, 3.0], False],
['inputs:a_texcoord3f', [11.0, 12.0, 13.0], False],
['inputs:a_texcoord3h', [21.0, 22.0, 23.0], False],
['inputs:a_timecode', 10.0, False],
['inputs:a_vector3d', [1.0, 2.0, 3.0], False],
['inputs:a_vector3f', [11.0, 12.0, 13.0], False],
['inputs:a_vector3h', [21.0, 22.0, 23.0], False],
],
'outputs': [
['outputs:a_color3d', [2.0, 3.0, 4.0], False],
['outputs:a_color3f', [12.0, 13.0, 14.0], False],
['outputs:a_color3h', [22.0, 23.0, 24.0], False],
['outputs:a_color4d', [2.0, 3.0, 4.0, 5.0], False],
['outputs:a_color4f', [12.0, 13.0, 14.0, 15.0], False],
['outputs:a_color4h', [22.0, 23.0, 24.0, 25.0], False],
['outputs:a_frame', [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0], False],
['outputs:a_matrix2d', [2.0, 3.0, 4.0, 5.0], False],
['outputs:a_matrix3d', [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], False],
['outputs:a_matrix4d', [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0], False],
['outputs:a_normal3d', [2.0, 3.0, 4.0], False],
['outputs:a_normal3f', [12.0, 13.0, 14.0], False],
['outputs:a_normal3h', [22.0, 23.0, 24.0], False],
['outputs:a_point3d', [2.0, 3.0, 4.0], False],
['outputs:a_point3f', [12.0, 13.0, 14.0], False],
['outputs:a_point3h', [22.0, 23.0, 24.0], False],
['outputs:a_quatd', [2.0, 3.0, 4.0, 5.0], False],
['outputs:a_quatf', [12.0, 13.0, 14.0, 15.0], False],
['outputs:a_quath', [22.0, 23.0, 24.0, 25.0], False],
['outputs:a_texcoord2d', [2.0, 3.0], False],
['outputs:a_texcoord2f', [12.0, 13.0], False],
['outputs:a_texcoord2h', [22.0, 23.0], False],
['outputs:a_texcoord3d', [2.0, 3.0, 4.0], False],
['outputs:a_texcoord3f', [12.0, 13.0, 14.0], False],
['outputs:a_texcoord3h', [22.0, 23.0, 24.0], False],
['outputs:a_timecode', 11.0, False],
['outputs:a_vector3d', [2.0, 3.0, 4.0], False],
['outputs:a_vector3f', [12.0, 13.0, 14.0], False],
['outputs:a_vector3h', [22.0, 23.0, 24.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_tutorials_RoleData", "omni.graph.tutorials.RoleData", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.RoleData 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_tutorials_RoleData","omni.graph.tutorials.RoleData", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.RoleData 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_tutorials_RoleData", "omni.graph.tutorials.RoleData", 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.tutorials.RoleData User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialRoleDataDatabase import OgnTutorialRoleDataDatabase
test_file_name = "OgnTutorialRoleDataTemplate.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_tutorials_RoleData")
database = OgnTutorialRoleDataDatabase(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:a_color3d"))
attribute = test_node.get_attribute("inputs:a_color3d")
db_value = database.inputs.a_color3d
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_color3f"))
attribute = test_node.get_attribute("inputs:a_color3f")
db_value = database.inputs.a_color3f
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_color3h"))
attribute = test_node.get_attribute("inputs:a_color3h")
db_value = database.inputs.a_color3h
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_color4d"))
attribute = test_node.get_attribute("inputs:a_color4d")
db_value = database.inputs.a_color4d
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_color4f"))
attribute = test_node.get_attribute("inputs:a_color4f")
db_value = database.inputs.a_color4f
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_color4h"))
attribute = test_node.get_attribute("inputs:a_color4h")
db_value = database.inputs.a_color4h
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_frame"))
attribute = test_node.get_attribute("inputs:a_frame")
db_value = database.inputs.a_frame
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:a_matrix2d"))
attribute = test_node.get_attribute("inputs:a_matrix2d")
db_value = database.inputs.a_matrix2d
expected_value = [[1.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:a_matrix3d"))
attribute = test_node.get_attribute("inputs:a_matrix3d")
db_value = database.inputs.a_matrix3d
expected_value = [[1.0, 0.0, 0.0], [0.0, 1.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:a_matrix4d"))
attribute = test_node.get_attribute("inputs:a_matrix4d")
db_value = database.inputs.a_matrix4d
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:a_normal3d"))
attribute = test_node.get_attribute("inputs:a_normal3d")
db_value = database.inputs.a_normal3d
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_normal3f"))
attribute = test_node.get_attribute("inputs:a_normal3f")
db_value = database.inputs.a_normal3f
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_normal3h"))
attribute = test_node.get_attribute("inputs:a_normal3h")
db_value = database.inputs.a_normal3h
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_point3d"))
attribute = test_node.get_attribute("inputs:a_point3d")
db_value = database.inputs.a_point3d
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_point3f"))
attribute = test_node.get_attribute("inputs:a_point3f")
db_value = database.inputs.a_point3f
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_point3h"))
attribute = test_node.get_attribute("inputs:a_point3h")
db_value = database.inputs.a_point3h
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_quatd"))
attribute = test_node.get_attribute("inputs:a_quatd")
db_value = database.inputs.a_quatd
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_quatf"))
attribute = test_node.get_attribute("inputs:a_quatf")
db_value = database.inputs.a_quatf
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_quath"))
attribute = test_node.get_attribute("inputs:a_quath")
db_value = database.inputs.a_quath
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_texcoord2d"))
attribute = test_node.get_attribute("inputs:a_texcoord2d")
db_value = database.inputs.a_texcoord2d
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_texcoord2f"))
attribute = test_node.get_attribute("inputs:a_texcoord2f")
db_value = database.inputs.a_texcoord2f
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_texcoord2h"))
attribute = test_node.get_attribute("inputs:a_texcoord2h")
db_value = database.inputs.a_texcoord2h
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_texcoord3d"))
attribute = test_node.get_attribute("inputs:a_texcoord3d")
db_value = database.inputs.a_texcoord3d
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_texcoord3f"))
attribute = test_node.get_attribute("inputs:a_texcoord3f")
db_value = database.inputs.a_texcoord3f
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_texcoord3h"))
attribute = test_node.get_attribute("inputs:a_texcoord3h")
db_value = database.inputs.a_texcoord3h
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_timecode"))
attribute = test_node.get_attribute("inputs:a_timecode")
db_value = database.inputs.a_timecode
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:a_vector3d"))
attribute = test_node.get_attribute("inputs:a_vector3d")
db_value = database.inputs.a_vector3d
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_vector3f"))
attribute = test_node.get_attribute("inputs:a_vector3f")
db_value = database.inputs.a_vector3f
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))
self.assertTrue(test_node.get_attribute_exists("inputs:a_vector3h"))
attribute = test_node.get_attribute("inputs:a_vector3h")
db_value = database.inputs.a_vector3h
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))
self.assertTrue(test_node.get_attribute_exists("outputs:a_color3d"))
attribute = test_node.get_attribute("outputs:a_color3d")
db_value = database.outputs.a_color3d
self.assertTrue(test_node.get_attribute_exists("outputs:a_color3f"))
attribute = test_node.get_attribute("outputs:a_color3f")
db_value = database.outputs.a_color3f
self.assertTrue(test_node.get_attribute_exists("outputs:a_color3h"))
attribute = test_node.get_attribute("outputs:a_color3h")
db_value = database.outputs.a_color3h
self.assertTrue(test_node.get_attribute_exists("outputs:a_color4d"))
attribute = test_node.get_attribute("outputs:a_color4d")
db_value = database.outputs.a_color4d
self.assertTrue(test_node.get_attribute_exists("outputs:a_color4f"))
attribute = test_node.get_attribute("outputs:a_color4f")
db_value = database.outputs.a_color4f
self.assertTrue(test_node.get_attribute_exists("outputs:a_color4h"))
attribute = test_node.get_attribute("outputs:a_color4h")
db_value = database.outputs.a_color4h
self.assertTrue(test_node.get_attribute_exists("outputs:a_frame"))
attribute = test_node.get_attribute("outputs:a_frame")
db_value = database.outputs.a_frame
self.assertTrue(test_node.get_attribute_exists("outputs:a_matrix2d"))
attribute = test_node.get_attribute("outputs:a_matrix2d")
db_value = database.outputs.a_matrix2d
self.assertTrue(test_node.get_attribute_exists("outputs:a_matrix3d"))
attribute = test_node.get_attribute("outputs:a_matrix3d")
db_value = database.outputs.a_matrix3d
self.assertTrue(test_node.get_attribute_exists("outputs:a_matrix4d"))
attribute = test_node.get_attribute("outputs:a_matrix4d")
db_value = database.outputs.a_matrix4d
self.assertTrue(test_node.get_attribute_exists("outputs:a_normal3d"))
attribute = test_node.get_attribute("outputs:a_normal3d")
db_value = database.outputs.a_normal3d
self.assertTrue(test_node.get_attribute_exists("outputs:a_normal3f"))
attribute = test_node.get_attribute("outputs:a_normal3f")
db_value = database.outputs.a_normal3f
self.assertTrue(test_node.get_attribute_exists("outputs:a_normal3h"))
attribute = test_node.get_attribute("outputs:a_normal3h")
db_value = database.outputs.a_normal3h
self.assertTrue(test_node.get_attribute_exists("outputs:a_point3d"))
attribute = test_node.get_attribute("outputs:a_point3d")
db_value = database.outputs.a_point3d
self.assertTrue(test_node.get_attribute_exists("outputs:a_point3f"))
attribute = test_node.get_attribute("outputs:a_point3f")
db_value = database.outputs.a_point3f
self.assertTrue(test_node.get_attribute_exists("outputs:a_point3h"))
attribute = test_node.get_attribute("outputs:a_point3h")
db_value = database.outputs.a_point3h
self.assertTrue(test_node.get_attribute_exists("outputs:a_quatd"))
attribute = test_node.get_attribute("outputs:a_quatd")
db_value = database.outputs.a_quatd
self.assertTrue(test_node.get_attribute_exists("outputs:a_quatf"))
attribute = test_node.get_attribute("outputs:a_quatf")
db_value = database.outputs.a_quatf
self.assertTrue(test_node.get_attribute_exists("outputs:a_quath"))
attribute = test_node.get_attribute("outputs:a_quath")
db_value = database.outputs.a_quath
self.assertTrue(test_node.get_attribute_exists("outputs:a_texcoord2d"))
attribute = test_node.get_attribute("outputs:a_texcoord2d")
db_value = database.outputs.a_texcoord2d
self.assertTrue(test_node.get_attribute_exists("outputs:a_texcoord2f"))
attribute = test_node.get_attribute("outputs:a_texcoord2f")
db_value = database.outputs.a_texcoord2f
self.assertTrue(test_node.get_attribute_exists("outputs:a_texcoord2h"))
attribute = test_node.get_attribute("outputs:a_texcoord2h")
db_value = database.outputs.a_texcoord2h
self.assertTrue(test_node.get_attribute_exists("outputs:a_texcoord3d"))
attribute = test_node.get_attribute("outputs:a_texcoord3d")
db_value = database.outputs.a_texcoord3d
self.assertTrue(test_node.get_attribute_exists("outputs:a_texcoord3f"))
attribute = test_node.get_attribute("outputs:a_texcoord3f")
db_value = database.outputs.a_texcoord3f
self.assertTrue(test_node.get_attribute_exists("outputs:a_texcoord3h"))
attribute = test_node.get_attribute("outputs:a_texcoord3h")
db_value = database.outputs.a_texcoord3h
self.assertTrue(test_node.get_attribute_exists("outputs:a_timecode"))
attribute = test_node.get_attribute("outputs:a_timecode")
db_value = database.outputs.a_timecode
self.assertTrue(test_node.get_attribute_exists("outputs:a_vector3d"))
attribute = test_node.get_attribute("outputs:a_vector3d")
db_value = database.outputs.a_vector3d
self.assertTrue(test_node.get_attribute_exists("outputs:a_vector3f"))
attribute = test_node.get_attribute("outputs:a_vector3f")
db_value = database.outputs.a_vector3f
self.assertTrue(test_node.get_attribute_exists("outputs:a_vector3h"))
attribute = test_node.get_attribute("outputs:a_vector3h")
db_value = database.outputs.a_vector3h
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialCpuGpuExtendedPy.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.tutorials.ogn.OgnTutorialCpuGpuExtendedPyDatabase import OgnTutorialCpuGpuExtendedPyDatabase
test_file_name = "OgnTutorialCpuGpuExtendedPyTemplate.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_tutorials_CpuGpuExtendedPy")
database = OgnTutorialCpuGpuExtendedPyDatabase(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:gpu"))
attribute = test_node.get_attribute("inputs:gpu")
db_value = database.inputs.gpu
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))
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialDefaults.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:a_bool', False, False],
['outputs:a_double', 0.0, False],
['outputs:a_float', 0.0, False],
['outputs:a_half', 0.0, False],
['outputs:a_int', 0, False],
['outputs:a_int64', 0, False],
['outputs:a_string', "", False],
['outputs:a_token', "", False],
['outputs:a_uchar', 0, False],
['outputs:a_uint', 0, False],
['outputs:a_uint64', 0, False],
['outputs:a_int2', [0, 0], False],
['outputs:a_matrix', [1.0, 0.0, 0.0, 1.0], False],
['outputs:a_array', [], 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_tutorials_Defaults", "omni.graph.tutorials.Defaults", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.Defaults 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_tutorials_Defaults","omni.graph.tutorials.Defaults", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.Defaults 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_tutorials_Defaults", "omni.graph.tutorials.Defaults", 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.tutorials.Defaults User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialDefaultsDatabase import OgnTutorialDefaultsDatabase
test_file_name = "OgnTutorialDefaultsTemplate.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_tutorials_Defaults")
database = OgnTutorialDefaultsDatabase(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:a_array"))
attribute = test_node.get_attribute("inputs:a_array")
db_value = database.inputs.a_array
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:a_bool"))
attribute = test_node.get_attribute("inputs:a_bool")
db_value = database.inputs.a_bool
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:a_double"))
attribute = test_node.get_attribute("inputs:a_double")
db_value = database.inputs.a_double
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:a_float"))
attribute = test_node.get_attribute("inputs:a_float")
db_value = database.inputs.a_float
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:a_half"))
attribute = test_node.get_attribute("inputs:a_half")
db_value = database.inputs.a_half
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:a_int"))
attribute = test_node.get_attribute("inputs:a_int")
db_value = database.inputs.a_int
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:a_int2"))
attribute = test_node.get_attribute("inputs:a_int2")
db_value = database.inputs.a_int2
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:a_int64"))
attribute = test_node.get_attribute("inputs:a_int64")
db_value = database.inputs.a_int64
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:a_matrix"))
attribute = test_node.get_attribute("inputs:a_matrix")
db_value = database.inputs.a_matrix
expected_value = [[1.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:a_string"))
attribute = test_node.get_attribute("inputs:a_string")
db_value = database.inputs.a_string
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:a_token"))
attribute = test_node.get_attribute("inputs:a_token")
db_value = database.inputs.a_token
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:a_uchar"))
attribute = test_node.get_attribute("inputs:a_uchar")
db_value = database.inputs.a_uchar
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:a_uint"))
attribute = test_node.get_attribute("inputs:a_uint")
db_value = database.inputs.a_uint
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:a_uint64"))
attribute = test_node.get_attribute("inputs:a_uint64")
db_value = database.inputs.a_uint64
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("outputs:a_array"))
attribute = test_node.get_attribute("outputs:a_array")
db_value = database.outputs.a_array
self.assertTrue(test_node.get_attribute_exists("outputs:a_bool"))
attribute = test_node.get_attribute("outputs:a_bool")
db_value = database.outputs.a_bool
self.assertTrue(test_node.get_attribute_exists("outputs:a_double"))
attribute = test_node.get_attribute("outputs:a_double")
db_value = database.outputs.a_double
self.assertTrue(test_node.get_attribute_exists("outputs:a_float"))
attribute = test_node.get_attribute("outputs:a_float")
db_value = database.outputs.a_float
self.assertTrue(test_node.get_attribute_exists("outputs:a_half"))
attribute = test_node.get_attribute("outputs:a_half")
db_value = database.outputs.a_half
self.assertTrue(test_node.get_attribute_exists("outputs:a_int"))
attribute = test_node.get_attribute("outputs:a_int")
db_value = database.outputs.a_int
self.assertTrue(test_node.get_attribute_exists("outputs:a_int2"))
attribute = test_node.get_attribute("outputs:a_int2")
db_value = database.outputs.a_int2
self.assertTrue(test_node.get_attribute_exists("outputs:a_int64"))
attribute = test_node.get_attribute("outputs:a_int64")
db_value = database.outputs.a_int64
self.assertTrue(test_node.get_attribute_exists("outputs:a_matrix"))
attribute = test_node.get_attribute("outputs:a_matrix")
db_value = database.outputs.a_matrix
self.assertTrue(test_node.get_attribute_exists("outputs:a_string"))
attribute = test_node.get_attribute("outputs:a_string")
db_value = database.outputs.a_string
self.assertTrue(test_node.get_attribute_exists("outputs:a_token"))
attribute = test_node.get_attribute("outputs:a_token")
db_value = database.outputs.a_token
self.assertTrue(test_node.get_attribute_exists("outputs:a_uchar"))
attribute = test_node.get_attribute("outputs:a_uchar")
db_value = database.outputs.a_uchar
self.assertTrue(test_node.get_attribute_exists("outputs:a_uint"))
attribute = test_node.get_attribute("outputs:a_uint")
db_value = database.outputs.a_uint
self.assertTrue(test_node.get_attribute_exists("outputs:a_uint64"))
attribute = test_node.get_attribute("outputs:a_uint64")
db_value = database.outputs.a_uint64
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialBundleAddAttributes.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.tutorials.ogn.OgnTutorialBundleAddAttributesDatabase import OgnTutorialBundleAddAttributesDatabase
test_file_name = "OgnTutorialBundleAddAttributesTemplate.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_tutorials_BundleAddAttributes")
database = OgnTutorialBundleAddAttributesDatabase(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:addedAttributeNames"))
attribute = test_node.get_attribute("inputs:addedAttributeNames")
db_value = database.inputs.addedAttributeNames
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:removedAttributeNames"))
attribute = test_node.get_attribute("inputs:removedAttributeNames")
db_value = database.inputs.removedAttributeNames
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:typesToAdd"))
attribute = test_node.get_attribute("inputs:typesToAdd")
db_value = database.inputs.typesToAdd
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:useBatchedAPI"))
attribute = test_node.get_attribute("inputs:useBatchedAPI")
db_value = database.inputs.useBatchedAPI
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_bundle"))
attribute = test_node.get_attribute("outputs_bundle")
db_value = database.outputs.bundle
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/TestOgnTutorialState.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:overrideValue', 555, False],
['inputs:override', True, False],
],
'outputs': [
['outputs:monotonic', 555, 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_tutorials_State", "omni.graph.tutorials.State", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.State 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_tutorials_State","omni.graph.tutorials.State", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.tutorials.State 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_tutorials_State", "omni.graph.tutorials.State", 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.tutorials.State User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.tutorials.ogn.OgnTutorialStateDatabase import OgnTutorialStateDatabase
test_file_name = "OgnTutorialStateTemplate.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_tutorials_State")
database = OgnTutorialStateDatabase(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:override"))
attribute = test_node.get_attribute("inputs:override")
db_value = database.inputs.override
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:overrideValue"))
attribute = test_node.get_attribute("inputs:overrideValue")
db_value = database.inputs.overrideValue
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("outputs:monotonic"))
attribute = test_node.get_attribute("outputs:monotonic")
db_value = database.outputs.monotonic
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialCudaDataCpuPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialCudaDataCpuPy.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_tutorials_CudaCpuArraysPy" (
docs="""This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device. Both plain attribute and bundle attribute extraction are shown."""
)
{
token node:type = "omni.graph.tutorials.CudaCpuArraysPy"
int node:typeVersion = 1
# 2 attributes
custom float3 inputs:multiplier = (1.0, 1.0, 1.0) (
docs="""Amplitude of the expansion for the input points"""
)
custom float3[] inputs:points = [] (
docs="""Array of points to be moved"""
)
# 2 attributes
def Output "outputs_outBundle" (
docs="""Bundle containing a copy of the output points"""
)
{
}
custom float3[] outputs:points (
docs="""Final positions of points"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialStateAttributesPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialStateAttributesPy.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_tutorials_StateAttributesPy" (
docs="""This is a tutorial node. It exercises state attributes to remember data from on evaluation to the next."""
)
{
token node:type = "omni.graph.tutorials.StateAttributesPy"
int node:typeVersion = 1
# 1 attribute
custom bool inputs:ignored = false (
docs="""Ignore me"""
)
# 2 attributes
custom int state:monotonic (
docs="""The monotonically increasing output value, reset to 0 when the reset value is true"""
)
custom bool state:reset = true (
docs="""If true then the inputs are ignored and outputs are set to default values, then this
flag is set to false for subsequent evaluations."""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialDefaultsTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialDefaults.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_tutorials_Defaults" (
docs="""This is a tutorial node. It will move the values of inputs to corresponding outputs. Inputs all have unspecified, and therefore empty, default values."""
)
{
token node:type = "omni.graph.tutorials.Defaults"
int node:typeVersion = 1
# 14 attributes
custom float[] inputs:a_array = [] (
docs="""This is an attribute of type array of floats"""
)
custom bool inputs:a_bool = false (
docs="""This is an attribute of type boolean"""
)
custom double inputs:a_double = 0.0 (
docs="""This is an attribute of type 64 bit floating point"""
)
custom float inputs:a_float = 0.0 (
docs="""This is an attribute of type 32 bit floating point"""
)
custom half inputs:a_half = 0.0 (
docs="""This is an attribute of type 16 bit floating point"""
)
custom int inputs:a_int = 0 (
docs="""This is an attribute of type 32 bit integer"""
)
custom int2 inputs:a_int2 = (0, 0) (
docs="""This is an attribute of type 2-tuple of integers"""
)
custom int64 inputs:a_int64 = 0 (
docs="""This is an attribute of type 64 bit integer"""
)
custom matrix2d inputs:a_matrix = ((1.0, 0.0), (0.0, 1.0)) (
docs="""This is an attribute of type 2x2 matrix"""
)
custom string inputs:a_string = "" (
docs="""This is an attribute of type string"""
)
custom token inputs:a_token = "" (
docs="""This is an attribute of type interned string with fast comparison and hashing"""
)
custom uchar inputs:a_uchar = 0 (
docs="""This is an attribute of type unsigned 8 bit integer"""
)
custom uint inputs:a_uint = 0 (
docs="""This is an attribute of type unsigned 32 bit integer"""
)
custom uint64 inputs:a_uint64 = 0 (
docs="""This is an attribute of type unsigned 64 bit integer"""
)
# 14 attributes
custom float[] outputs:a_array (
docs="""This is a computed attribute of type array of floats"""
)
custom bool outputs:a_bool (
docs="""This is a computed attribute of type boolean"""
)
custom double outputs:a_double (
docs="""This is a computed attribute of type 64 bit floating point"""
)
custom float outputs:a_float (
docs="""This is a computed attribute of type 32 bit floating point"""
)
custom half outputs:a_half (
docs="""This is a computed attribute of type 16 bit floating point"""
)
custom int outputs:a_int (
docs="""This is a computed attribute of type 32 bit integer"""
)
custom int2 outputs:a_int2 (
docs="""This is a computed attribute of type 2-tuple of integers"""
)
custom int64 outputs:a_int64 (
docs="""This is a computed attribute of type 64 bit integer"""
)
custom matrix2d outputs:a_matrix (
docs="""This is a computed attribute of type 2x2 matrix"""
)
custom string outputs:a_string (
docs="""This is a computed attribute of type string"""
)
custom token outputs:a_token (
docs="""This is a computed attribute of type interned string with fast comparison and hashing"""
)
custom uchar outputs:a_uchar (
docs="""This is a computed attribute of type unsigned 8 bit integer"""
)
custom uint outputs:a_uint (
docs="""This is a computed attribute of type unsigned 32 bit integer"""
)
custom uint64 outputs:a_uint64 (
docs="""This is a computed attribute of type unsigned 64 bit integer"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialCudaDataTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialCudaData.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_tutorials_CudaData" (
docs="""This is a tutorial node. It performs different functions on the GPU to illustrate different types of data access. The first adds inputs 'a' and 'b' to yield output 'sum', all of which are on the GPU. The second is a sample expansion deformation that multiplies every point on a set of input points, stored on the GPU, by a constant value, stored on the CPU, to yield a set of output points, also on the GPU. The third is an assortment of different data types illustrating how different data is passed to the GPU. This particular node uses CUDA for its GPU computations, as indicated in the memory type value. Normal use case for GPU compute is large amounts of data. For testing purposes this node only handles a very small amount but the principle is the same."""
)
{
token node:type = "omni.graph.tutorials.CudaData"
int node:typeVersion = 1
# 7 attributes
custom float inputs:a = 0.0 (
docs="""First value to be added in algorithm 1"""
)
custom float inputs:b = 0.0 (
docs="""Second value to be added in algorithm 1"""
)
custom color3d inputs:color = (1.0, 0.5, 1.0) (
docs="""Input with three doubles as a color for algorithm 3"""
)
custom half inputs:half = 1.0 (
docs="""Input of type half for algorithm 3"""
)
custom matrix4d inputs:matrix = ((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)) (
docs="""Input with 16 doubles interpreted as a double-precision 4d matrix"""
)
custom float3 inputs:multiplier = (1.0, 1.0, 1.0) (
docs="""Amplitude of the expansion for the input points in algorithm 2"""
)
custom float3[] inputs:points = [] (
docs="""Points to be moved by algorithm 2"""
)
# 5 attributes
custom color3d outputs:color (
docs="""Output with three doubles as a color for algorithm 3"""
)
custom half outputs:half (
docs="""Output of type half for algorithm 3"""
)
custom matrix4d outputs:matrix (
docs="""Output with 16 doubles interpreted as a double-precision 4d matrix"""
)
custom float3[] outputs:points (
docs="""Final positions of points from algorithm 2"""
)
custom float outputs:sum (
docs="""Sum of the two inputs from algorithm 1"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialSimpleDataPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialSimpleDataPy.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_tutorials_SimpleDataPy" (
docs="""This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values. It is the same as node omni.graph.tutorials.SimpleData, except it is implemented in Python instead of C++."""
)
{
token node:type = "omni.graph.tutorials.SimpleDataPy"
int node:typeVersion = 1
# 14 attributes
custom bool inputs:a_bool = true (
docs="""This is an attribute of type boolean"""
)
custom int inputs:a_constant_input = 0 (
docs="""This is an input attribute whose value can be set but can only be connected as a source."""
)
custom double inputs:a_double = 0 (
docs="""This is an attribute of type 64 bit floating point"""
)
custom float inputs:a_float = 0 (
docs="""This is an attribute of type 32 bit floating point"""
)
custom half inputs:a_half = 0.0 (
docs="""This is an attribute of type 16 bit float"""
)
custom int inputs:a_int = 0 (
docs="""This is an attribute of type 32 bit integer"""
)
custom int64 inputs:a_int64 = 0 (
docs="""This is an attribute of type 64 bit integer"""
)
custom uint64 inputs:a_objectId = 0 (
docs="""This is an attribute of type objectId"""
)
custom string inputs:a_path = "" (
docs="""This is an attribute of type path"""
)
custom string inputs:a_string = "helloString" (
docs="""This is an attribute of type string"""
)
custom token inputs:a_token = "helloToken" (
docs="""This is an attribute of type interned string with fast comparison and hashing"""
)
custom uchar inputs:a_uchar = 0 (
docs="""This is an attribute of type unsigned 8 bit integer"""
)
custom uint inputs:a_uint = 0 (
docs="""This is an attribute of type unsigned 32 bit integer"""
)
custom uint64 inputs:a_uint64 = 0 (
docs="""This is an attribute of type unsigned 64 bit integer"""
)
# 15 attributes
custom string outputs:a_a_boolUiName (
docs="""Computed attribute containing the UI name of input a_bool"""
)
custom bool outputs:a_bool (
docs="""This is a computed attribute of type boolean"""
)
custom double outputs:a_double (
docs="""This is a computed attribute of type 64 bit floating point"""
)
custom float outputs:a_float (
docs="""This is a computed attribute of type 32 bit floating point"""
)
custom half outputs:a_half (
docs="""This is a computed attribute of type 16 bit float"""
)
custom int outputs:a_int (
docs="""This is a computed attribute of type 32 bit integer"""
)
custom int64 outputs:a_int64 (
docs="""This is a computed attribute of type 64 bit integer"""
)
custom string outputs:a_nodeTypeUiName (
docs="""Computed attribute containing the UI name of this node type"""
)
custom uint64 outputs:a_objectId (
docs="""This is a computed attribute of type objectId"""
)
custom string outputs:a_path = "/Child" (
docs="""This is a computed attribute of type path"""
)
custom string outputs:a_string = "This string is empty" (
docs="""This is a computed attribute of type string"""
)
custom token outputs:a_token (
docs="""This is a computed attribute of type interned string with fast comparison and hashing"""
)
custom uchar outputs:a_uchar (
docs="""This is a computed attribute of type unsigned 8 bit integer"""
)
custom uint outputs:a_uint (
docs="""This is a computed attribute of type unsigned 32 bit integer"""
)
custom uint64 outputs:a_uint64 (
docs="""This is a computed attribute of type unsigned 64 bit integer"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialTupleDataTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialTupleData.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_tutorials_TupleData" (
docs="""This is a tutorial node. It creates both an input and output attribute of some of the supported tuple types. The values are modified in a simple way so that the compute can be tested."""
)
{
token node:type = "omni.tutorials.TupleData"
int node:typeVersion = 1
# 6 attributes
custom double2 inputs:a_double2 = (1.1, 2.2) (
docs="""This is an attribute with two double values"""
)
custom double3 inputs:a_double3 = (1.1, 2.2, 3.3) (
docs="""This is an attribute with three double values"""
)
custom float2 inputs:a_float2 = (4.4, 5.5) (
docs="""This is an attribute with two float values"""
)
custom float3 inputs:a_float3 = (6.6, 7.7, 8.8) (
docs="""This is an attribute with three float values"""
)
custom half2 inputs:a_half2 = (7.0, 8.0) (
docs="""This is an attribute with two 16-bit float values"""
)
custom int2 inputs:a_int2 = (10, 11) (
docs="""This is an attribute with two 32-bit integer values"""
)
# 6 attributes
custom double2 outputs:a_double2 (
docs="""This is a computed attribute with two double values"""
)
custom double3 outputs:a_double3 (
docs="""This is a computed attribute with three double values"""
)
custom float2 outputs:a_float2 (
docs="""This is a computed attribute with two float values"""
)
custom float3 outputs:a_float3 (
docs="""This is a computed attribute with three float values"""
)
custom half2 outputs:a_half2 (
docs="""This is a computed attribute with two 16-bit float values"""
)
custom int2 outputs:a_int2 (
docs="""This is a computed attribute with two 32-bit integer values"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialBundleDataPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialBundleDataPy.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_tutorials_BundleDataPy" (
docs="""This is a tutorial node. It exercises functionality for access of data within bundle attributes. The configuration is the same as omni.graph.tutorials.BundleData except that the implementation language is Python"""
)
{
token node:type = "omni.graph.tutorials.BundleDataPy"
int node:typeVersion = 1
# 1 attribute
custom rel inputs:bundle (
docs="""Bundle whose contents are modified for passing to the output"""
)
# 1 attribute
def Output "outputs_bundle" (
docs="""This is the bundle with values of known types doubled."""
)
{
}
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialEmptyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialEmpty.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_tutorials_Empty" (
docs="""This is a tutorial node. It does absolutely nothing and is only meant to serve as an example to use for setting up your build."""
)
{
token node:type = "omni.graph.tutorials.Empty"
int node:typeVersion = 1
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialBundleAddAttributesPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialBundleAddAttributesPy.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_tutorials_BundleAddAttributesPy" (
docs="""This is a Python tutorial node. It exercises functionality for adding and removing attributes on output bundles."""
)
{
token node:type = "omni.graph.tutorials.BundleAddAttributesPy"
int node:typeVersion = 1
# 4 attributes
custom token[] inputs:addedAttributeNames = [] (
docs="""Names for the attribute types to be added. The size of this array must match the size
of the 'typesToAdd' array to be legal."""
)
custom token[] inputs:removedAttributeNames = [] (
docs="""Names for the attribute types to be removed. Non-existent attributes will be ignored."""
)
custom token[] inputs:typesToAdd = [] (
docs="""List of type descriptions to add to the bundle. The strings in this list correspond to the
strings that represent the attribute types in the .ogn file (e.g. float[3][], colord[3], bool"""
)
custom bool inputs:useBatchedAPI = false (
docs="""Controls whether or not to used batched APIS for adding/removing attributes"""
)
# 1 attribute
def Output "outputs_bundle" (
docs="""This is the bundle with all attributes added by compute."""
)
{
}
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialComplexDataPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialComplexDataPy.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_tutorials_ComplexDataPy" (
docs="""This is a tutorial node written in Python. It will compute the point3f array by multiplying each element of the float array by the three element vector in the multiplier."""
)
{
token node:type = "omni.graph.tutorials.ComplexDataPy"
int node:typeVersion = 1
# 2 attributes
custom float[] inputs:a_inputArray = [] (
docs="""Input array"""
)
custom float3 inputs:a_vectorMultiplier = (1.0, 2.0, 3.0) (
docs="""Vector multiplier"""
)
# 1 attribute
custom point3f[] outputs:a_productArray = [] (
docs="""Output array"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialABIPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialABIPy.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_tutorials_AbiPy" (
docs="""This tutorial node shows how to override ABI methods on your Python node. The algorithm of the node converts an RGB color into HSV components."""
)
{
token node:type = "omni.graph.tutorials.AbiPy"
int node:typeVersion = 1
# 1 attribute
custom color3d inputs:color = (0.0, 0.0, 0.0) (
docs="""The color to be converted"""
)
# 3 attributes
custom double outputs:h (
docs="""The hue component of the input color"""
)
custom double outputs:s (
docs="""The saturation component of the input color"""
)
custom double outputs:v (
docs="""The value component of the input color"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialExtendedTypesTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialExtendedTypes.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_tutorials_ExtendedTypes" (
docs="""This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types."""
)
{
token node:type = "omni.graph.tutorials.ExtendedTypes"
int node:typeVersion = 1
# 4 attributes
custom token inputs:flexible (
docs="""Flexible data type input"""
)
custom token inputs:floatOrToken (
docs="""Attribute that can either be a float value or a token value"""
)
custom token inputs:toNegate (
docs="""Attribute that can either be an array of booleans or an array of floats"""
)
custom token inputs:tuple = "any" (
docs="""Variable size/type tuple values"""
)
# 4 attributes
custom token outputs:doubledResult = "any" (
docs="""If the input 'simpleInput' is a float this is 2x the value.
If it is a token this contains the input token repeated twice."""
)
custom token outputs:flexible (
docs="""Flexible data type output"""
)
custom token outputs:negatedResult (
docs="""Result of negating the data from the 'toNegate' input"""
)
custom token outputs:tuple = "any" (
docs="""Negated values of the tuple input"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialOverrideTypeTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialOverrideType.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_tutorials_OverrideType" (
docs="""This is a tutorial node. It has an input and output of type float[3], an input and output of type double[3], and a type override specification that lets the node use Carbonite types for the generated data on the float[3] attributes only. Ordinarily all of the types would be defined in a seperate configuration file so that it can be shared for a project. In that case the type definition build flag would also be used so that this information does not have to be embedded in every .ogn file in the project. It is placed directly in the file here solely for instructional purposes. The compute is just a rotation of components from x->y, y->z, and z->x, for each input type."""
)
{
token node:type = "omni.graph.tutorials.OverrideType"
int node:typeVersion = 1
# 2 attributes
custom double3 inputs:data = (0.0, 0.0, 0.0) (
docs="""The value to rotate"""
)
custom float3 inputs:typedData = (0.0, 0.0, 0.0) (
docs="""The value to rotate"""
)
# 2 attributes
custom double3 outputs:data (
docs="""The rotated version of inputs::data"""
)
custom float3 outputs:typedData (
docs="""The rotated version of inputs::typedData"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialGenericMathNodeTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialGenericMathNode.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_tutorials_GenericMathNode" (
docs="""This is a tutorial node. It is functionally equivalent to the built-in Multiply node, but written in python as a practical demonstration of using extended attributes to write math nodes that work with any numeric types, including arrays and tuples."""
)
{
token node:type = "omni.graph.tutorials.GenericMathNode"
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.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialCpuGpuDataTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialCpuGpuData.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_tutorials_CpuGpuData" (
docs="""This is a tutorial node. It illustrates how to access data whose memory location, CPU or GPU, is determined at runtime in the compute method. The data types are the same as for the purely CPU and purely GPU tutorials, it is only the access method that changes. The input 'is_gpu' determines where the data of the other attributes can be accessed."""
)
{
token node:type = "omni.graph.tutorials.CpuGpuData"
int node:typeVersion = 1
# 5 attributes
custom float inputs:a = 0.0 (
docs="""First value to be added in algorithm 1"""
)
custom float inputs:b = 0.0 (
docs="""Second value to be added in algorithm 1"""
)
custom bool inputs:is_gpu = false (
docs="""Runtime switch determining where the data for the other attributes lives."""
)
custom float3 inputs:multiplier = (1.0, 1.0, 1.0) (
docs="""Amplitude of the expansion for the input points in algorithm 2"""
)
custom float3[] inputs:points = [] (
docs="""Points to be moved by algorithm 2"""
)
# 2 attributes
custom float3[] outputs:points (
docs="""Final positions of points from algorithm 2"""
)
custom float outputs:sum (
docs="""Sum of the two inputs from algorithm 1"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialBundleAddAttributesTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialBundleAddAttributes.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_tutorials_BundleAddAttributes" (
docs="""This is a tutorial node. It exercises functionality for adding and removing attributes on output bundles."""
)
{
token node:type = "omni.graph.tutorials.BundleAddAttributes"
int node:typeVersion = 1
# 4 attributes
custom token[] inputs:addedAttributeNames = [] (
docs="""Names for the attribute types to be added. The size of this array must match the size
of the 'typesToAdd' array to be legal."""
)
custom token[] inputs:removedAttributeNames = [] (
docs="""Names for the attribute types to be removed. Non-existent attributes will be ignored."""
)
custom token[] inputs:typesToAdd = [] (
docs="""List of type descriptions to add to the bundle. The strings in this list correspond to the
strings that represent the attribute types in the .ogn file (e.g. float[3][], colord[3], bool"""
)
custom bool inputs:useBatchedAPI = false (
docs="""Controls whether or not to used batched APIS for adding/removing attributes"""
)
# 1 attribute
def Output "outputs_bundle" (
docs="""This is the bundle with all attributes added by compute."""
)
{
}
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialTokensTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialTokens.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_tutorials_Tokens" (
docs="""This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list."""
)
{
token node:type = "omni.graph.tutorials.Tokens"
int node:typeVersion = 1
# 1 attribute
custom token[] inputs:valuesToCheck = [] (
docs="""Array of tokens that are to be checked"""
)
# 1 attribute
custom bool[] outputs:isColor (
docs="""True values if the corresponding input value appears in the token list"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialRoleDataTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialRoleData.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_tutorials_RoleData" (
docs="""This is a tutorial node. It creates both an input and output attribute of every supported role-based data type. The values are modified in a simple way so that the compute modifies values. """
)
{
token node:type = "omni.graph.tutorials.RoleData"
int node:typeVersion = 1
# 29 attributes
custom color3d inputs:a_color3d = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a double-precision 3d color"""
)
custom color3f inputs:a_color3f = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a single-precision 3d color"""
)
custom color3h inputs:a_color3h = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a half-precision 3d color"""
)
custom color4d inputs:a_color4d = (0.0, 0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a double-precision 4d color"""
)
custom color4f inputs:a_color4f = (0.0, 0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a single-precision 4d color"""
)
custom color4h inputs:a_color4h = (0.0, 0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a half-precision 4d color"""
)
custom frame4d inputs:a_frame = ((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)) (
docs="""This is an attribute interpreted as a coordinate frame"""
)
custom matrix2d inputs:a_matrix2d = ((1.0, 0.0), (0.0, 1.0)) (
docs="""This is an attribute interpreted as a double-precision 2d matrix"""
)
custom matrix3d inputs:a_matrix3d = ((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)) (
docs="""This is an attribute interpreted as a double-precision 3d matrix"""
)
custom matrix4d inputs:a_matrix4d = ((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)) (
docs="""This is an attribute interpreted as a double-precision 4d matrix"""
)
custom normal3d inputs:a_normal3d = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a double-precision 3d normal"""
)
custom normal3f inputs:a_normal3f = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a single-precision 3d normal"""
)
custom normal3h inputs:a_normal3h = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a half-precision 3d normal"""
)
custom point3d inputs:a_point3d = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a double-precision 3d point"""
)
custom point3f inputs:a_point3f = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a single-precision 3d point"""
)
custom point3h inputs:a_point3h = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a half-precision 3d point"""
)
custom quatd inputs:a_quatd = (0.0, 0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a double-precision 4d quaternion"""
)
custom quatf inputs:a_quatf = (0.0, 0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a single-precision 4d quaternion"""
)
custom quath inputs:a_quath = (0.0, 0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a half-precision 4d quaternion"""
)
custom texCoord2d inputs:a_texcoord2d = (0.0, 0.0) (
docs="""This is an attribute interpreted as a double-precision 2d texcoord"""
)
custom texCoord2f inputs:a_texcoord2f = (0.0, 0.0) (
docs="""This is an attribute interpreted as a single-precision 2d texcoord"""
)
custom texCoord2h inputs:a_texcoord2h = (0.0, 0.0) (
docs="""This is an attribute interpreted as a half-precision 2d texcoord"""
)
custom texCoord3d inputs:a_texcoord3d = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a double-precision 3d texcoord"""
)
custom texCoord3f inputs:a_texcoord3f = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a single-precision 3d texcoord"""
)
custom texCoord3h inputs:a_texcoord3h = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a half-precision 3d texcoord"""
)
custom timecode inputs:a_timecode = 1.0 (
docs="""This is a computed attribute interpreted as a timecode"""
)
custom vector3d inputs:a_vector3d = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a double-precision 3d vector"""
)
custom vector3f inputs:a_vector3f = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a single-precision 3d vector"""
)
custom vector3h inputs:a_vector3h = (0.0, 0.0, 0.0) (
docs="""This is an attribute interpreted as a half-precision 3d vector"""
)
# 29 attributes
custom color3d outputs:a_color3d (
docs="""This is a computed attribute interpreted as a double-precision 3d color"""
)
custom color3f outputs:a_color3f (
docs="""This is a computed attribute interpreted as a single-precision 3d color"""
)
custom color3h outputs:a_color3h (
docs="""This is a computed attribute interpreted as a half-precision 3d color"""
)
custom color4d outputs:a_color4d (
docs="""This is a computed attribute interpreted as a double-precision 4d color"""
)
custom color4f outputs:a_color4f (
docs="""This is a computed attribute interpreted as a single-precision 4d color"""
)
custom color4h outputs:a_color4h (
docs="""This is a computed attribute interpreted as a half-precision 4d color"""
)
custom frame4d outputs:a_frame (
docs="""This is a computed attribute interpreted as a coordinate frame"""
)
custom matrix2d outputs:a_matrix2d (
docs="""This is a computed attribute interpreted as a double-precision 2d matrix"""
)
custom matrix3d outputs:a_matrix3d (
docs="""This is a computed attribute interpreted as a double-precision 3d matrix"""
)
custom matrix4d outputs:a_matrix4d (
docs="""This is a computed attribute interpreted as a double-precision 4d matrix"""
)
custom normal3d outputs:a_normal3d (
docs="""This is a computed attribute interpreted as a double-precision 3d normal"""
)
custom normal3f outputs:a_normal3f (
docs="""This is a computed attribute interpreted as a single-precision 3d normal"""
)
custom normal3h outputs:a_normal3h (
docs="""This is a computed attribute interpreted as a half-precision 3d normal"""
)
custom point3d outputs:a_point3d (
docs="""This is a computed attribute interpreted as a double-precision 3d point"""
)
custom point3f outputs:a_point3f (
docs="""This is a computed attribute interpreted as a single-precision 3d point"""
)
custom point3h outputs:a_point3h (
docs="""This is a computed attribute interpreted as a half-precision 3d point"""
)
custom quatd outputs:a_quatd (
docs="""This is a computed attribute interpreted as a double-precision 4d quaternion"""
)
custom quatf outputs:a_quatf (
docs="""This is a computed attribute interpreted as a single-precision 4d quaternion"""
)
custom quath outputs:a_quath (
docs="""This is a computed attribute interpreted as a half-precision 4d quaternion"""
)
custom texCoord2d outputs:a_texcoord2d (
docs="""This is a computed attribute interpreted as a double-precision 2d texcoord"""
)
custom texCoord2f outputs:a_texcoord2f (
docs="""This is a computed attribute interpreted as a single-precision 2d texcoord"""
)
custom texCoord2h outputs:a_texcoord2h (
docs="""This is a computed attribute interpreted as a half-precision 2d texcoord"""
)
custom texCoord3d outputs:a_texcoord3d (
docs="""This is a computed attribute interpreted as a double-precision 3d texcoord"""
)
custom texCoord3f outputs:a_texcoord3f (
docs="""This is a computed attribute interpreted as a single-precision 3d texcoord"""
)
custom texCoord3h outputs:a_texcoord3h (
docs="""This is a computed attribute interpreted as a half-precision 3d texcoord"""
)
custom timecode outputs:a_timecode (
docs="""This is a computed attribute interpreted as a timecode"""
)
custom vector3d outputs:a_vector3d (
docs="""This is a computed attribute interpreted as a double-precision 3d vector"""
)
custom vector3f outputs:a_vector3f (
docs="""This is a computed attribute interpreted as a single-precision 3d vector"""
)
custom vector3h outputs:a_vector3h (
docs="""This is a computed attribute interpreted as a half-precision 3d vector"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialBundleDataTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialBundleData.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_tutorials_BundleData" (
docs="""This is a tutorial node. It exercises functionality for access of data within bundle attributes."""
)
{
token node:type = "omni.graph.tutorials.BundleData"
int node:typeVersion = 1
# 1 attribute
custom rel inputs:bundle (
docs="""Bundle whose contents are modified for passing to the output"""
)
# 1 attribute
def Output "outputs_bundle" (
docs="""This is the bundle with values of known types doubled."""
)
{
}
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialStateTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialState.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_tutorials_State" (
docs="""This is a tutorial node. It makes use of internal state information to continuously increment an output."""
)
{
token node:type = "omni.graph.tutorials.State"
int node:typeVersion = 1
# 2 attributes
custom bool inputs:override = false (
docs="""When true get the output from the overrideValue, otherwise use the internal value"""
)
custom int64 inputs:overrideValue = 0 (
docs="""Value to use instead of the monotonically increasing internal one when 'override' is true"""
)
# 1 attribute
custom int64 outputs:monotonic = 0 (
docs="""Monotonically increasing output, set by internal state information"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialBundlesPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialBundlesPy.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_tutorials_BundleManipulationPy" (
docs="""This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents. The configuration is the same as omni.graph.tutorials.BundleManipulation except that the implementation language is Python"""
)
{
token node:type = "omni.graph.tutorials.BundleManipulationPy"
int node:typeVersion = 1
# 3 attributes
custom rel inputs:filteredBundle (
docs="""Bundle whose contents are filtered before being added to the output"""
)
custom token[] inputs:filters = [] (
docs="""List of filter names to be applied to the filteredBundle. Any filter name
appearing in this list will be applied to members of that bundle and only those
passing all filters will be added to the output bundle. Legal filter values are
'big' (arrays of size > 10), 'x' (attributes whose name contains the letter x),
and 'int' (attributes whose base type is integer)."""
)
custom rel inputs:fullBundle (
docs="""Bundle whose contents are passed to the output in their entirety"""
)
# 1 attribute
def Output "outputs_combinedBundle" (
docs="""This is the union of fullBundle and filtered members of the filteredBundle."""
)
{
}
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialArrayDataTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialArrayData.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_tutorials_ArrayData" (
docs="""This is a tutorial node. It will compute the array 'result' as the input array 'original' with every element multiplied by the constant 'multiplier'."""
)
{
token node:type = "omni.graph.tutorials.ArrayData"
int node:typeVersion = 1
# 4 attributes
custom bool[] inputs:gates = [] (
docs="""Boolean mask telling which elements of the array should be multiplied"""
)
custom token[] inputs:info = ['There', 'is', 'no', 'data'] (
docs="""List of strings providing commentary"""
)
custom float inputs:multiplier = 1.0 (
docs="""Multiplier of the array elements"""
)
custom float[] inputs:original = [] (
docs="""Array to be multiplied"""
)
# 3 attributes
custom int outputs:infoSize (
docs="""Number of letters in all strings in the info input"""
)
custom bool[] outputs:negativeValues (
docs="""Array of booleans set to true if the corresponding 'result' is negative"""
)
custom float[] outputs:result (
docs="""Multiplied array"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialTokensPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialTokensPy.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_tutorials_TokensPy" (
docs="""This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list."""
)
{
token node:type = "omni.graph.tutorials.TokensPy"
int node:typeVersion = 1
# 1 attribute
custom token[] inputs:valuesToCheck = [] (
docs="""Array of tokens that are to be checked"""
)
# 1 attribute
custom bool[] outputs:isColor (
docs="""True values if the corresponding input value appears in the token list"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialDynamicAttributesTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialDynamicAttributes.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_tutorials_DynamicAttributes" (
docs="""This is a Python node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001)."""
)
{
token node:type = "omni.graph.tutorials.DynamicAttributes"
int node:typeVersion = 1
# 1 attribute
custom uint inputs:value = 0 (
docs="""Original value to be modified."""
)
# 1 attribute
custom uint outputs:result (
docs="""Modified value"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialCpuGpuExtendedPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialCpuGpuExtendedPy.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_tutorials_CpuGpuExtendedPy" (
docs="""This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtended.ogn, except is is implemented in Python."""
)
{
token node:type = "omni.graph.tutorials.CpuGpuExtendedPy"
int node:typeVersion = 1
# 3 attributes
custom token inputs:cpuData = "any" (
docs="""Input attribute whose data always lives on the CPU"""
)
custom bool inputs:gpu = false (
docs="""If true then put the sum on the GPU, otherwise put it on the CPU"""
)
custom token inputs:gpuData = "any" (
docs="""Input attribute whose data always lives on the GPU"""
)
# 1 attribute
custom token outputs:cpuGpuSum = "any" (
docs="""This is the attribute with the selected data. If the 'gpu' attribute is set to true then this
attribute's contents will be entirely on the GPU, otherwise it will be on the CPU."""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialABITemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialABI.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_tutorials_Abi" (
docs="""This tutorial node shows how to override ABI methods on your node."""
)
{
token node:type = "omni.graph.tutorials.Abi"
int node:typeVersion = 1
# 1 attribute
custom bool inputs:namespace:a_bool = true (
docs="""The input is any boolean value"""
)
# 1 attribute
custom bool outputs:namespace:a_bool = true (
docs="""The output is computed as the negation of the input"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialTupleArraysTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialTupleArrays.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_tutorials_TupleArrays" (
docs="""This is a tutorial node. It will compute the float array 'result' as the elementwise dot product of the input arrays 'a' and 'b'."""
)
{
token node:type = "omni.graph.tutorials.TupleArrays"
int node:typeVersion = 1
# 2 attributes
custom float3[] inputs:a = [] (
docs="""First array"""
)
custom float3[] inputs:b = [] (
docs="""Second array"""
)
# 1 attribute
custom float[] outputs:result = [] (
docs="""Dot-product array"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialCudaDataCpuTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialCudaDataCpu.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_tutorials_CudaCpuArrays" (
docs="""This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device."""
)
{
token node:type = "omni.graph.tutorials.CudaCpuArrays"
int node:typeVersion = 1
# 2 attributes
custom float3 inputs:multiplier = (1.0, 1.0, 1.0) (
docs="""Amplitude of the expansion for the input points"""
)
custom float3[] inputs:points = [] (
docs="""Array of points to be moved"""
)
# 1 attribute
custom float3[] outputs:points (
docs="""Final positions of points"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialDynamicAttributesPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialDynamicAttributesPy.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_tutorials_DynamicAttributesPy" (
docs="""This is a Python node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001)."""
)
{
token node:type = "omni.graph.tutorials.DynamicAttributesPy"
int node:typeVersion = 1
# 1 attribute
custom uint inputs:value = 0 (
docs="""Original value to be modified."""
)
# 1 attribute
custom uint outputs:result (
docs="""Modified value"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialExtendedTypesPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialExtendedTypesPy.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_tutorials_ExtendedTypesPy" (
docs="""This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types. It is identical to OgnTutorialExtendedTypes.ogn, except the language of implementation is selected to be python."""
)
{
token node:type = "omni.graph.tutorials.ExtendedTypesPy"
int node:typeVersion = 1
# 4 attributes
custom token inputs:flexible (
docs="""Flexible data type input"""
)
custom token inputs:floatOrToken (
docs="""Attribute that can either be a float value or a token value"""
)
custom token inputs:toNegate (
docs="""Attribute that can either be an array of booleans or an array of floats"""
)
custom token inputs:tuple = "any" (
docs="""Variable size/type tuple values"""
)
# 4 attributes
custom token outputs:doubledResult = "any" (
docs="""If the input 'floatOrToken' is a float this is 2x the value.
If it is a token this contains the input token repeated twice."""
)
custom token outputs:flexible (
docs="""Flexible data type output"""
)
custom token outputs:negatedResult (
docs="""Result of negating the data from the 'toNegate' input"""
)
custom token outputs:tuple = "any" (
docs="""Negated values of the tuple input"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialCpuGpuExtendedTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialCpuGpuExtended.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_tutorials_CpuGpuExtended" (
docs="""This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtendedPy.ogn, except is is implemented in C++."""
)
{
token node:type = "omni.graph.tutorials.CpuGpuExtended"
int node:typeVersion = 1
# 3 attributes
custom token inputs:cpuData = "any" (
docs="""Input attribute whose data always lives on the CPU"""
)
custom bool inputs:gpu = false (
docs="""If true then put the sum on the GPU, otherwise put it on the CPU"""
)
custom token inputs:gpuData = "any" (
docs="""Input attribute whose data always lives on the GPU"""
)
# 1 attribute
custom token outputs:cpuGpuSum = "any" (
docs="""This is the attribute with the selected data. If the 'gpu' attribute is set to true then this
attribute's contents will be entirely on the GPU, otherwise it will be on the CPU."""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialSimpleDataTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialSimpleData.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_tutorials_SimpleData" (
docs="""This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values."""
)
{
token node:type = "omni.graph.tutorials.SimpleData"
int node:typeVersion = 1
# 14 attributes
custom bool inputs:a_bool = true (
docs="""This is an attribute of type boolean"""
)
custom int inputs:a_constant_input = 0 (
docs="""This is an input attribute whose value can be set but can only be connected as a source."""
)
custom double inputs:a_double = 0 (
docs="""This is an attribute of type 64 bit floating point"""
)
custom float inputs:a_float = 0 (
docs="""This is an attribute of type 32 bit floating point"""
)
custom half inputs:a_half = 0.0 (
docs="""This is an attribute of type 16 bit float"""
)
custom int inputs:a_int = 0 (
docs="""This is an attribute of type 32 bit integer"""
)
custom int64 inputs:a_int64 = 0 (
docs="""This is an attribute of type 64 bit integer"""
)
custom uint64 inputs:a_objectId = 0 (
docs="""This is an attribute of type objectId"""
)
custom string inputs:a_path = "" (
docs="""This is an attribute of type path"""
)
custom string inputs:a_string = "helloString" (
docs="""This is an attribute of type string"""
)
custom token inputs:a_token = "helloToken" (
docs="""This is an attribute of type interned string with fast comparison and hashing"""
)
custom uchar inputs:unsigned:a_uchar = 0 (
docs="""This is an attribute of type unsigned 8 bit integer"""
)
custom uint inputs:unsigned:a_uint = 0 (
docs="""This is an attribute of type unsigned 32 bit integer"""
)
custom uint64 inputs:unsigned:a_uint64 = 0 (
docs="""This is an attribute of type unsigned 64 bit integer"""
)
# 13 attributes
custom bool outputs:a_bool = false (
docs="""This is a computed attribute of type boolean"""
)
custom double outputs:a_double = 5.0 (
docs="""This is a computed attribute of type 64 bit floating point"""
)
custom float outputs:a_float = 4.0 (
docs="""This is a computed attribute of type 32 bit floating point"""
)
custom half outputs:a_half = 1.0 (
docs="""This is a computed attribute of type 16 bit float"""
)
custom int outputs:a_int = 2 (
docs="""This is a computed attribute of type 32 bit integer"""
)
custom int64 outputs:a_int64 = 3 (
docs="""This is a computed attribute of type 64 bit integer"""
)
custom uint64 outputs:a_objectId = 8 (
docs="""This is a computed attribute of type objectId"""
)
custom string outputs:a_path = "/" (
docs="""This is a computed attribute of type path"""
)
custom string outputs:a_string = "seven" (
docs="""This is a computed attribute of type string"""
)
custom token outputs:a_token = "six" (
docs="""This is a computed attribute of type interned string with fast comparison and hashing"""
)
custom uchar outputs:unsigned:a_uchar = 9 (
docs="""This is a computed attribute of type unsigned 8 bit integer"""
)
custom uint outputs:unsigned:a_uint = 10 (
docs="""This is a computed attribute of type unsigned 32 bit integer"""
)
custom uint64 outputs:unsigned:a_uint64 = 11 (
docs="""This is a computed attribute of type unsigned 64 bit integer"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialCpuGpuBundlesPyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialCpuGpuBundlesPy.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_tutorials_CpuGpuBundlesPy" (
docs="""This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes the dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundles.ogn, except is is implemented in Python."""
)
{
token node:type = "omni.graph.tutorials.CpuGpuBundlesPy"
int node:typeVersion = 1
# 3 attributes
custom rel inputs:cpuBundle (
docs="""Input bundle whose data always lives on the CPU"""
)
custom bool inputs:gpu = false (
docs="""If true then copy gpuBundle onto the output, otherwise copy cpuBundle"""
)
custom rel inputs:gpuBundle (
docs="""Input bundle whose data always lives on the GPU"""
)
# 1 attribute
def Output "outputs_cpuGpuBundle" (
docs="""This is the bundle with the merged data. If the 'gpu' attribute is set to true then this
bundle's contents will be entirely on the GPU, otherwise it will be on the CPU."""
)
{
}
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialStatePyTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialStatePy.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_tutorials_StatePy" (
docs="""This is a tutorial node. It makes use of internal state information to continuously increment an output."""
)
{
token node:type = "omni.graph.tutorials.StatePy"
int node:typeVersion = 1
# 2 attributes
custom bool inputs:override = false (
docs="""When true get the output from the overrideValue, otherwise use the internal value"""
)
custom int64 inputs:overrideValue = 0 (
docs="""Value to use instead of the monotonically increasing internal one when 'override' is true"""
)
# 1 attribute
custom int64 outputs:monotonic = 0 (
docs="""Monotonically increasing output, set by internal state information"""
)
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialCpuGpuBundlesTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialCpuGpuBundles.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_tutorials_CpuGpuBundles" (
docs="""This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes their dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundlesPy.ogn, except it is implemented in C++."""
)
{
token node:type = "omni.graph.tutorials.CpuGpuBundles"
int node:typeVersion = 1
# 3 attributes
custom rel inputs:cpuBundle (
docs="""Input bundle whose data always lives on the CPU"""
)
custom bool inputs:gpu = false (
docs="""If true then copy gpuBundle onto the output, otherwise copy cpuBundle"""
)
custom rel inputs:gpuBundle (
docs="""Input bundle whose data always lives on the GPU"""
)
# 1 attribute
def Output "outputs_cpuGpuBundle" (
docs="""This is the bundle with the merged data. If the 'gpu' attribute is set to true then this
bundle's contents will be entirely on the GPU, otherwise they will be on the CPU."""
)
{
}
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tests/usd/OgnTutorialBundlesTemplate.usda | #usda 1.0
(
doc ="""Generated from node description file OgnTutorialBundles.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_tutorials_BundleManipulation" (
docs="""This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents."""
)
{
token node:type = "omni.graph.tutorials.BundleManipulation"
int node:typeVersion = 1
# 3 attributes
custom rel inputs:filteredBundle (
docs="""Bundle whose contents are filtered before being added to the output"""
)
custom token[] inputs:filters = [] (
docs="""List of filter names to be applied to the filteredBundle. Any filter name
appearing in this list will be applied to members of that bundle and only those
passing all filters will be added to the output bundle. Legal filter values are
'big' (arrays of size > 10), 'x' (attributes whose name contains the letter x),
and 'int' (attributes whose base type is integer)."""
)
custom rel inputs:fullBundle (
docs="""Bundle whose contents are passed to the output in their entirety"""
)
# 1 attribute
def Output "outputs_combinedBundle" (
docs="""This is the union of fullBundle and filtered members of the filteredBundle."""
)
{
}
}
}
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/_impl/extension.py | """Support required by the Carbonite extension loader"""
import omni.ext
from ..bindings._omni_graph_tutorials import acquire_interface as _acquire_interface # noqa: PLE0402
from ..bindings._omni_graph_tutorials import release_interface as _release_interface # noqa: PLE0402
class _PublicExtension(omni.ext.IExt):
"""Object that tracks the lifetime of the Python part of the extension loading"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__interface = None
def on_startup(self):
"""Set up initial conditions for the Python part of the extension"""
self.__interface = _acquire_interface()
def on_shutdown(self):
"""Shutting down this part of the extension prepares it for hot reload"""
if self.__interface is not None:
_release_interface(self.__interface)
self.__interface = None
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/test_omnigraph_python_interface.py | """Basic tests of the Python interface to C++ nodes generated from a .ogn file"""
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.tutorials.ogn.OgnTutorialSimpleDataDatabase import OgnTutorialSimpleDataDatabase
# ======================================================================
class TestOmniGraphPythonInterface(ogts.OmniGraphTestCase):
"""Run a simple unit test that exercises generated Python interface functionality"""
# ----------------------------------------------------------------------
async def test_setting_in_ogn_python_api(self):
"""Test ability to set inputs on a node and retrieve them"""
(_, [simple_node], _, _) = og.Controller.edit(
"/TestGraph",
{
og.Controller.Keys.CREATE_NODES: ("PyTest_SimpleNode", "omni.graph.tutorials.SimpleData"),
},
)
await og.Controller.evaluate()
interface = OgnTutorialSimpleDataDatabase(simple_node)
# Set input values through the database interface
interface.inputs.a_bool = False
interface.inputs.a_half = 2.0
interface.inputs.a_int = 3
interface.inputs.a_int64 = 4
interface.inputs.a_float = 5.0
interface.inputs.a_double = 6.0
# interface.inputs.a_token = "hello"
interface.inputs.unsigned_a_uchar = 7
interface.inputs.unsigned_a_uint = 8
interface.inputs.unsigned_a_uint64 = 9
# Run the node's compute method
await og.Controller.evaluate()
# Retrieve output values from the database interface and verify against expected values
self.assertEqual(interface.outputs.a_bool, True)
self.assertAlmostEqual(interface.outputs.a_half, 3.0)
self.assertEqual(interface.outputs.a_int, 4)
self.assertEqual(interface.outputs.a_int64, 5)
self.assertAlmostEqual(interface.outputs.a_float, 6.0)
self.assertAlmostEqual(interface.outputs.a_double, 7.0)
# self.assertEqual(interface.outputs.a_token, "world")
self.assertEqual(interface.outputs.unsigned_a_uchar, 8)
self.assertEqual(interface.outputs.unsigned_a_uint, 9)
self.assertEqual(interface.outputs.unsigned_a_uint64, 10)
# ----------------------------------------------------------------------
async def test_check_has_state(self):
"""Test ability to correctly determine if a node has marked itself as having internal state"""
stateless_node_type = og.get_node_type("omni.graph.tutorials.SimpleData")
stateful_node_type = og.get_node_type("omni.graph.tutorials.StatePy")
self.assertFalse(stateless_node_type.has_state())
self.assertTrue(stateful_node_type.has_state())
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/test_api.py | """Testing the stability of the API in this module"""
import omni.graph.core.tests as ogts
import omni.graph.tutorials as ogtu
from omni.graph.tools.tests.internal_utils import _check_module_api_consistency, _check_public_api_contents
# ======================================================================
class _TestOmniGraphTutorialsApi(ogts.OmniGraphTestCase):
_UNPUBLISHED = ["bindings", "ogn", "tests"]
async def test_api(self):
_check_module_api_consistency(ogtu, self._UNPUBLISHED) # noqa: PLW0212
_check_module_api_consistency(ogtu.tests, is_test_module=True) # noqa: PLW0212
async def test_api_features(self):
"""Test that the known public API features continue to exist"""
_check_public_api_contents(ogtu, [], self._UNPUBLISHED, only_expected_allowed=True) # noqa: PLW0212
_check_public_api_contents(ogtu.tests, [], [], only_expected_allowed=True) # noqa: PLW0212
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/__init__.py | """There is no public API to this module."""
__all__ = []
scan_for_test_modules = True
"""The presence of this object causes the test runner to automatically scan the directory for unit test cases"""
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/test_tutorial_extended_types.py | """
Tests for the omni.graph.tutorials.ExtendedTypes and omni.graph.tutorials.ExtendedTypesPy nodes
"""
import omni.graph.core as og
import omni.graph.core.tests as ogts
class TestTutorialExtendedTypes(ogts.OmniGraphTestCase):
"""Extended attribute type tests require multiple nodes, not supported in the .ogn test framework"""
# ----------------------------------------------------------------------
async def _test_tutorial_extended_attributes_node(self, test_node_type_name: str):
"""Test basic operation of the tutorial node containing extended attributes"""
# Set up a graph that creates full type resolution for simple and array types of the extended attribute node
#
# SimpleIn ----=> Extended1 ----=> SimpleOut
# \ / \ /
# X X
# / \ / \
# ArrayIn ----=> Extended2 ----=> ArrayOut
#
keys = og.Controller.Keys
(_, [simple_node, _, extended_node_1, extended_node_2, array_node, _], _, _) = og.Controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: [
("SimpleIn", "omni.graph.tutorials.SimpleData"),
("SimpleOut", "omni.graph.tutorials.SimpleData"),
("Extended1", test_node_type_name),
("Extended2", test_node_type_name),
("ArrayIn", "omni.graph.tutorials.ArrayData"),
("ArrayOut", "omni.graph.tutorials.ArrayData"),
],
keys.CONNECT: [
("SimpleIn.outputs:a_float", "Extended1.inputs:floatOrToken"),
("Extended1.outputs:doubledResult", "SimpleOut.inputs:a_float"),
("ArrayIn.outputs:result", "Extended1.inputs:toNegate"),
("Extended1.outputs:negatedResult", "ArrayOut.inputs:original"),
("SimpleIn.outputs:a_token", "Extended2.inputs:floatOrToken"),
("Extended2.outputs:doubledResult", "SimpleOut.inputs:a_token"),
("ArrayIn.outputs:negativeValues", "Extended2.inputs:toNegate"),
("Extended2.outputs:negatedResult", "ArrayOut.inputs:gates"),
],
keys.SET_VALUES: [
("SimpleIn.inputs:a_float", 5.0),
("SimpleIn.inputs:a_token", "hello"),
("ArrayIn.inputs:multiplier", 2.0),
("ArrayIn.inputs:original", [5.0, -6.0]),
("ArrayIn.inputs:gates", [False, True]),
],
},
)
await og.Controller.evaluate()
# Check that the inputs into the extended type nodes are correct
self.assertEqual(6.0, og.Controller.get(("outputs:a_float", simple_node)))
self.assertEqual("world", og.Controller.get(("outputs:a_token", simple_node)))
self.assertCountEqual([5.0, -12.0], og.Controller.get(("outputs:result", array_node)))
self.assertCountEqual([False, True], og.Controller.get(("outputs:negativeValues", array_node)))
# Check the extended simple value outputs
self.assertEqual(12.0, og.Controller.get(("outputs:doubledResult", extended_node_1)))
self.assertEqual("worldworld", og.Controller.get(("outputs:doubledResult", extended_node_2)))
# Check the extended array value outputs
self.assertCountEqual([-5.0, 12.0], og.Controller.get(("outputs:negatedResult", extended_node_1)))
self.assertCountEqual([True, False], og.Controller.get(("outputs:negatedResult", extended_node_2)))
# ----------------------------------------------------------------------
async def test_tutorial_extended_attributes_node_cpp(self):
"""Test basic operation of the C++ tutorial node containing extended attributes."""
await self._test_tutorial_extended_attributes_node("omni.graph.tutorials.ExtendedTypes")
# ----------------------------------------------------------------------
async def test_tutorial_extended_attributes_node_python(self):
"""Test basic operation of the Python tutorial node containing extended attributes."""
await self._test_tutorial_extended_attributes_node("omni.graph.tutorials.ExtendedTypesPy")
# ----------------------------------------------------------------------
async def _test_tutorial_extended_attributes_tuples(self, test_node_type_name: str):
"""Test basic operation of the tutorial node containing extended attributes on its tuple-accepting attributes"""
# Set up a graph that creates full type resolution for the tuple types of the extended attribute node with
# two different resolved types.
#
keys = og.Controller.Keys
(
_,
[tuple_node, _, extended_node_1, extended_node_2, tuple_array_node, _, simple_node, _],
_,
_,
) = og.Controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: [
("TupleIn", "omni.tutorials.TupleData"),
("TupleOut", "omni.tutorials.TupleData"),
("Extended1", test_node_type_name),
("Extended2", test_node_type_name),
("TupleArrayIn", "omni.graph.tutorials.TupleArrays"),
("TupleArrayOut", "omni.graph.tutorials.TupleArrays"),
("SimpleIn", "omni.graph.tutorials.SimpleData"),
("SimpleOut", "omni.graph.tutorials.SimpleData"),
],
keys.CONNECT: [
("TupleIn.outputs:a_int2", "Extended1.inputs:tuple"),
("Extended1.outputs:tuple", "TupleOut.inputs:a_int2"),
("TupleArrayIn.inputs:a", "Extended1.inputs:flexible"),
("Extended1.outputs:flexible", "TupleArrayOut.inputs:a"),
("TupleIn.outputs:a_float3", "Extended2.inputs:tuple"),
("Extended2.outputs:tuple", "TupleOut.inputs:a_float3"),
("SimpleIn.outputs:a_token", "Extended2.inputs:flexible"),
("Extended2.outputs:flexible", "SimpleOut.inputs:a_token"),
],
keys.SET_VALUES: [
("TupleIn.inputs:a_int2", [4, 2]),
("TupleIn.inputs:a_float3", (4.0, 10.0, 2.0)),
("TupleArrayIn.inputs:a", [[2.0, 3.0, 7.0], [21.0, 14.0, 6.0]]),
("TupleArrayIn.inputs:b", [[21.0, 14.0, 6.0], [2.0, 3.0, 7.0]]),
("SimpleIn.inputs:a_token", "hello"),
],
},
)
await og.Controller.evaluate()
# Check that the inputs into the extended type nodes are correct
self.assertEqual("world", og.Controller.get(("outputs:a_token", simple_node)))
self.assertCountEqual([5, 3], og.Controller.get(("outputs:a_int2", tuple_node)))
self.assertCountEqual([5.0, 11.0, 3.0], og.Controller.get(("outputs:a_float3", tuple_node)))
self.assertCountEqual([126.0, 126.0], og.Controller.get(("outputs:result", tuple_array_node)))
# Check the resulting values from resolving the "any" type to tuples
self.assertCountEqual([-5, -3], og.Controller.get(("outputs:tuple", extended_node_1)))
self.assertCountEqual([-5.0, -11.0, -3.0], og.Controller.get(("outputs:tuple", extended_node_2)))
# Check the resulting values from resolving the flexible type as both of its types
self.assertEqual("dlrow", og.Controller.get(("outputs:flexible", extended_node_2)))
list_expected = [[-2.0, -3.0, -7.0], [-21.0, -14.0, -6.0]]
list_computed = og.Controller.get(("outputs:flexible", extended_node_1))
for expected, computed in zip(list_expected, list_computed):
self.assertCountEqual(expected, computed)
# ----------------------------------------------------------------------
async def test_tutorial_extended_attributes_tuples_cpp(self):
"""Test basic operation of the C++ tutorial node containing extended attributes."""
await self._test_tutorial_extended_attributes_tuples("omni.graph.tutorials.ExtendedTypes")
# ----------------------------------------------------------------------
async def test_tutorial_extended_attributes_tuples_python(self):
"""Test basic operation of the Python tutorial node containing extended attributes."""
await self._test_tutorial_extended_attributes_tuples("omni.graph.tutorials.ExtendedTypesPy")
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/test_omnigraph_deletion.py | """OmniGraph deletion tests"""
import omni.graph.core as og
import omni.graph.core.tests as ogts
import omni.kit.commands
import omni.kit.test
import omni.usd
class TestOmniGraphDeletion(ogts.OmniGraphTestCase):
# In these tests, we test various aspects of deleting things from OG
async def test_omnigraph_usd_deletion(self):
# In this test we set up 2 very similar looking nodes:
# /new_node and /new_node_01. We then delete /new_node
# The idea is that this looks very similar to cases like
# /parent/path/stuff/mynode where we delete /parent/path
# In that case we want to delete mynode, but in our case
# we do not want to delete /new_node_01 when /new_node is
# deleted.
keys = og.Controller.Keys
(graph, [new_node, new_node_01], _, _) = og.Controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: [
("new_node", "omni.graph.tutorials.Empty"),
("new_node_01", "omni.graph.tutorials.Empty"),
]
},
)
await og.Controller.evaluate()
self.assertIsNotNone(new_node_01)
self.assertTrue(new_node_01.is_valid())
self.assertIsNotNone(new_node)
self.assertTrue(new_node.is_valid())
og.Controller.delete_node(new_node)
new_node_01 = graph.get_node("/TestGraph/new_node_01")
self.assertIsNotNone(new_node_01)
self.assertTrue(new_node_01.is_valid())
new_node = graph.get_node("/TestGraph/new_node")
self.assertTrue(not new_node.is_valid())
omni.kit.undo.undo()
new_node_01 = graph.get_node("/TestGraph/new_node_01")
self.assertIsNotNone(new_node_01)
self.assertTrue(new_node_01.is_valid())
new_node = graph.get_node("/TestGraph/new_node")
self.assertIsNotNone(new_node)
self.assertTrue(new_node.is_valid())
# --------------------------------------------------------------------------------------------------------------
async def test_fabric_dangling_connections(self):
# In this test we create two nodes, connect them together. The output of the first node drives the input
# of the second node. When we break the connection, we need to verify that the output of the second node
# now takes its input from its own value, rather than the connected value (ie. the connection is actually
# broken in the fabric).
keys = og.Controller.Keys
(graph, [node_a, node_b], _, _) = og.Controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: [
("node_a", "omni.graph.tutorials.SimpleData"),
("node_b", "omni.graph.tutorials.SimpleData"),
]
},
)
await og.Controller.evaluate()
node_a = graph.get_node("/TestGraph/node_a")
self.assertIsNotNone(node_a)
self.assertTrue(node_a.is_valid())
node_b = graph.get_node("/TestGraph/node_b")
self.assertIsNotNone(node_b)
self.assertTrue(node_b.is_valid())
upstream_attr = node_a.get_attribute("outputs:a_int")
downstream_attr = node_b.get_attribute("inputs:a_int")
og.Controller.connect(upstream_attr, downstream_attr)
await og.Controller.evaluate()
# This node "omni.graph.tutorials.SimpleData" add 1 to the input. The default value of a_int is 0, so the output
# of the first node is 1. When this is used as the input to the second node, we expect the value to be 2:
value = og.Controller.get(node_b.get_attribute("outputs:a_int"))
self.assertEqual(value, 2)
og.Controller.disconnect(upstream_attr, downstream_attr)
await og.Controller.evaluate()
# Now that the connection is broken, the value should now be 1. However, if it didn't actually break the
# connection in the fabric, the graph would still "think" it's connected and output 2.
value = og.Controller.get(node_b.get_attribute("outputs:a_int"))
self.assertEqual(value, 1)
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/test_tutorial_state.py | """
Tests for the omnigraph.tutorial.state node
"""
import omni.graph.core as og
import omni.graph.core.tests as ogts
class TestTutorialState(ogts.OmniGraphTestCase):
""".ogn tests only run once while state tests require multiple evaluations, handled here"""
# ----------------------------------------------------------------------
async def test_tutorial_state_node(self):
"""Test basic operation of the tutorial node containing internal node state"""
self.assertTrue(og.get_node_type("omni.graph.tutorials.State").has_state(), "Tutorial state node has state")
# Create a set of state nodes, updating after each one so that the state information is properly initialized.
# If that requirement weren't there this would just be done in one call.
state_nodes = []
for index in range(5):
(graph, new_nodes, _, _) = og.Controller.edit(
"/StateGraph",
{
og.Controller.Keys.CREATE_NODES: [
(f"State{index}", "omni.graph.tutorials.State"),
]
},
)
state_nodes.append(new_nodes[0])
await og.Controller.evaluate(graph)
output_attrs = [state_node.get_attribute("outputs:monotonic") for state_node in state_nodes]
output_values = [og.Controller(output_attr).get() for output_attr in output_attrs]
for i in range(len(output_values) - 1):
self.assertLess(output_values[i], output_values[i + 1], "Comparing state of other nodes")
await og.Controller.evaluate(graph)
new_values = [og.Controller(output_attr).get() for output_attr in output_attrs]
for i in range(len(new_values) - 1):
self.assertLess(new_values[i], new_values[i + 1], "Comparing second state of other nodes")
for i, new_value in enumerate(new_values):
self.assertLess(output_values[i], new_value, "Comparing node state updates")
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/test_tutorial_state_attributes_py.py | """
Tests for the omnigraph.tutorial.stateAttributesPy node
"""
import omni.graph.core as og
import omni.graph.core.tests as ogts
class TestTutorialStateAttributesPy(ogts.OmniGraphTestCase):
""".ogn tests only run once while state tests require multiple evaluations, handled here"""
# ----------------------------------------------------------------------
async def test_tutorial_state_attributes_py_node(self):
"""Test basic operation of the Python tutorial node containing state attributes"""
keys = og.Controller.Keys
(_, [state_node], _, _) = og.Controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: ("StateNode", "omni.graph.tutorials.StateAttributesPy"),
keys.SET_VALUES: ("StateNode.state:reset", True),
},
)
await og.Controller.evaluate()
reset_attr = og.Controller.attribute("state:reset", state_node)
monotonic_attr = og.Controller.attribute("state:monotonic", state_node)
self.assertEqual(og.Controller.get(reset_attr), False, "Reset attribute set back to False")
self.assertEqual(og.Controller.get(monotonic_attr), 0, "Monotonic attribute reset to start")
await og.Controller.evaluate()
self.assertEqual(og.Controller.get(reset_attr), False, "Reset attribute still False")
self.assertEqual(og.Controller.get(monotonic_attr), 1, "Monotonic attribute incremented once")
await og.Controller.evaluate()
self.assertEqual(og.Controller.get(monotonic_attr), 2, "Monotonic attribute incremented twice")
og.Controller.set(reset_attr, True)
await og.Controller.evaluate()
self.assertEqual(og.Controller.get(reset_attr), False, "Reset again set back to False")
self.assertEqual(og.Controller.get(monotonic_attr), 0, "Monotonic attribute again reset to start")
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/test_omnigraph_bundles.py | """
Tests for attribute bundles
"""
import unittest
from contextlib import suppress
from typing import Any, List, Tuple
import omni.graph.core as og
import omni.graph.core.tests as ogts
import omni.graph.nodes.tests as ognts
import omni.graph.tools as ogt
from omni.kit.test.teamcity import is_running_in_teamcity
from pxr import Gf
# ==============================================================================================================
def multiply_elements(multiplier, original: Any) -> Any:
"""Take in a numeric value, tuple, list, tuple of tuples, etc. and multiply every element by a constant"""
if isinstance(original, tuple):
return tuple(multiply_elements(multiplier, element) for element in original)
if isinstance(original, list):
return tuple(multiply_elements(multiplier, element) for element in original)
return multiplier * original
# ==============================================================================================================
def as_tuple(value: Any) -> Tuple:
"""Return the value, interpreted as a tuple (except simple values, which are returned as themselves)"""
if isinstance(value, tuple):
return value
if isinstance(value, list):
return tuple(value)
if isinstance(value, (Gf.Quatd, Gf.Quatf, Gf.Quath)):
return (*value.GetImaginary(), value.GetReal())
if isinstance(value, Gf.Matrix4d):
return tuple(tuple(element for element in list(row)) for row in value)
with suppress(TypeError):
if len(value) > 1:
return tuple(value)
return value
# ==============================================================================================================
class TestOmniGraphBundles(ogts.OmniGraphTestCase):
"""Attribute bundles do not yet have the ability to log tests directly in a .ogn file so it's done here"""
# --------------------------------------------------------------------------------------------------------------
def _compare_results(self, expected_raw: Any, actual_raw: Any, test_info: str):
"""Loose comparison of two types of compatible values
Args:
expected_raw: Expected results. Can be simple values, tuples, lists, or pxr.Gf types
actual_raw: Actual results. Can be simple values, tuples, lists, or pxr.Gf types
test_info: String to accompany error messages
Returns:
Error encountered when mismatched values found, None if everything matched
"""
expected = as_tuple(expected_raw)
actual = as_tuple(actual_raw)
self.assertEqual(
type(expected), type(actual), f"{test_info} Mismatched types - expected {expected_raw}, got {actual_raw}"
)
if isinstance(expected, tuple):
for expected_element, actual_element in zip(expected, actual):
self._compare_results(expected_element, actual_element, test_info)
else:
self.assertEqual(expected, actual, f"{test_info} Expected {expected}, got {actual}")
# ----------------------------------------------------------------------
async def _test_bundle_contents(self, node_type_to_test: str):
"""Test access to bundle attribute manipulation for C++ and Python implementations"""
keys = og.Controller.Keys
(graph, [bundle_node, inspector_node, _, _], [_, filtered_prim], _) = og.Controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: [
("BundleManipulator", node_type_to_test),
("Inspector", "omni.graph.nodes.BundleInspector"),
],
keys.CREATE_PRIMS: [
("FullPrim", {"fullInt": ("int", 2), "floatArray": ("float[]", [3.0, 4.0, 5.0])}),
(
"FilteredPrim",
{
"int_1": ("int", 6),
"uint_1": ("uint", 7),
"int64_x": ("int64", 8),
"uint64_1": ("uint64", 9),
"int_3": ("int[3]", (10, 11, 12)),
"int_array": ("int[]", [13, 14, 15]),
"float_1": ("float", 3.0),
"double_x": ("double", 4.0),
"big_int": ("int[]", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
},
),
],
keys.EXPOSE_PRIMS: [
(og.Controller.PrimExposureType.AS_BUNDLE, "/FullPrim", "FullPrimExtract"),
(og.Controller.PrimExposureType.AS_BUNDLE, "/FilteredPrim", "FilteredPrimExtract"),
],
keys.CONNECT: [
("FullPrimExtract.outputs_primBundle", "BundleManipulator.inputs:fullBundle"),
("FilteredPrimExtract.outputs_primBundle", "BundleManipulator.inputs:filteredBundle"),
("BundleManipulator.outputs_combinedBundle", "Inspector.inputs:bundle"),
],
},
)
_ = ogt.OGN_DEBUG and ognts.enable_debugging(inspector_node)
await og.Controller.evaluate()
expected_results = {
"big_int": ("int", 1, 1, "none", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
"int_1": ("int", 1, 0, "none", 6),
"uint_1": ("uint", 1, 0, "none", 7),
"int64_x": ("int64", 1, 0, "none", 8),
"uint64_1": ("uint64", 1, 0, "none", 9),
"int_3": ("int", 3, 0, "none", (10, 11, 12)),
"int_array": ("int", 1, 1, "none", [13, 14, 15]),
"float_1": ("float", 1, 0, "none", 3.0),
"double_x": ("double", 1, 0, "none", 4.0),
"fullInt": ("int", 1, 0, "none", 2),
"floatArray": ("float", 1, 1, "none", [3.0, 4.0, 5.0]),
"sourcePrimPath": ("token", 1, 0, "none", str(filtered_prim.GetPrimPath())),
"sourcePrimType": ("token", 1, 0, "none", str(filtered_prim.GetTypeName())),
}
def __result_subset(elements_removed: List[str]):
"""Return the set of results with the index list of elements removed"""
return {key: value for key, value in expected_results.items() if key not in elements_removed}
# Test data consists of a list of individual test configurations with the filters to set and the
# expected contents of the output bundle using those filters.
test_data = [
([], expected_results),
(["x"], __result_subset(["int64_x", "double_x"])),
(["int"], __result_subset(["big_int", "int_1", "uint_1", "int64_x", "uint64_1", "int_3", "int_array"])),
(["big"], __result_subset(["big_int"])),
(
["x", "big", "int"],
__result_subset(
["big_int", "int_1", "uint_1", "int64_x", "uint64_1", "int_3", "int_array", "double_x"]
),
),
]
for (filters, expected_results) in test_data:
og.Controller.edit(
graph,
{
keys.SET_VALUES: (("inputs:filters", bundle_node), filters),
},
)
await og.Controller.evaluate()
try:
ognts.verify_bundles_are_equal(
ognts.filter_bundle_inspector_results(
ognts.bundle_inspector_results(inspector_node), [], filter_for_inclusion=False
),
ognts.filter_bundle_inspector_results(
(len(expected_results), expected_results), [], filter_for_inclusion=False
),
)
except ValueError as error:
self.assertTrue(False, error)
# ----------------------------------------------------------------------
async def test_bundle_contents_cpp(self):
"""Test access to bundle attribute manipulation on the C++ implemented node"""
await self._test_bundle_contents("omni.graph.tutorials.BundleManipulation")
# ----------------------------------------------------------------------
async def test_bundle_contents_py(self):
"""Test bundle attribute manipulation on the Python implemented node"""
await self._test_bundle_contents("omni.graph.tutorials.BundleManipulationPy")
# ----------------------------------------------------------------------
async def _test_simple_bundled_data(self, node_type_to_test: str):
"""Test access to attributes with simple data types within bundles for both C++ and Python implementations"""
controller = og.Controller()
keys = og.Controller.Keys
prim_definition = ognts.prim_with_everything_definition()
(_, [_, inspector_node, _], _, _) = controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: [
("BundledDataModifier", node_type_to_test),
("Inspector", "omni.graph.nodes.BundleInspector"),
],
keys.CREATE_PRIMS: ("TestPrim", prim_definition),
keys.EXPOSE_PRIMS: (og.Controller.PrimExposureType.AS_BUNDLE, "TestPrim", "TestBundle"),
keys.CONNECT: [
("TestBundle.outputs_primBundle", "BundledDataModifier.inputs:bundle"),
("BundledDataModifier.outputs_bundle", "Inspector.inputs:bundle"),
],
},
)
_ = ogt.OGN_DEBUG and ognts.enable_debugging(inspector_node)
await controller.evaluate()
(bundled_count, bundled_results) = ognts.bundle_inspector_results(inspector_node)
# Prim will not have the "sourcePrimXX" attributes so it is smaller by 2
self.assertEqual(len(prim_definition) + 2, bundled_count)
for name, (ogn_type, array_depth, tuple_count, role, actual_output) in bundled_results.items():
if name in ["sourcePrimType", "sourcePrimPath"]:
continue
if not node_type_to_test.endswith("Py") and ogn_type not in ["int", "int64", "uint", "uint64"]:
# The C++ node only handles integer types, in the interest of brevity
continue
test_info = "Bundled"
if tuple_count > 1:
test_info += f" tuple[{tuple_count}]"
if array_depth > 0:
test_info += " array"
test_info += f" attribute {name} of type {ogn_type}"
if role != "none":
test_info += f" (role {role})"
if ogn_type == "token" or role == "text":
expected_output = prim_definition[name][1]
if isinstance(expected_output, str):
expected_output += expected_output
else:
expected_output = [f"{element}{element}" for element in expected_output]
self._compare_results(expected_output, actual_output, test_info)
else:
if ogn_type in ["bool", "bool[]"]:
expected_output = as_tuple(prim_definition[name][1])
else:
expected_output = multiply_elements(2, as_tuple(prim_definition[name][1]))
self._compare_results(expected_output, actual_output, test_info)
# ----------------------------------------------------------------------
async def test_simple_bundled_data_cpp(self):
"""Test access to attributes with simple data types within bundles on the C++ implemented node"""
await self._test_simple_bundled_data("omni.graph.tutorials.BundleData")
# ----------------------------------------------------------------------
async def test_simple_bundled_data_py(self):
"""Test access to attributes with simple data types within bundles on the Python implemented node"""
await self._test_simple_bundled_data("omni.graph.tutorials.BundleDataPy")
# ----------------------------------------------------------------------
async def _test_add_attributes_to_bundle(self, node_type_to_test: str):
"""Test basic operation of the tutorial node that adds new attributes to a bundle"""
keys = og.Controller.Keys
(graph, [add_node, inspector_node], _, _) = og.Controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: [
("AddAttributes", node_type_to_test),
("Inspector", "omni.graph.nodes.BundleInspector"),
],
keys.CONNECT: ("AddAttributes.outputs_bundle", "Inspector.inputs:bundle"),
},
)
await og.Controller.evaluate()
types_attribute = og.Controller.attribute("inputs:typesToAdd", add_node)
added_names_attribute = og.Controller.attribute("inputs:addedAttributeNames", add_node)
removed_names_attribute = og.Controller.attribute("inputs:removedAttributeNames", add_node)
_ = ogt.OGN_DEBUG and ognts.enable_debugging(inspector_node)
# List of test data configurations to run. The individual test entries consist of:
# - list of the types for the attributes to be added
# - list of the base types corresponding to the main types
# - list of names for the attributes to be added
# - list of values expected for the new bundle as (count, roles, arrayDepths, tupleCounts, values)
test_data = [
[
["float", "double", "int", "int64", "uchar", "uint", "uint64", "bool", "token"],
["float", "double", "int", "int64", "uchar", "uint", "uint64", "bool", "token"],
[f"output{n}" for n in range(9)],
(9, ["none"] * 9, [0] * 9, [1] * 9, [0.0, 0.0, 0, 0, 0, 0, 0, False, ""]),
],
[
["float[]", "double[]", "int[]", "int64[]", "uchar[]", "uint[]", "uint64[]", "token[]"],
["float", "double", "int", "int64", "uchar", "uint", "uint64", "token"],
[f"output{n}" for n in range(8)],
(8, ["none"] * 8, [1] * 8, [1] * 8, [[], [], [], [], [], [], [], []]),
],
[
["float[3]", "double[2]", "int[4]"],
["float", "double", "int"],
[f"output{n}" for n in range(3)],
(3, ["none"] * 3, [0] * 3, [3, 2, 4], [[0.0, 0.0, 0.0], [0.0, 0.0], [0, 0, 0, 0]]),
],
[
["float[3][]", "double[2][]", "int[4][]"],
["float", "double", "int"],
[f"output{n}" for n in range(3)],
(3, ["none"] * 3, [1] * 3, [3, 2, 4], [[], [], []]),
],
[
["any"],
["token"],
["output0"],
(1, ["none"], [0], [1], [""]),
],
[
["colord[3]", "colorf[4]", "colorh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["color"] * 3, [0] * 3, [3, 4, 3], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["normald[3]", "normalf[3]", "normalh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["normal"] * 3, [0] * 3, [3, 3, 3], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["pointd[3]", "pointf[3]", "pointh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["point"] * 3, [0] * 3, [3, 3, 3], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["quatd[4]", "quatf[4]", "quath[4]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(
3,
["quat"] * 3,
[0] * 3,
[4, 4, 4],
[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]],
),
],
[
["texcoordd[3]", "texcoordf[2]", "texcoordh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["texcoord"] * 3, [0] * 3, [3, 2, 3], [[0.0, 0.0, 0.0], [0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["vectord[3]", "vectorf[3]", "vectorh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["vector"] * 3, [0] * 3, [3, 3, 3], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["timecode"],
["double"],
["output0"],
(1, ["timecode"], [0], [1], [0.0]),
],
]
for (types, base_types, names, results) in test_data:
og.Controller.edit(
graph,
{
keys.SET_VALUES: [
(types_attribute, types),
(added_names_attribute, names),
]
},
)
await og.Controller.evaluate()
(bundled_count, bundled_results) = ognts.bundle_inspector_results(inspector_node)
self.assertEqual(bundled_count, results[0])
self.assertCountEqual(list(bundled_results.keys()), names)
for index, name in enumerate(names):
error = f"Checking {{}} for attribute {name}"
named_results = bundled_results[name]
self.assertEqual(
named_results[ognts.BundleResultKeys.TYPE_IDX], base_types[index], error.format("type")
)
self.assertEqual(
named_results[ognts.BundleResultKeys.ARRAY_DEPTH_IDX],
results[2][index],
error.format("array depth"),
)
self.assertEqual(
named_results[ognts.BundleResultKeys.TUPLE_COUNT_IDX],
results[3][index],
error.format("tuple count"),
)
self.assertEqual(
named_results[ognts.BundleResultKeys.ROLE_IDX], results[1][index], error.format("role")
)
# One final test run that also includes a remove of the 2nd, 4th, and 7th attributes in the first test list
(types, base_types, names, results) = test_data[0]
og.Controller.edit(
graph,
{
keys.SET_VALUES: [
(types_attribute, types),
(added_names_attribute, names),
(removed_names_attribute, [names[2], names[4], names[7]]),
]
},
)
await og.Controller.evaluate()
def pruned_list(original: List) -> List:
"""Remove the elements 2, 4, 7 from the list and return the result"""
return [item for index, item in enumerate(original) if index not in [2, 4, 7]]
(bundled_count, bundled_results) = ognts.bundle_inspector_results(inspector_node)
# Modify the expected results to account for the removed attributes
self.assertEqual(bundled_count, results[0] - 3)
names_expected = pruned_list(names)
base_types_expected = pruned_list(base_types)
array_depths_expected = pruned_list(results[2])
tuple_counts_expected = pruned_list(results[3])
roles_expected = pruned_list(results[1])
self.assertCountEqual(list(bundled_results.keys()), names_expected)
for index, name in enumerate(names_expected):
error = f"Checking {{}} for attribute {name}"
named_results = bundled_results[name]
self.assertEqual(
named_results[ognts.BundleResultKeys.TYPE_IDX], base_types_expected[index], error.format("type")
)
self.assertEqual(
named_results[ognts.BundleResultKeys.ARRAY_DEPTH_IDX],
array_depths_expected[index],
error.format("array depth"),
)
self.assertEqual(
named_results[ognts.BundleResultKeys.TUPLE_COUNT_IDX],
tuple_counts_expected[index],
error.format("tuple count"),
)
self.assertEqual(
named_results[ognts.BundleResultKeys.ROLE_IDX], roles_expected[index], error.format("role")
)
# ----------------------------------------------------------------------
async def test_add_attributes_to_bundle_cpp(self):
"""Test adding attributes to bundles on the C++ implemented node"""
await self._test_add_attributes_to_bundle("omni.graph.tutorials.BundleAddAttributes")
# ----------------------------------------------------------------------
async def test_add_attributes_to_bundle_py(self):
"""Test adding attributes to bundles on the Python implemented node"""
await self._test_add_attributes_to_bundle("omni.graph.tutorials.BundleAddAttributesPy")
# ----------------------------------------------------------------------
async def _test_batched_add_attributes_to_bundle(self, node_type_to_test: str):
"""Test basic operation of the tutorial node that adds new attributes to a bundle"""
keys = og.Controller.Keys
(graph, [add_node, inspector_node], _, _) = og.Controller.edit(
"/TestGraph",
{
keys.CREATE_NODES: [
("AddAttributes", node_type_to_test),
("Inspector", "omni.graph.nodes.BundleInspector"),
],
keys.CONNECT: ("AddAttributes.outputs_bundle", "Inspector.inputs:bundle"),
},
)
await og.Controller.evaluate()
types_attribute = og.Controller.attribute("inputs:typesToAdd", add_node)
added_names_attribute = og.Controller.attribute("inputs:addedAttributeNames", add_node)
removed_names_attribute = og.Controller.attribute("inputs:removedAttributeNames", add_node)
batched_api_attribute = og.Controller.attribute("inputs:useBatchedAPI", add_node)
_ = ogt.OGN_DEBUG and ognts.enable_debugging(inspector_node)
# List of test data configurations to run. The individual test entries consist of:
# - list of the types for the attributes to be added
# - list of the base types corresponding to the main types
# - list of names for the attributes to be added
# - list of values expected for the new bundle as (count, roles, arrayDepths, tupleCounts, values)
test_data = [
[
["float", "double", "int", "int64", "uchar", "uint", "uint64", "bool", "token"],
["float", "double", "int", "int64", "uchar", "uint", "uint64", "bool", "token"],
[f"output{n}" for n in range(9)],
(9, ["none"] * 9, [0] * 9, [1] * 9, [0.0, 0.0, 0, 0, 0, 0, 0, False, ""]),
],
[
["float[]", "double[]", "int[]", "int64[]", "uchar[]", "uint[]", "uint64[]", "token[]"],
["float", "double", "int", "int64", "uchar", "uint", "uint64", "token"],
[f"output{n}" for n in range(8)],
(8, ["none"] * 8, [1] * 8, [1] * 8, [[], [], [], [], [], [], [], []]),
],
[
["float[3]", "double[2]", "int[4]"],
["float", "double", "int"],
[f"output{n}" for n in range(3)],
(3, ["none"] * 3, [0] * 3, [3, 2, 4], [[0.0, 0.0, 0.0], [0.0, 0.0], [0, 0, 0, 0]]),
],
[
["float[3][]", "double[2][]", "int[4][]"],
["float", "double", "int"],
[f"output{n}" for n in range(3)],
(3, ["none"] * 3, [1] * 3, [3, 2, 4], [[], [], []]),
],
[
["any"],
["token"],
["output0"],
(1, ["none"], [0], [1], [""]),
],
[
["colord[3]", "colorf[4]", "colorh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["color"] * 3, [0] * 3, [3, 4, 3], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["normald[3]", "normalf[3]", "normalh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["normal"] * 3, [0] * 3, [3, 3, 3], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["pointd[3]", "pointf[3]", "pointh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["point"] * 3, [0] * 3, [3, 3, 3], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["quatd[4]", "quatf[4]", "quath[4]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(
3,
["quat"] * 3,
[0] * 3,
[4, 4, 4],
[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]],
),
],
[
["texcoordd[3]", "texcoordf[2]", "texcoordh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["texcoord"] * 3, [0] * 3, [3, 2, 3], [[0.0, 0.0, 0.0], [0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["vectord[3]", "vectorf[3]", "vectorh[3]"],
["double", "float", "half"],
[f"output{n}" for n in range(3)],
(3, ["vector"] * 3, [0] * 3, [3, 3, 3], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
],
[
["timecode"],
["double"],
["output0"],
(1, ["timecode"], [0], [1], [0.0]),
],
]
for (types, base_types, names, results) in test_data:
og.Controller.edit(
graph,
{
keys.SET_VALUES: [
(types_attribute, types),
(added_names_attribute, names),
(batched_api_attribute, True),
]
},
)
await og.Controller.evaluate()
(bundled_count, bundled_results) = ognts.bundle_inspector_results(inspector_node)
self.assertEqual(bundled_count, results[0])
self.assertCountEqual(list(bundled_results.keys()), names)
for index, name in enumerate(names):
error = f"Checking {{}} for attribute {name}"
named_results = bundled_results[name]
self.assertEqual(
named_results[ognts.BundleResultKeys.TYPE_IDX], base_types[index], error.format("type")
)
self.assertEqual(
named_results[ognts.BundleResultKeys.ARRAY_DEPTH_IDX],
results[2][index],
error.format("array depth"),
)
self.assertEqual(
named_results[ognts.BundleResultKeys.TUPLE_COUNT_IDX],
results[3][index],
error.format("tuple count"),
)
self.assertEqual(
named_results[ognts.BundleResultKeys.ROLE_IDX], results[1][index], error.format("role")
)
# One final test run that also includes a remove of the 2nd, 4th, and 7th attributes in the first test list
(types, base_types, names, results) = test_data[0]
og.Controller.edit(
graph,
{
keys.SET_VALUES: [
(types_attribute, types),
(added_names_attribute, names),
(removed_names_attribute, [names[2], names[4], names[7]]),
]
},
)
await og.Controller.evaluate()
def pruned_list(original: List) -> List:
"""Remove the elements 2, 4, 7 from the list and return the result"""
return [item for index, item in enumerate(original) if index not in [2, 4, 7]]
await og.Controller.evaluate()
(bundled_count, bundled_results) = ognts.bundle_inspector_results(inspector_node)
self.assertEqual(bundled_count, results[0] - 3)
# Modify the expected results to account for the removed attributes
names_expected = pruned_list(names)
base_types_expected = pruned_list(base_types)
array_depths_expected = pruned_list(results[2])
tuple_counts_expected = pruned_list(results[3])
roles_expected = pruned_list(results[1])
self.assertCountEqual(list(bundled_results.keys()), names_expected)
for index, name in enumerate(names_expected):
error = f"Checking {{}} for attribute {name}"
named_results = bundled_results[name]
self.assertEqual(
named_results[ognts.BundleResultKeys.TYPE_IDX], base_types_expected[index], error.format("type")
)
self.assertEqual(
named_results[ognts.BundleResultKeys.ARRAY_DEPTH_IDX],
array_depths_expected[index],
error.format("array depth"),
)
self.assertEqual(
named_results[ognts.BundleResultKeys.TUPLE_COUNT_IDX],
tuple_counts_expected[index],
error.format("tuple count"),
)
self.assertEqual(
named_results[ognts.BundleResultKeys.ROLE_IDX], roles_expected[index], error.format("role")
)
# ----------------------------------------------------------------------
async def test_batched_add_attributes_to_bundle_cpp(self):
"""Test adding attributes to bundles on the C++ implemented node"""
await self._test_batched_add_attributes_to_bundle("omni.graph.tutorials.BundleAddAttributes")
# ----------------------------------------------------------------------
async def test_batched_add_attributes_to_bundle_py(self):
"""Test adding attributes to bundles on the Python implemented node"""
await self._test_batched_add_attributes_to_bundle("omni.graph.tutorials.BundleAddAttributesPy")
# ----------------------------------------------------------------------
async def _test_bundle_gpu(self, node_type_to_test: str):
"""Test basic operation of the tutorial node that accesses bundle data on the GPU"""
controller = og.Controller()
keys = og.Controller.Keys
(graph, (bundle_node, inspector_node), _, _) = controller.edit(
"/TestGraph",
{
keys.CREATE_PRIMS: [
("Prim1", {"points": ("pointf[3][]", [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])}),
("Prim2", {"points": ("pointf[3][]", [[4.0, 5.0, 6.0], [7.0, 8.0, 9.0]])}),
],
keys.CREATE_NODES: [
("GpuBundleNode", node_type_to_test),
("Inspector", "omni.graph.nodes.BundleInspector"),
],
},
)
controller.edit(
graph,
{
keys.EXPOSE_PRIMS: [
(og.GraphController.PrimExposureType.AS_BUNDLE, "Prim1", "Prim1Extract"),
(og.GraphController.PrimExposureType.AS_BUNDLE, "Prim2", "Prim2Extract"),
],
keys.CONNECT: [
("Prim1Extract.outputs_primBundle", "GpuBundleNode.inputs:cpuBundle"),
("Prim2Extract.outputs_primBundle", "GpuBundleNode.inputs:gpuBundle"),
("GpuBundleNode.outputs_cpuGpuBundle", "Inspector.inputs:bundle"),
],
},
)
_ = ogt.OGN_DEBUG and ognts.enable_debugging(inspector_node)
await controller.evaluate(graph)
for gpu in [False, True]:
controller.attribute("inputs:gpu", bundle_node, graph).set(gpu)
await controller.evaluate()
(_, bundled_values) = ognts.bundle_inspector_results(inspector_node)
self.assertEqual(bundled_values["dotProducts"][ognts.BundleResultKeys.VALUE_IDX], [32.0, 122.0])
# ----------------------------------------------------------------------
async def test_bundle_gpu_cpp(self):
"""Test access to bundle contents on GPU on the C++ implemented node"""
await self._test_bundle_gpu("omni.graph.tutorials.CpuGpuBundles")
# ----------------------------------------------------------------------
async def test_bundle_gpu_py(self):
"""Test bundle contents on GPU on the Python implemented node"""
await self._test_bundle_gpu("omni.graph.tutorials.CpuGpuBundlesPy")
# ----------------------------------------------------------------------
@unittest.skipIf(is_running_in_teamcity(), "This is a manual test so it only needs to run locally")
async def test_cuda_pointers_py(self):
"""Run a simple test on a node that extracts CUDA pointers from the GPU. Inspect the output for information"""
controller = og.Controller()
keys = og.Controller.Keys
(graph, (_, inspector_node), _, _) = controller.edit(
"/TestGraph",
{
keys.CREATE_PRIMS: [
("Prim1", {"points": ("float[3][]", [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])}),
],
keys.CREATE_NODES: [
("GpuBundleNode", "omni.graph.tutorials.CudaCpuArraysPy"),
("Inspector", "omni.graph.nodes.BundleInspector"),
],
},
)
controller.edit(
graph,
{
keys.EXPOSE_PRIMS: [
(og.GraphController.PrimExposureType.AS_ATTRIBUTES, "Prim1", "Prim1Extract"),
],
},
)
_ = ogt.OGN_DEBUG and ognts.enable_debugging(inspector_node)
await controller.evaluate(graph)
controller.edit(
graph,
{
keys.CONNECT: [
("Prim1Extract.outputs:points", "GpuBundleNode.inputs:points"),
("GpuBundleNode.outputs_outBundle", "Inspector.inputs:bundle"),
],
},
)
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/tests/test_omnigraph_metadata.py | """Basic tests of the metadata bindings found in OmniGraphBindingsPython.cpp"""
import omni.graph.core as og
import omni.graph.core.tests as ogts
import omni.graph.tools.ogn as ogn
# ======================================================================
class TestOmniGraphMetadata(ogts.OmniGraphTestCase):
"""Encapsulate simple tests that exercise metadata access"""
# ----------------------------------------------------------------------
def __node_type_metadata_test(self, node_type: og.NodeType):
"""Test a node type object for metadata access"""
original_count = node_type.get_metadata_count()
key = "_node_type_metadata"
value = "_test_value"
node_type.set_metadata(key, value)
# The new metadata key should now have the new value
self.assertEqual(value, node_type.get_metadata(key))
new_metadata = node_type.get_all_metadata()
# The new key/value pair should now be part of the entire metadata listt
self.assertTrue(key in new_metadata)
self.assertEqual(value, new_metadata[key])
# Since a unique key was chosen there should be one extra metadata value
self.assertEqual(original_count + 1, node_type.get_metadata_count())
# Setting a value to None should remove the metadata from the node type.
# Do this last so that the test can run multiple times successfully.
node_type.set_metadata(key, None)
self.assertEqual(original_count, node_type.get_metadata_count())
# Test silent success of trying to set the metadata to illegal data
node_type.set_metadata(None, value)
# Verify the hardcoded metadata type names
self.assertTrue(ogn.MetadataKeys.UI_NAME in new_metadata)
self.assertTrue(ogn.MetadataKeys.TAGS in new_metadata)
self.assertEqual("Tutorial Node: Tuple Attributes", new_metadata[ogn.MetadataKeys.UI_NAME])
self.assertEqual("tuple,tutorial,internal", new_metadata[ogn.MetadataKeys.TAGS])
# ----------------------------------------------------------------------
async def test_node_type_metadata(self):
"""Test metadata features in the NodeType class"""
# The TupleData tutorial node happens to have special metadata types defined
node_type = og.get_node_type("omni.tutorials.TupleData")
self.assertIsNotNone(node_type, "Empty node type to be used for test was not registered")
self.__node_type_metadata_test(node_type)
# ----------------------------------------------------------------------
async def test_node_metadata(self):
"""Test metadata access through the node class"""
# The TupleData tutorial node happens to have special metadata types defined
(_, [test_node], _, _) = og.Controller.edit(
"/TestGraph",
{
og.Controller.Keys.CREATE_NODES: ("TupleNode", "omni.tutorials.TupleData"),
},
)
await og.Controller.evaluate()
self.__node_type_metadata_test(test_node.get_node_type())
# ----------------------------------------------------------------------
async def test_attribute_metadata(self):
"""Test metadata features in the NodeType class"""
# Any node type will do for metadata tests so use a simple one
(_, [test_node], _, _) = og.Controller.edit(
"/TestGraph",
{
og.Controller.Keys.CREATE_NODES: ("SimpleNode", "omni.graph.tutorials.SimpleData"),
},
)
await og.Controller.evaluate()
self.assertIsNotNone(test_node, "Simple data node type to be used for test was not registered")
test_attribute = test_node.get_attribute("inputs:a_bool")
self.assertIsNotNone(test_attribute, "Boolean input on simple data node type not found")
original_count = test_attribute.get_metadata_count()
key = "_test_attribute_metadata"
value = "_test_value"
test_attribute.set_metadata(key, value)
# The new metadata key should now have the new value
self.assertEqual(value, test_attribute.get_metadata(key))
new_metadata = test_attribute.get_all_metadata()
# The new key/value pair should now be part of the entire metadata listt
self.assertTrue(key in new_metadata)
self.assertEqual(value, new_metadata[key])
# Since a unique key was chosen there should be one extra metadata value
self.assertEqual(original_count + 1, test_attribute.get_metadata_count())
# Setting a value to None should remove the metadata from the node type.
# Do this last so that the test can run multiple times successfully.
test_attribute.set_metadata(key, None)
self.assertEqual(original_count, test_attribute.get_metadata_count())
# Test silent success of trying to set the metadata to illegal data
test_attribute.set_metadata(None, value)
# ObjectId types get special metadata hardcoded
for attribute_name in ["inputs:a_objectId", "outputs:a_objectId"]:
object_id_attribute = test_node.get_attribute(attribute_name)
self.assertIsNotNone(object_id_attribute, f"ObjectId {attribute_name} on simple data node type not found")
object_id_metadata = object_id_attribute.get_all_metadata()
self.assertTrue(ogn.MetadataKeys.OBJECT_ID in object_id_metadata)
# Check on the constant attribute
constant_attribute = test_node.get_attribute("inputs:a_constant_input")
self.assertEqual("1", constant_attribute.get_metadata(ogn.MetadataKeys.OUTPUT_ONLY))
|
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/data/README.txt | # Example files with Tutorial nodes
This directory contains USD files that make use of the tutorial nodes.
|
omniverse-code/kit/exts/omni.graph.tutorials/docs/CHANGELOG.md | # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [1.3.3] - 2022-08-31
### Fixed
- Refactored out use of a deprecated class
## [1.3.2] - 2022-08-30
### Fixed
- Doc error referencing a Python node in a C++ node docs
## [1.3.1] - 2022-08-09
### Fixed
- Applied formatting to all of the Python files
## [1.3.0] - 2022-07-07
### Changed
- Refactored imports from omni.graph.tools to get the new locations
### Added
- Test for public API consistency
## [1.2.0] - 2022-05-06
### Changed
- Updated the CPU to GPU test to show the actual pointer contents
## [1.1.3] - 2022-04-29
### Changed
- Made tests derive from OmniGraphTestCase
## [1.1.2] - 2022-03-07
### Changed
- Substituted old tutorial 1 node icons with new version
## [1.1.1] - 2022-03-01
### Fixed
- Made bundle tests use the Controller
## [1.0.0] - 2021-03-01
### Initial Version
- Started changelog with initial released version of the OmniGraph core
|
omniverse-code/kit/exts/omni.graph.tutorials/docs/README.md | # OmniGraph Tutorials [omni.graph.tutorials]
Sets of nodes that provide tutorials on the construction of OmniGraph nodes, with an emphasis on the use of
the OmniGraph node description files (*.ogn).
|
omniverse-code/kit/exts/omni.graph.tutorials/docs/index.rst | .. _ogn_tutorial_nodes:
OmniGraph Walkthrough Tutorials
###############################
.. tabularcolumns:: |L|R|
.. csv-table::
:width: 100%
**Extension**: omni.graph.tutorials,**Documentation Generated**: |today|
.. toctree::
:maxdepth: 1
CHANGELOG
In the source tree are several tutorials. Enclosed in these tutorial files are curated nodes that implement a
representative portion of the available features in an OmniGraph Node interface. By working through these tutorials
you can gradually build up a knowledge of the concepts used to effectively write OmniGraph Nodes.
.. note:: In the tutorial files irrelevant details such as the copyright notice are omitted for clarity
.. toctree::
:maxdepth: 1
:glob:
../tutorials/conversionTutorial/*
../tutorials/extensionTutorial/*
../tutorials/tutorial1/*
../tutorials/tutorial2/*
../tutorials/tutorial3/*
../tutorials/tutorial4/*
../tutorials/tutorial5/*
../tutorials/tutorial6/*
../tutorials/tutorial7/*
../tutorials/tutorial8/*
../tutorials/tutorial9/*
../tutorials/tutorial10/*
../tutorials/tutorial11/*
../tutorials/tutorial12/*
../tutorials/tutorial13/*
../tutorials/tutorial14/*
../tutorials/tutorial15/*
../tutorials/tutorial16/*
../tutorials/tutorial17/*
../tutorials/tutorial18/*
../tutorials/tutorial19/*
../tutorials/tutorial20/*
../tutorials/tutorial21/*
../tutorials/tutorial22/*
../tutorials/tutorial23/*
../tutorials/tutorial24/*
../tutorials/tutorial25/*
../tutorials/tutorial26/*
../tutorials/tutorial27/*
|
omniverse-code/kit/exts/omni.graph.tutorials/docs/Overview.md | (ogn_tutorial_nodes)=
# OmniGraph Walkthrough Tutorials
```{csv-table}
**Extension**: omni.graph.tutorials,**Documentation Generated**: {sub-ref}`today`
```
In the source tree are several tutorials. Enclosed in these tutorial files are curated nodes that implement a
representative portion of the available features in an OmniGraph Node interface. By working through these tutorials
you can gradually build up a knowledge of the concepts used to effectively write OmniGraph Nodes.
```{note}
In the tutorial files irrelevant details such as the copyright notice are omitted for clarity
```
- [Tutorial - OmniGraph Build Environment Conversion](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/conversionTutorial/build_conversion.html)
- [Tutorial - Building OmniGraph Outside Kit](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/conversionTutorial/building_outside_kit.html)
- [Tutorial - OmniGraph .ogn Conversion](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/conversionTutorial/node_conversion.html)
- [Example Setup - Creating An OGN-enabled Extension](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/extensionTutorial/extensionTutorial.html)
- [Tutorial 1 - Trivial Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial1/tutorial1.html)
- [Tutorial 2 - Simple Data Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial2/tutorial2.html)
- [Tutorial 3 - ABI Override Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial3/tutorial3.html)
- [Tutorial 4 - Tuple Data Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial4/tutorial4.html)
- [Tutorial 5 - Array Data Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial5/tutorial5.html)
- [Tutorial 6 - Array of Tuples](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial6/tutorial6.html)
- [Tutorial 7 - Role-Based Data Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial7/tutorial7.html)
- [Tutorial 8 - GPU Data Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial8/tutorial8.html)
- [Tutorial 9 - Runtime CPU/GPU Decision](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial9/tutorial9.html)
- [Tutorial 10 - Simple Data Node in Python](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial10/tutorial10.html)
- [Tutorial 11 - Complex Data Node in Python](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial11/tutorial11.html)
- [Tutorial 12 - Python ABI Override Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial12/tutorial12.html)
- [Tutorial 13 - Python State Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial13/tutorial13.html)
- [Tutorial 14 - Defaults](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial14/tutorial14.html)
- [Tutorial 15 - Bundle Manipulation](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial15/tutorial15.html)
- [Tutorial 16 - Bundle Data](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial16/tutorial16.html)
- [Tutorial 17 - Python State Attributes Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial17/tutorial17.html)
- [Tutorial 18 - Node With Internal State](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial18/tutorial18.html)
- [Tutorial 19 - Extended Attribute Types](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial19/tutorial19.html)
- [Tutorial 20 - Tokens](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial20/tutorial20.html)
- [Tutorial 21 - Adding Bundled Attributes](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial21/tutorial21.html)
- [Tutorial 22 - Bundles On The GPU](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial22/tutorial22.html)
- [Tutorial 23 - Extended Attributes On The GPU](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial23/tutorial23.html)
- [Tutorial 24 - Overridden Types](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial24/tutorial24.html)
- [Tutorial 25 - Dynamic Attributes](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial25/tutorial25.html)
- [Tutorial 26 - Generic Math Node](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial26/tutorial26.html)
- [Tutorial 27 - GPU Data Node with CPU Array Pointers](../../kit-sdk/latest/source/extensions/omni.graph.tutorials/tutorials/tutorial27/tutorial27.html)
|
omniverse-code/kit/exts/omni.graph.tutorials/data/README.txt | # Example files with Tutorial nodes
This directory contains USD files that make use of the tutorial nodes.
|
omniverse-code/kit/exts/omni.audiorecorder/PACKAGE-LICENSES/omni.audiorecorder-LICENSE.md | Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
NVIDIA CORPORATION and its licensors retain all intellectual property
and proprietary rights in and to this software, related documentation
and any modifications thereto. Any use, reproduction, disclosure or
distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited. |
omniverse-code/kit/exts/omni.audiorecorder/config/extension.toml | [package]
title = "Kit Audio Recorder"
category = "Audio"
feature = true
version = "0.1.0"
description = "An audio recorder API which is available from python and C++"
detailedDescription = """This is a simple interface that can be used to record
audio to file or send recorded audio to a callback for generic audio recording
tasks.
This recorder can achieve a relatively low latency (e.g. 20ms).
This API is available in python and C++.
See omni.kit.window.audiorecorder for an example use of this API.
"""
authors = ["NVIDIA"]
keywords = ["audio", "capture", "recording"]
[dependencies]
"carb.audio" = {}
"omni.usd.libs" = {}
"omni.usd.schema.semantics" = {}
"omni.usd.schema.audio" = {}
"omni.kit.audiodeviceenum" = {}
[[native.plugin]]
path = "bin/*.plugin"
[[python.module]]
name = "omni.audiorecorder"
[[test]]
args = [
"--/audio/deviceBackend=null"
]
dependencies = [
"omni.usd",
"omni.kit.test_helpers_gfx",
]
stdoutFailPatterns.exclude = [
"*failed to create an encoder state*",
"*failed to initialize the output stream*",
"*recording is already in progress*",
"*no supported conversion path from ePcmFloat (4) to eRaw (10)*",
]
# uncomment and re-open OM-50069 if it breaks again
#pythonTests.unreliable = [
# "*test_callback_recording", # OM-50069
#]
|
omniverse-code/kit/exts/omni.audiorecorder/omni/audiorecorder/__init__.py | """
This module contains bindings to the C++ omni::audio::IAudioRecorder interface.
This provides functionality for simple audio recording to file or using a callback.
Recording can be done in 16 bit, 32 bit or float PCM if a callback is required.
Recording can be done in any format when only recording to a file.
Recording to a file while simultaneously receiving data callbacks is also possible.
"""
# recorder bindings depend on some types from carb.audio
import carb.audio
from ._audiorecorder import *
|
omniverse-code/kit/exts/omni.audiorecorder/omni/audiorecorder/tests/__init__.py | from .test_audio_recorder import * # pragma: no cover
|
omniverse-code/kit/exts/omni.audiorecorder/omni/audiorecorder/tests/test_audio_recorder.py | import pathlib
import time
import os
import math
from PIL import Image
import omni.kit.test_helpers_gfx.compare_utils
import carb.tokens
import carb.audio
import omni.audiorecorder
import omni.usd.audio
import omni.kit.audiodeviceenum
import omni.kit.test
import omni.log
OUTPUTS_DIR = pathlib.Path(omni.kit.test.get_test_output_path())
# boilerplate to work around python lacking references
class IntReference: # pragma: no cover
def __init__(self, v):
self._v = v;
def _get_value(self):
return self._v
def _set_value(self, v):
self._v = v
value = property(_get_value, _set_value)
def wait_for_data(received: IntReference, ms: int, expected_data: int): # pragma: no cover
for i in range(ms):
if received.value > expected_data:
# log this so we can see timing margins on teamcity
omni.log.warn("finished waiting after " + str(i / 1000.0) + " seconds")
break
if i > 0 and i % 1000 == 0:
omni.log.warn("waited " + str(i // 1000) + " seconds")
if i == ms - 1:
self.assertTrue(not "timeout of " + str(ms) + "ms waiting for " + str(expected_data) + " frames")
time.sleep(0.001)
class TestAudioRecorder(omni.kit.test.AsyncTestCase): # pragma: no cover
def setUp(self):
self._recorder = omni.audiorecorder.create_audio_recorder()
self.assertIsNotNone(self._recorder)
extension_path = carb.tokens.get_tokens_interface().resolve("${omni.audiorecorder}")
self._test_path = pathlib.Path(extension_path).joinpath("data").joinpath("tests").absolute()
self._golden_path = self._test_path.joinpath("golden")
def tearDown(self):
self._recorder = None
def test_callback_recording(self):
valid = []
for i in range(1, 16):
valid.append(4800 * i)
received = IntReference(0)
def read_validation(data):
nonlocal received
received.value += len(data)
self.assertTrue(len(data) in valid)
def float_read_callback(data):
read_validation(data)
self.assertTrue(isinstance(data[0], float))
def int_read_callback(data):
read_validation(data)
self.assertTrue(isinstance(data[0], int))
# if there are no devices, this won't work
if omni.kit.audiodeviceenum.acquire_audio_device_enum_interface().get_device_count(omni.kit.audiodeviceenum.Direction.CAPTURE) == 0:
self.assertFalse(self._recorder.begin_recording_float(
callback = float_read_callback,
))
return
# not open => should be some valid default format
fmt = self._recorder.get_format()
self.assertIsNotNone(fmt)
self.assertGreaterEqual(fmt.channels, carb.audio.MIN_CHANNELS)
self.assertLessEqual(fmt.channels, carb.audio.MAX_CHANNELS)
self.assertGreaterEqual(fmt.frame_rate, carb.audio.MIN_FRAMERATE)
self.assertLessEqual(fmt.frame_rate, carb.audio.MAX_FRAMERATE)
self.assertTrue(self._recorder.begin_recording_float(
callback = float_read_callback,
buffer_length = 4800 * 16, # enormous buffer for test reliability
period = 4800,
length_type = carb.audio.UnitType.FRAMES,
channels = 1
))
# try again and it will fail because a recording is already in progress
self.assertFalse(self._recorder.begin_recording_float(
callback = float_read_callback,
buffer_length = 4800 * 16, # enormous buffer for test reliability
period = 4800,
length_type = carb.audio.UnitType.FRAMES,
channels = 1
))
# not much we can test here aside from it being valid
fmt = self._recorder.get_format()
self.assertIsNotNone(fmt)
self.assertEqual(fmt.channels, 1)
self.assertGreaterEqual(fmt.frame_rate, carb.audio.MIN_FRAMERATE)
self.assertLessEqual(fmt.frame_rate, carb.audio.MAX_FRAMERATE)
self.assertEqual(fmt.format, carb.audio.SampleFormat.PCM_FLOAT)
# this timeout seems absurd, but anything's possible with teamcity's timing
wait_for_data(received, 8000, 4800)
self._recorder.stop_recording()
# try again with int16
received.value = 0
self.assertTrue(self._recorder.begin_recording_int16(
callback = int_read_callback,
buffer_length = 4800 * 16, # enormous buffer for test reliability
period = 4800,
length_type = carb.audio.UnitType.FRAMES,
channels = 1
))
# not much we can test here aside from it being valid
fmt = self._recorder.get_format()
self.assertIsNotNone(fmt)
self.assertEqual(fmt.channels, 1)
self.assertGreaterEqual(fmt.frame_rate, carb.audio.MIN_FRAMERATE)
self.assertLessEqual(fmt.frame_rate, carb.audio.MAX_FRAMERATE)
self.assertEqual(fmt.format, carb.audio.SampleFormat.PCM16)
wait_for_data(received, 8000, 4800)
self._recorder.stop_recording()
# try again with int32
received.value = 0
self.assertTrue(self._recorder.begin_recording_int32(
callback = int_read_callback,
buffer_length = 4800 * 16, # enormous buffer for test reliability
period = 4800,
length_type = carb.audio.UnitType.FRAMES,
channels = 1
))
# not much we can test here aside from it being valid
fmt = self._recorder.get_format()
self.assertIsNotNone(fmt)
self.assertEqual(fmt.channels, 1)
self.assertGreaterEqual(fmt.frame_rate, carb.audio.MIN_FRAMERATE)
self.assertLessEqual(fmt.frame_rate, carb.audio.MAX_FRAMERATE)
self.assertEqual(fmt.format, carb.audio.SampleFormat.PCM32)
wait_for_data(received, 8000, 4800)
self._recorder.stop_recording()
# test that the format is set as specified
self.assertTrue(self._recorder.begin_recording_float(
callback = float_read_callback,
channels = 1, # 1 channel because that's all we can guarantee
# when we upgrade IAudioCapture, this should no longer
# be an issue
frame_rate = 43217,
buffer_length = 4800 * 16, # enormous buffer for test reliability
period = 4800,
length_type = carb.audio.UnitType.FRAMES
))
fmt = self._recorder.get_format()
self.assertEqual(fmt.channels, 1)
self.assertEqual(fmt.frame_rate, 43217)
self.assertEqual(fmt.format, carb.audio.SampleFormat.PCM_FLOAT)
self._recorder.stop_recording()
def _validate_sound(self, path):
# to validate that this is a working sound, load it into a sound prim
# and check if the sound asset loaded successfully
context = omni.usd.get_context()
self.assertIsNotNone(context)
context.new_stage()
stage = context.get_stage()
self.assertIsNotNone(stage)
prim = stage.DefinePrim("/sound", "OmniSound")
self.assertIsNotNone(prim)
prim.GetAttribute("filePath").Set(path)
audio = omni.usd.audio.get_stage_audio_interface()
self.assertIsNotNone(audio)
i = 0
while audio.get_sound_asset_status(prim) == omni.usd.audio.AssetLoadStatus.IN_PROGRESS:
time.sleep(0.001)
if i > 5000:
raise Exception("asset load timed out")
i += 1
self.assertEqual(audio.get_sound_asset_status(prim), omni.usd.audio.AssetLoadStatus.DONE)
def test_recording_to_file(self):
received = IntReference(0)
def read_callback(data):
nonlocal received
received.value += len(data)
if omni.kit.audiodeviceenum.acquire_audio_device_enum_interface().get_device_count(omni.kit.audiodeviceenum.Direction.CAPTURE) == 0:
self.assertFalse(self._recorder.begin_recording_float(
callback = read_callback,
filename = str(OUTPUTS_DIR.joinpath("test.oga"))
))
self.assertFalse(self._recorder.begin_recording_to_file(
filename = str(OUTPUTS_DIR.joinpath("test.oga"))
))
return
self.assertTrue(self._recorder.begin_recording_float(
callback = read_callback,
buffer_length = 4800 * 16, # enormous buffer for test reliability
period = 4800,
channels = 1,
frame_rate = 48000,
length_type = carb.audio.UnitType.FRAMES,
output_format = carb.audio.SampleFormat.OPUS,
filename = str(OUTPUTS_DIR.joinpath("test.opus.oga"))
))
wait_for_data(received, 8000, 4800)
self._recorder.stop_recording()
self._validate_sound(str(OUTPUTS_DIR.joinpath("test.opus.oga")))
# try again with a default output format
self.assertTrue(self._recorder.begin_recording_float(
callback = read_callback,
buffer_length = 4800 * 16, # enormous buffer for test reliability
period = 4800,
channels = 1,
frame_rate = 48000,
length_type = carb.audio.UnitType.FRAMES,
filename = str(OUTPUTS_DIR.joinpath("test.default.0.wav"))
))
wait_for_data(received, 8000, 4800)
self._recorder.stop_recording()
self._validate_sound(str(OUTPUTS_DIR.joinpath("test.default.0.wav")))
self.assertTrue(self._recorder.begin_recording_to_file(
frame_rate = 73172,
channels = 1,
filename = str(OUTPUTS_DIR.joinpath("test.vorbis.oga")),
output_format = carb.audio.SampleFormat.VORBIS
))
time.sleep(2.0)
self._recorder.stop_recording()
self._validate_sound(str(OUTPUTS_DIR.joinpath("test.vorbis.oga")))
# try again with a default output format
self.assertTrue(self._recorder.begin_recording_to_file(
frame_rate = 73172,
channels = 1,
filename = str(OUTPUTS_DIR.joinpath("test.default.1.wav")),
))
time.sleep(2.0)
self._recorder.stop_recording()
self._validate_sound(str(OUTPUTS_DIR.joinpath("test.default.1.wav")))
def test_bad_parameters(self):
def read_callback(data):
pass
# MP3 is not supported
self.assertFalse(self._recorder.begin_recording_float(
callback = read_callback,
output_format = carb.audio.SampleFormat.MP3,
filename = str(OUTPUTS_DIR.joinpath("test.mp3"))
))
# bad format
self.assertFalse(self._recorder.begin_recording_float(
callback = read_callback,
output_format = carb.audio.SampleFormat.RAW,
filename = str(OUTPUTS_DIR.joinpath("test.mp3"))
))
# bad file name
self.assertFalse(self._recorder.begin_recording_float(
callback = read_callback,
output_format = carb.audio.SampleFormat.OPUS,
filename = "a/b/c/d/e/f/g/h/i/j.oga"
))
self.assertFalse(self._recorder.begin_recording_float(
callback = read_callback,
channels = carb.audio.MAX_CHANNELS + 1
))
self.assertFalse(self._recorder.begin_recording_float(
callback = read_callback,
frame_rate = carb.audio.MAX_FRAMERATE + 1
))
def test_draw_waveform(self):
# toggle in case you want to regenerate waveforms
GENERATE_GOLDEN_IMAGES = False
samples_int16 = []
samples_int32 = []
samples_float = []
for i in range(4800):
samples_float.append(math.sin(i / 48.0))
samples_int16.append(int(samples_float[-1] * (2 ** 15 - 1)))
samples_int32.append(int(samples_float[-1] * (2 ** 31 - 1)))
W = 256
H = 256
raw = omni.audiorecorder.draw_waveform_from_blob_float(samples_float, 1, W, H, [1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 0.0, 1.0])
self.assertEqual(len(raw), W * H * 4)
with Image.frombytes("RGBX", (W, H), bytes(raw), 'raw') as img:
img.convert("RGB").save(str(pathlib.Path(OUTPUTS_DIR).joinpath("waveform.float.png")))
if not GENERATE_GOLDEN_IMAGES:
self.assertLess(omni.kit.test_helpers_gfx.compare_utils.compare(
pathlib.Path(OUTPUTS_DIR).joinpath("waveform.float.png"),
self._golden_path.joinpath("waveform.png"),
pathlib.Path(OUTPUTS_DIR).joinpath("waveform.float.png.diff.png")),
0.1)
raw = omni.audiorecorder.draw_waveform_from_blob_int32(samples_int32, 1, W, H, [1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 0.0, 1.0])
self.assertEqual(len(raw), W * H * 4)
with Image.frombytes("RGBX", (W, H), bytes(raw), 'raw') as img:
img.convert("RGB").save(str(pathlib.Path(OUTPUTS_DIR).joinpath("waveform.int32.png")))
if not GENERATE_GOLDEN_IMAGES:
self.assertLess(omni.kit.test_helpers_gfx.compare_utils.compare(
pathlib.Path(OUTPUTS_DIR).joinpath("waveform.int32.png"),
self._golden_path.joinpath("waveform.png"),
pathlib.Path(OUTPUTS_DIR).joinpath("waveform.int32.png.diff.png")),
0.1)
raw = omni.audiorecorder.draw_waveform_from_blob_int16(samples_int16, 1, W, H, [1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 0.0, 1.0])
self.assertEqual(len(raw), W * H * 4)
with Image.frombytes("RGBX", (W, H), bytes(raw), 'raw') as img:
img.convert("RGB").save(str(pathlib.Path(OUTPUTS_DIR).joinpath("waveform.int16.png")))
if not GENERATE_GOLDEN_IMAGES:
# 1 pixel of difference was 756.0 difference
self.assertLess(omni.kit.test_helpers_gfx.compare_utils.compare(
pathlib.Path(OUTPUTS_DIR).joinpath("waveform.int16.png"),
self._golden_path.joinpath("waveform.png"),
pathlib.Path(OUTPUTS_DIR).joinpath("waveform.int16.png.diff.png")),
1024.0)
|
omniverse-code/kit/exts/omni.graph.tools/PACKAGE-LICENSES/omni.graph.tools-LICENSE.md | Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
NVIDIA CORPORATION and its licensors retain all intellectual property
and proprietary rights in and to this software, related documentation
and any modifications thereto. Any use, reproduction, disclosure or
distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited. |
omniverse-code/kit/exts/omni.graph.tools/config/extension.toml | [package]
title = "OmniGraph Tools"
# Note that for this extension the semantic versioning is interpreted slightly differently as it has to be concerned
# with the public Python API, the content of the generated code, and the .ogn format. Ordinarily the versioning of the
# generated code would be handled by a dependency on a particular version of omni.graph/omni.graph.core, however as
# this extension cannot see them the dependency has to be managed manually.
#
# MAJOR VERSION: Changes are made to the generated code, OGN format, or the public API that are not backward compatible.
# i.e. the user has to change some of their code to make it work with the new version
#
# MINOR VERSION: 1. A change is made to the Python API that is backward compatible with no user changes
# 2. A change is made to the .ogn format that is backward compatible with no user changes
# 3. A change is made that would require regeneration of the Python node database at runtime in order
# to ensure backward compatibility, but with no user changes required to the .ogn or node files.
# e.g. extra runtime information is added to the database
#
# PATCH VERSION: 1. A change is made to the implementation of the Python API that does not change functionality
# 2. A change is made to the .ogn parsing that does not change the generated code
#
version = "1.17.2"
category = "Graph"
readme = "docs/README.md"
changelog = "docs/CHANGELOG.md"
description = "Contains the implementation of the Omniverse Graph node generator scripts."
repository = ""
keywords = ["kit", "omnigraph", "tools"]
authors = ["NVIDIA"]
# The tools are used for the build and so have no dependencies
[dependencies]
"omni.usd.libs" = {}
"omni.kit.pip_archive" = {}
# For AutoNode - to be removed after the deprecation support is removed from omni.graph.tools/python/_impl/v1_2_0/autograph
[python.pipapi]
requirements = [
"numpy", # SWIPAT filed under: http://nvbugs/3193231
"toml", # SWIPAT filed under: http://nvbugs/3060676
]
# Main python module this extension provides, it will be publicly available as "import omni.graph.tools".
[[python.module]]
name = "omni.graph.tools"
[documentation]
deps = [
["kit-sdk", "_build/docs/kit-sdk/latest"], # WAR to include omni.graph.tutorial/etc refs until that workflow is moved
]
pages = [
"docs/Overview.md",
"docs/node_architects_guide.rst",
"docs/ogn_user_guide.rst",
"docs/ogn_reference_guide.rst",
"docs/attribute_types.rst",
"docs/ogn_code_samples_cpp.rst",
"docs/ogn_code_samples_python.rst",
"docs/ogn_generation_script.rst",
"docs/CHANGELOG.md",
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.