Added automatic include of the new data_model module.
The new data_model module adds better support for interfacing with numpy. This change automatically includes that module from vtkCommonDataModel in order to enable its @overrides that augment VTK data objects' API.
Merge request reports
Activity
assigned to @sebastien.jourdain
mentioned in merge request !10876 (closed)
From David Gobbi
Why not make this generic, instead of hard-coding it?
For example,
vtkmodules
could have a dict (we could call itmodule_mapper
) that mapsvtkCommonDataModel
tovtkmodules.util.data_model
,vtkCommonExecutionModel
tovtkmodules.util.execution_model
, etc.Whenever any vtk module is loaded, the wrapper code can check
sys.modules
to see ifvtkmodules
is there, and if so, it can use thevtkmodules.module_mapper
to see if there is a util module to load. The logic for this can go invtkPythonUtil.cxx
instead of generated byvtkWrapPythonInit.c
, which would make it much cleaner.In this way, all people would have to do in the future is edit the
module_mapper
dict invtkmodules/__init__.py
.Edited by Sebastien JourdainIt could also be super-generic if we have a function
vtkmodules.OnVTKModuleLoad()
that every VTK module calls when it is loaded. We would still have amodule_mapper
dict, but then all the code for loading the util modules can be written in Python. And if anyone needs to understand what is happening, they can readvtkmodules/__init__.py
and they will see exactly what the mechanisms are.I have to get ready for my trame course, but in the meantime if you have the C++ code to call
vtkmodules.on_vtk_module_loaded(name)
invtkPythonUtil::AddModule
that will speed things up on my end (getting rusty in C++).I mean, just a code snippet in comment will be plenty, otherwise I'll figure it out later.
Edited by Sebastien JourdainErrors:
- commit c43859ff is not allowed because the following files are not formatted according to the 'clang-format' check:
Wrapping/Tools/vtkWrapPythonInit.c
. Post a comment ending in the lineDo: reformat
to rewrite the MR source branch automatically.
Warnings:
- please consider adding a changelog entry in a file ending with
.md
inDocumentation/release/dev
.
The warnings do not need to be fixed, but it is recommended to do so.
Please rewrite commits to fix the errors listed above (adding fixup commits will not resolve the errors) and force-push the branch again to update the merge request.
- commit c43859ff is not allowed because the following files are not formatted according to the 'clang-format' check:
@berkgeveci with the change I made I'm wondering if I should/could remove your import logic of
vtkmodules.util.execution_model
inWrapping/Tools/vtkWrapPythonNumberProtocol.c
orWrapping/Tools/vtkWrapPythonMethodDef.c
.The current code in
vtkmodules.utils.data_model
do "work" without numpy but is rudimentary. Maybe it is enough for now and we can revisit it if there is truly a need to support Composite without numpy.Let me know what you think (@berkgeveci + @dgobbi)
77 } 78 LOADED_MODULES = set() 79 IMPORTED_MODULES = set() 80 81 def register_vtk_module_dependencies(vtk_module_name, *import_names): 82 """Method to call for registering external override on vtkmodule load""" 83 global module_mapper 84 if vtk_module_name not in module_mapper: 85 module_mapper[vtk_module_name] = [] 86 87 for import_name in import_names: 88 module_mapper[vtk_module_name].append(import_name) 89 90 # If already loaded let's make sure we import it now 91 if vtk_module_name in LOADED_MODULES and import_name not in IMPORTED_MODULES: 92 print(f" + {import_name}") changed this line in version 3 of the diff
Errors:
- commit c43859ff is not allowed because the following files are not formatted according to the 'clang-format' check:
Wrapping/Tools/vtkWrapPythonInit.c
. Post a comment ending in the lineDo: reformat
to rewrite the MR source branch automatically.
Warnings:
- please consider adding a changelog entry in a file ending with
.md
inDocumentation/release/dev
.
The warnings do not need to be fixed, but it is recommended to do so.
Please rewrite commits to fix the errors listed above (adding fixup commits will not resolve the errors) and force-push the branch again to update the merge request.
- commit c43859ff is not allowed because the following files are not formatted according to the 'clang-format' check:
Errors:
- commit c43859ff is not allowed because the following files are not formatted according to the 'clang-format' check:
Wrapping/Tools/vtkWrapPythonInit.c
. Post a comment ending in the lineDo: reformat
to rewrite the MR source branch automatically.
Warnings:
- please consider adding a changelog entry in a file ending with
.md
inDocumentation/release/dev
.
The warnings do not need to be fixed, but it is recommended to do so.
Please rewrite commits to fix the errors listed above (adding fixup commits will not resolve the errors) and force-push the branch again to update the merge request.
- commit c43859ff is not allowed because the following files are not formatted according to the 'clang-format' check: