Sanity test if we didn't miss the _schema_name for any op with custom wrapper
(module_name, base_name="")
| 196 | |
| 197 | |
| 198 | def _test_schema_name_for_module(module_name, base_name=""): |
| 199 | """Sanity test if we didn't miss the _schema_name for any op with custom wrapper""" |
| 200 | if module_name.endswith("hidden"): |
| 201 | return |
| 202 | if base_name == "": |
| 203 | base_name = module_name |
| 204 | dali_module = sys.modules[module_name] |
| 205 | for member_name in dir(dali_module): |
| 206 | if member_name.startswith("_"): |
| 207 | continue |
| 208 | member = getattr(dali_module, member_name) |
| 209 | if inspect.isfunction(member): |
| 210 | # Check if we can reconstruct the name of the op from provided schema |
| 211 | assert hasattr(member, "_schema_name") |
| 212 | full_name = ops._op_name(member._schema_name) |
| 213 | assert base_name + "." + full_name == module_name + "." + member_name |
| 214 | elif inspect.ismodule(member) and (module_name + "." + member_name) in sys.modules.keys(): |
| 215 | # Recurse on DALI submodule (filter out non-DALI reexported modules like `sys`) |
| 216 | _test_schema_name_for_module(module_name + "." + member_name, base_name) |
| 217 | |
| 218 | |
| 219 | def test_schema_name(): |
no test coverage detected