Relative file not found when loading PVSM file
I've encountered some issues with loading PVSM files saved from a pvpython
script.
I get the following errors when I try to 'Load State' in the ParaView interface (file names have been changed):
ERROR: In /Users/rossgardiner/Downloads/paraview/VTK/IO/XML/vtkXMLReader.cxx, line 262
vtkXMLImageDataReader (0x7f81ad103de0): Error opening file my_file.vti
ERROR: In /Users/rossgardiner/Downloads/paraview/VTK/IO/XML/vtkXMLReader.cxx, line 262
vtkXMLImageDataReader (0x7f81ad103de0): Error opening file my_file.vti
ERROR: In /Users/rossgardiner/Downloads/paraview/VTK/Common/ExecutionModel/vtkExecutive.cxx, line 784
vtkPVCompositeDataPipeline (0x7f81ad1060d0): Algorithm vtkXMLImageDataReader(0x7f81ad103de0) returned failure for request: vtkInformation (0x7f81ad0ad840)
Debug: Off
Modified Time: 227533
Reference Count: 1
Registered Events: (none)
Request: REQUEST_INFORMATION
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
ERROR: In /Users/rossgardiner/Downloads/paraview/VTK/IO/XML/vtkXMLReader.cxx, line 262
vtkXMLImageDataReader (0x7f81ad103de0): Error opening file my_file.vti
ERROR: In /Users/rossgardiner/Downloads/paraview/VTK/Common/ExecutionModel/vtkExecutive.cxx, line 784
vtkPVCompositeDataPipeline (0x7f81ad10a420): Algorithm vtkFileSeriesReader(0x7f81ad1083f0) returned failure for request: vtkInformation (0x7f81ad72cec0)
Debug: Off
Modified Time: 925100
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
FROM_OUTPUT_PORT: 0
ERROR: In /Users/rossgardiner/Downloads/paraview/VTK/Common/ExecutionModel/vtkExecutive.cxx, line 784
vtkCompositeDataPipeline (0x7f81ad1731b0): Algorithm vtkPVGeometryFilter(0x7f81ad15f370) returned failure for request: vtkInformation (0x7f81ad887e90)
Debug: Off
Modified Time: 925145
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA_OBJECT
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
FROM_OUTPUT_PORT: 0
This was with the 'Use File Names From State' option selected, but I get errors even if I choose 'Search files under specified directory' and specify the directory containing the file. As far as I can tell, the PVSM file contains only the name of the file, and not any relative or absolute path.
I cloned the latest ParaView commit (47b3ba94 at the time) and debugged the error.
In 'Use File Names From State' mode, I ended up looking at vtkXMLReader::OpenVTKFile()
, which is attempting to stat(1)
the filename. this->FileName
is set to just the filename 'my_file.vti' at this point (there is no enclosing path). I guess failure to find the file might be expected behaviour in this mode (but the code should probably make an effort to look in the directory that the PVSM came from).
In 'Search files under specified directory' mode, I noticed that the failure to find the file is stemming from vtkLoadStateOptions::LocateFileInDirectory
.
This method gets called with filepath == "my_file.vti"
and this->DataDirectory == "/Users/rossgardiner/Documents/<projectname>/cmake-build-debug"
(where my_file.vti
exists).
The call to SystemTools::GetParentDirectory
on line 74 then returns ""
, because the filename has no enclosing path. Splitting it into the pathComponents
variable results in a vector, length 1, containing an empty string. The loop on line 77 then skips because pathComponents.size() > 1
is false. As a result, the error is logged and result
is returned as an empty string.
I tried changing the while
condition to while (pathComponents.size() >= 1)
and this seems to work properly. I thought it would be best for someone with a bit more understanding of the ParaView codebase to check whether this is actually expected behaviour and suggest a fix.