visit-dav / visit

VisIt - Visualization and Data Analysis for Mesh-based Scientific Data
https://visit.llnl.gov
BSD 3-Clause "New" or "Revised" License
434 stars 112 forks source link

Exporting a BOV with an absolute path fails. #5835

Open brugger1 opened 3 years ago

brugger1 commented 3 years ago

The following script works.

# Create the plot.
OpenDatabase("/usr/gapps/visit/data/rect3d.silo")
AddPlot("Pseudocolor", "u")
DrawPlots()

# Export the database.
e=ExportDBAttributes()
e.db_type="BOV"
e.filename = "export_file"
ExportDatabase(e)

quit()

When "export_file" is changed to an absolute path it fails with the error:

VisIt: Error - Unable to export database: viewer: There was an error opening Could not open stem file.  Do you lack write access on the destination filesystem?. It may be an invalid file.
biagas commented 3 years ago

Should it work? There is a dirname option in ExportDBAttributes for specifying location of the file.

brugger1 commented 3 years ago

I see that now. The default value is "." and by adding debug information I see that "./" is appended to the absolute path specified in "filename". This wasn't obvious to Steve Langer and it wasn't obvious to me. It may make sense in the GUI, but it is strange to have for a scripting interface.

Changing the attributes probably isn't a good idea. We could probably improve things so that people don't get confused by it and waste lots of time figuring out the problem.

A couple of thoughts.

1) If the filename starts with a "/" print an error. 2) If the filename starts with a "/", don't prepend the dir path.

Thoughts?

brugger1 commented 3 years ago

The relevant code is in the file ./engine/main/NetworkManager.C in ExportSingleDatabas around line 5008.

biagas commented 3 years ago

Just for clarity, here are the lines @brugger pointed out.

https://github.com/visit-dav/visit/blob/6e0161b081c01771181ddeeee1a93390dadc0862/src/engine/main/NetworkManager.C#L5007-L5012

There would have to be logic for Windows as well, where full paths don't begin with "/".

Using FileFunctions::dirname on filename might be helpful. If it returns an empty string, then prepend the atts dirname to filename to form qualFilename.

biagas commented 3 years ago

In my work for #5462, I have modified export_db.py test to also test changing dirnames. We should add a tests for filenames that are fully qualified paths.

brugger1 commented 3 years ago

Let's go with option 1, displaying an error message. We should try to catch the error early on so that we don't do a lot of work before catching it in NetworkManager. We may need to put a common validity check in the GUI and CLI or find somewhere early on that both share.