VTKHDF file unloading on Paraview 5.13 & 6.0

I am writing my own VTKHDF files. After a file is read into Paraview and later the display model is deleted from the display, I cannot write to the same VTKHDF file unit again until Paraview is completely shutdown. So, the running instance of Paraview is “holding on the HDF5 file pointer” or some similar operation.

The write error is:

HDF5-DIAG: Error detected in HDF5 (1.14.1-2) thread 0:
  #000: /.../src/H5F.c line 660 in H5Fcreate(): unable to synchronously create file
    major: File accessibility
    minor: Unable to create file
... SNIP ...

If I delete the file after unloading it from Paraview, I am able to again write the without any HDF5 issues.

Hello @Greg_Burgreen,

Indeed, that’s because the reader doesn’t close the vtkhdf file after we read it so the writer can’t override the file.

Could you please open an issue on VTK as it’s probably an issue in the vtkHDFReader : https://gitlab.kitware.com/vtk/vtk/-/issues ?

Thanks!

I think this is already fixed in ParaView 6.0: https://gitlab.kitware.com/vtk/vtk/-/issues/19764

@mwestphal I can confirm this is not fixed in ParaView 6.0.0 on Windows. I still need to completely shut Paraview to overwrite a file, even if it has been removed from the pipeline browser. Using python and h5py to write the files.

  File "...\writer\vtkhdf.py", line 212, in write_vtkhdf_file
    with h5py.File(self.path, 'w') as f:
         ~~~~~~~~~^^^^^^^^^^^^^^^^
  File "...\.venv\Lib\site-packages\h5py\_hl\files.py", line 564, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
  File "...\.venv\Lib\site-packages\h5py\_hl\files.py", line 244, in make_fid
    fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
  File "h5py\\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\\h5f.pyx", line 122, in h5py.h5f.create
OSError: [Errno 0] Unable to synchronously create file (unable to lock file, errno = 0, error message = 'No error', Win32 GetLastError() = 33)

Note: file paths truncated here

What do you mean ? Please provide steps to reproduce.

Sorry for being unclear. If I write simualtion data out to a vtkhdf file (using python and h5py) and load it into paraview, i can view the results and data. Then I close the mesh in the pipeline viewer becuase I want to edit the data in the vtkhdf file or just overwrite it with a newer version with updated results.

However it is not possible as ParaView keeps a lock on the file until it is closed - you need to shit paraview completely, even if you have other data you are still working on, to overwrite the vtkhdf file.

If you close paraview, then you can edit or overwrite the vtkhdf file.

This is strange because I’m able to fo the following without issue:

  • run ParaView, create UnstructuredCellTypes, Apply
  • File → SaveData → file.vtkhdf
  • File → OpenData → file.vtkhdf
  • File → SaveData → file.vtkhdf

So I would expect your python script to behave the same.

But I guess the difference is that you are doing all of that within ParaView? Once I close the file in the pipline browser I am opening, editing or overwriting in another external software.

My workflow is slightly different:

  • Simulation solver writes .vtkhdf file
  • Open in ParaView and visulaise .vtkhdf file
  • Close in Paraview pipeline browser when done
  • Open python kernel in vscode and attempt to edit/overwrite .vtkhdf file
    – this is when the error is thrown by vscode or pycharm

Although the file is closed in ParaView, it seem to have kept a lock on the file and prevents the write. As the original post says, if you want to write to the file you first need to delete the file if you leave ParaView open or else close ParaView.

This should prevent the write from ParaView as well, but I defer to @Louis_Gombert and @Lucas_Givord

The earlier post by @Lucas_Givord seems to suggest this may be the case and it does seem to be reproducible across different libraries.

I didn’t see an issue open - should i add one?

does your simulation solver close the file properly? I have only tested on Linux but could not seem to reproduce the issue with the steps here: https://gitlab.kitware.com/vtk/vtk/-/issues/19764#note_1694694

Yes, it’s closed by the python context manager in all cases. I’m on windows but I’ll check on my linux workstation next week.