-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add support for JSON input files #114
Comments
Thank you so much for doing this, @arsLibera! I like your restructuring of the checks and reading the input file! It's also nice that the old format is still supported. Those are my thoughts so far: JSON format:
Testing:
Eventually, we also need to update the 1D input file generator in SimVascular. Changing the code shouldn’t be too complicated. However, as you can see from the pipeline performance, we currently can’t build SimVascular on certain platforms. @ktbolt might have an update on that. Let me know how you would like to proceed, @arsLibera, and where we can help! |
@arsLibera A very good start! We do need to support the old and new formats, will be some time until I can build SV again. Selecting a new file format we need to think about
Given that the 1D solver data is flat why not just use a simple text format that is cleaner and clearer than the current one ?
|
Makes sense
I wasn't aware of other applications besides the 1D solver that will be consuming the data. Can you point me to the other clients?
I agree that this is necessary, but something we should strive to avoid. In particular, the formatting in the file should be taken care of by the software. Small edits could be made by the user, but major edits should be easily supportable either through the C++ application or through a helper script (e.g., in Python).
This is one of the reasons why JSON is a good option. If you mean native in the sense of C++ itself or STL, no, but there are tons of great open source libraries out there with permissive licenses (as I'm sure you're aware).
I think there's two subpoints here: how easy it is to verify the formatting in the file and how easy it is to verify that the data is valid for the application. It might also be worth considering:
But, from a software perspective I think the question for me is always: Here's how I would evaluate your suggestion of a plain text format:
Most applications would prefer to consume JSON
I do not personally find manually editing (pretty) JSON to be more difficult than manually editing a plain text file in the sense that I do not find it more prone to errors. But for non-programmers, a custom plain-text format (like the one you suggest) could certainly be easier to read and edit.
This is probably the biggest reason not to use a custom plain-text format. There's no existing support.
a. In terms of validating the format, json is obvious here. We can rely on the existing parsers to throw errors for us if there is bad formatting. The formatting of a custom-formatted plain text file will take a lot more work. If we look at the additional points I raised:
Brian |
Sure, I wondered about those data tables (and a couple other things). I'd propose that we keep the format as-is initially, and then start to migrate data format (and clients of the data) once we can drop support for the previous format.
Based on that perspective I'd propose this initial step:
After that I'd propose two changes:
Brian |
I think JSON makes the most sense. It's not much more complicated than the plain text that @ktbolt suggests, and it's a standard format. We mostly use these reduced order models (0D and 1D) in applications where we sample many model evaluations, e.g., for uncertainty quantification, sensitivity analysis, or optimization. Using JSON, parameters can be changed easily in Python, and the simulations can be easily connected to other frameworks. For svMultiPhysics, we threw all unit tests in this folder. We added those lines to the CMakeLists.txt. These are activated during the build with a compiler flag and executed (manually or by GitHub Actions) with |
@arsLibera @mrp089 Good comments! So let's go with JSON then. |
Use Case
Define simulation input parameters.
Problem
Existing input format is difficult to read and not easily extensible
Solution
Provide a JSON input reader/writer to replace the existing custom format.
Alternatives considered
None
Additional context
@mrp089 @ktbolt
Untested/unrefined implementation:
master...arsLibera:svOneDSolver:jsonOptions
Example JSON:
out.json
Code of Conduct
The text was updated successfully, but these errors were encountered: