New Options when Loading ParaView State Files

When a ParaView state file is saved, it saves the absolute paths to the data files that ParaView has loaded. This has made sharing state files annoying since the person loading the state file has to tell ParaView where to look for each data file. Since sharing state files is something many people want to do, one of the most requested features for ParaView is to be able to load data from a path relative to the state file rather than an absolute path. We have added some new features to loading state files that will make sharing state files much easier.

When you load a state file, ParaView will now give broader options of where to look for the files as shown in this screenshot:

Load State Options dialog with data location dropdown

The new ‘Load State Options’ dialog in ParaView showing the locations to search for data files dropdown options.

Use File Names From State just uses the file locations specified in the state file and errors if they are not found.  This is useful if you are using a state file written out on the same computer.

Search files under specified directory looks for the data files in a specified directory.  ParaView will parse out the filename of each file and look in the given directory to see if that filename exists.  If the file exists it will be used, otherwise it will try the path in the state file.  Since a common use case is sharing state files along with their data, the default directory used by this option is the location of the state file.  Here is what the dialog looks like when using this option:

Load State Options with search under directory option

The Load State Options dialog with the Search files under specified directory option selected

The Choose File Names option is the old default: manually specifying where each data file is located.  This is still useful for running a pipeline on a different dataset than the one it was built with although we expect the other two to be more commonly used.  This option has been improved with the ability to specify environment variables as a part of the filename as shown here:

Load data relative to environment variables

The ParaView Load State Options dialog showing finding data with environment variables in the path

Unlike the old load state file mechanism these options can also be specified from the Python API.  Use the python trace to find the options needed for a given state file.  Here is an example of loading state in a python script that loads a state and uses the Search files under specified directory option.  This was created by using Python Trace while loading the state file used to create the above screenshots, so you can compare the options passed to LoadState to the options in the screenshots above.

 

These changes are merged into ParaView master and are available in the ParaView 5.4-RC1 binaries which can be obtained here.

6 Responses to New Options when Loading ParaView State Files

  1. Bruno says:

    Hello,
    thank you for your effort on the topic. I have been struggeling a lot with adjusting the paths in state files when reusing them for different simulations. My current workflow is:
    1. Create a state in Paraview on Windows
    2. When the simulation is done:
    2.1 Use a search/replace script on Linux cluster to replace Windows paths with Linux paths
    2.2 Run pvpython on Linux to load the state and save Animations
    3. Run another simulation
    3.1 copy state to new location
    3.2 Use script (from 2.1) to update all the paths for the local case
    3.3 Run pvpython on Linux to load the state and save Animations
    My script kind of behaves like “Search files under specified directory”. However “If the file exists it will be used, otherwise it will try the path in the state file.” sometimes led to making videos with the wrong data source and I only noticed some time later. Now I adjust all the paths and prefer getting errors if the file does not exist, instead of accidentially using the file from the previous case. (Sometimes the new case does not have all the sources the original case had for which I made the state template.)
    For me the perfect behaviour would be:
    – tick a “use relative paths” checkbox when saving the state file, making all paths relative to the current directory the state file is located when being loaded.
    – relative paths are accepted when the state is loaded in pvpython and also accepting both “/” and “\” paths separators, regardless of which operating system was used when creating the state file.
    Maybe you can add such a behaviour to the upcoming version?
    Thank you.

  2. Shawn Waldon says:

    Bruno,

    I added a new option for you that behaves like your script. Search files under specified directory now has a checkbox called ‘Only Use Files In Data Directory’ that makes it fail if the file is not found in the directory you specified rather than defaulting to the path in the state file. This change was just merged and will be in 5.4 RC2. Relative paths in state files is a bigger piece of work and will have to wait for a future release. But we are hoping that these changes will remove most of the need for it.

    Thank you for the feedback,
    Shawn

    • Bruno says:

      Shawn,

      I am looking forward to test it once the next version is released.
      Thank you for adding this feature.

      Bruno

  3. Elio says:

    Hello,

    I have a state file that loads two .pvtp files in split-screen to compare results.

    In 5.4, using the “Choose File Names” option, changing the name of one input file automatically updates the second file name to match the first, whereas I need two new paths for comparison. The feature works as I expected in 5.2. Is this a bug in the new release, or can I expect the current functionality to remain?

    Thanks,

    Elio

  4. Shawn Waldon says:

    Hi Elio,

    That sounds like a bug to me. Can you make a bug report over on the bug tracker? (https://gitlab.kitware.com/paraview/paraview/issues) Please include an example state file that demonstrates the problem.

    Shawn

  5. Benedikt Zier says:

    Hello,

    In 4.5.1 when changing the file names in the Load State Options my changes are not applied. I have one State which I want to use for two CSV data series. I have created the state for one of the data series but when changing the file names to the other data series in the Load State Options the default data series is loaded.

    Thanks,
    Benedikt

Questions or comments are always welcome!