-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Readers in fileio module #2561
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2561 +/- ##
==========================================
+ Coverage 93.72% 93.76% +0.03%
==========================================
Files 75 75
Lines 16116 16150 +34
==========================================
+ Hits 15105 15143 +38
+ Misses 1011 1007 -4 |
@whophil I see you implemented the My reading of https://vtk.org/doc/nightly/html/classvtkPlot3DMetaReader.html suggests that it is expected that the user put this information into a more complex json formatted file before reading it. There are many more possibilities other than q-files here. Unless we want to implement a wrapper that mimics the json format, I'd suggest we scrap the q-file functionality entirely. Thoughts? For example, vtk suggests that this is a more descriptive pattern to use for this format, note that the changes in q-file are linked to a time point, an { "time" : 3.5, "xyz" : "combxyz.bin", "q" : "combq.1.bin", "function" : "combf.1.bin" },
{ "time" : 4.5, "xyz" : "combxyz.bin", "q" : "combq.2.bin", "function" : "combf.2.bin" } |
Hey @MatthewFlamm , sorry for the delay. I haven't been keeping up with the changes you've been making to the readers, so excuse my ignorance here.
I have never used the |
Im not sure, that's what I wanted to discuss. I'm proposing that all the other routines other than reader = Plot3DMetaReader(filename)
reader.add_q_files(q_file)
mesh = reader.read() After looking into this, it isn't clear to me that adding q-files is intended to be user-facing. It has a different method name in 8.x, 9.0.x, and 9.1.x. I'm unsure how we can get the functionality to more closely resemble the json file format without a lot of effort, which from my reading of the vtk docs is the intended usage for this reader. Maybe the best solution is to replicate the q file usage in the class based Reader, then someone with more need can make it more elegant? |
I believe the thing that should be wrapped, and possibly exposed with a convenience class (like the CGNS reader) is actually |
You have uncovered something I overlooked. |
This is now fully ready for review. I fully removed There aren't tests for all the file types, so it would be nice if someone can review the mapping of readers based on extension in the old |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can only look at the meat of the changes later, so only a few cursory remarks for now.
doc/api/utilities/utilities.rst
Outdated
@@ -33,7 +33,6 @@ File IO | |||
read | |||
read_exodus | |||
read_texture | |||
read_legacy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the situation of read_legacy()
any different from read_exodus()
? If I understand correctly the legacy reader is what reads .vtk
and .pvtk
files. I'm just wondering if downstream code might rely on this, and whether still having read_exodus()
is justified then.
Most of the hits at https://github.com/search?l=Python&q=read_legacy&type=Code are from something called openWB, and most of the rest are from pyvista itself (including forks). (Which is to say they aren't downstream uses of our helper.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either deprecate or remove read_legacy
IMO. Even before this PR when you called pyvista.read('file.vtk')
it called read_legacy
, so there was no need to have a separate function.
Exodus currently does not have a Reader class and it is self contained in that it doesn't use standard_reader_routine
. So I specifically left it out if this PR to keep things manageable.
I agree. This PR should make it much easier to add those in the future. This PR adds the existing functionality.
Good catch! I refactored the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a way cleaner implementation, and I fully support moving to use our new get_reader
approach.
I see no issues with this and I'd like to get this merged to main
and start playing around with this locally on some of my closed source projects to make sure that the new reader works. I'm happy with this as-is.
This is a fairly large PR. I'll give it just a few more days in case there are any more comments. I agree that testing downstream will also be important as there wasn't comprehensive testing of file types in |
Agreed. I'll merge by Friday next week unless there are additional concerns raised. |
Overview
Closes #2494. This PR uses the machinery in the
pyvista.utilities.reader
module to replace the functionality that thestandard_reader_routine
did.This enables one location to maintain reading utilities.
Details
I will leave
read_exodus
out of this PR as there is no Reader class and it is self-contained in fileio.TODO:
read_plot3d
functionality into the ReaderAdd error observing functionality into BaseReader?Continue wrapping observer forpyvista.read
standard_reader_routine