I have created a Python plugin using vtkmodules.util.vtkAlgorithm.VTKPythonAlgorithmBase
. This plugin works great in the GUI, but I am trying to use paraview.simple.LoadState()
in a script so that I can parse my .pvsm state file into a .py state file. This operation fails, because one of the components of my plugin calls vtk.vtkMultiProcessController.GetGlobalController().GetCommunicator()
. In the GUI, it returns a datatype vtkMPICommunicator
for this call. But through LoadState()
, it appears to return a datatype vtkDummyCommunicator
and fails.
The relevant parts of the plugin that I am trying to use:
29 import vtk
30 _GC = vtk.vtkMultiProcessController.GetGlobalController()
31 _RANK = _GC.GetLocalProcessId()
32 _COMM = vtk.vtkMPI4PyCommunicator.ConvertToPython(_GC.GetCommunicator())
33 print(type(_GC.GetCommunicator()))
Using the print statement on Line 33, I can tell that when it loads in the Paraview GUI, the datatype is vtkMPICommunicator
.
Next I use that plugin filter in Paraview and save a .pvsm state file. After the .pvsm is saved, in my workflow I use another script to convert that .pvsm state file to .py. That script is reproduced below:
4 import sys
5 from paraview import simple as pvs
6 from paraview import smstate
7
8 pvsm_file = sys.argv[1]
9
10 # Load pvsm state file
11 pvs.LoadState(pvsm_file)
When I run that script, it crashes with the error trace in Python being:
2 Failed to call `paraview.detail.pythonalgorithm.load_plugin`.^[[0m
3 Traceback (most recent call last):
4 File "/opt/Software/paraview/5.9.0_server/lib64/python3.7/site-packages/paraview/detail/pythonalgorithm.py", line 509, in load_plugin
5 spec.loader.exec_module(module)
6 File "<frozen importlib._bootstrap_external>", line 728, in exec_module
7 File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
8 File "path_to_plugin/plugin.py", line 30, in <module>
9 _COMM = vtk.vtkMPI4PyCommunicator.ConvertToPython(_GC.GetCommunicator())
10 TypeError: ConvertToPython argument 1: method requires a vtkMPICommunicator, a vtkDummyCommunicator was provided.
From that error trace, I am led to believe that something in LoadState()
is forcing _GC.GetCommunicator()
to output as datatype vtkDummyCommunicator
instead of vtkMPICommunicator
, which is what it does in the Paraview GUI.
Is there a solution to this? Is it a problem with paraview.simple
, or is it a problem with my implementation?