Skip to content
Snippets Groups Projects

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Warnings:

    • please consider adding a changelog entry in a file ending with .md in Documentation/release/dev.

    The warnings do not need to be fixed, but it is recommended to do so.

  • Sebastien Jourdain mentioned in merge request !10876 (closed)

    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 it module_mapper) that maps vtkCommonDataModel to vtkmodules.util.data_model, vtkCommonExecutionModel to vtkmodules.util.execution_model, etc.

    Whenever any vtk module is loaded, the wrapper code can check sys.modules to see if vtkmodules is there, and if so, it can use the vtkmodules.module_mapper to see if there is a util module to load. The logic for this can go in vtkPythonUtil.cxx instead of generated by vtkWrapPythonInit.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 in vtkmodules/__init__.py.

    Edited by Sebastien Jourdain
  • It 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 a module_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 read vtkmodules/__init__.py and they will see exactly what the mechanisms are.

  • By the way, every module calls vtkPythonUtil::AddModule(name) at the end of its init function. So vtkPythonUtil::AddModule() is the best function to modify.

  • Thanks for all those pointers...

  • 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) in vtkPythonUtil::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 Jourdain
  • added 2 commits

    • 530432ee - Python: make data_model works without numpy
    • c43859ff - load registered python dependency on vtk module load

    Compare with previous version

  • 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 line Do: reformat to rewrite the MR source branch automatically.

    Warnings:

    • please consider adding a changelog entry in a file ending with .md in Documentation/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.

  • @berkgeveci with the change I made I'm wondering if I should/could remove your import logic of vtkmodules.util.execution_model in Wrapping/Tools/vtkWrapPythonNumberProtocol.c or Wrapping/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)

  • Sebastien Jourdain resolved all threads

    resolved all threads

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}")
  • added 1 commit

    • 843184ea - remove vtkmodules loading debug prints

    Compare with previous version

  • 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 line Do: reformat to rewrite the MR source branch automatically.

    Warnings:

    • please consider adding a changelog entry in a file ending with .md in Documentation/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.

  • 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 line Do: reformat to rewrite the MR source branch automatically.

    Warnings:

    • please consider adding a changelog entry in a file ending with .md in Documentation/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.

  • Do: reformat

  • This topic has been reformatted and pushed; please fetch from the source repository and reset your local branch to continue with further development on the reformatted commits.

  • added 2 commits

    • a493987c - load registered python dependency on vtk module load
    • ac429268 - remove vtkmodules loading debug prints

    Compare with previous version

  • Warnings:

    • please consider adding a changelog entry in a file ending with .md in Documentation/release/dev.

    The warnings do not need to be fixed, but it is recommended to do so.

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading