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 basic parameter file validation mode. #2600
Add basic parameter file validation mode. #2600
Conversation
Does this really work as is? I don't see the logic to check whether parsing works or not. Would you mind setting the return value in |
ef3829a
to
6916c18
Compare
Yeah, but it does it the lazy way. It either hits the I'm not sure I understood your suggestion. I see two other options to make the code more explicit, and they both involve more changes and possible code duplication than I think this feature really deserves:
|
I see! This is difficult to see by looking at the source. So you are saying that your approach does already return failure in main() because of the quiet exception? Another option (maybe):
instead of introducing additional args to |
That'd work, and be more clear/explicit, but to do it from Alternatively, that could be its own function, called something like I'm fine with any of these options; let me know which you prefer. |
well, you could put what I wrote into
I don't feel strongly about it either. :) |
6916c18
to
dc45800
Compare
👍 -- I put your code in |
I like it! Thanks. /run-tests |
dc45800
to
423f9c3
Compare
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 like this as well!
source/main.cc
Outdated
@@ -511,6 +511,7 @@ void print_help() | |||
<< " -j, --threads (to use multi-threading)\n" | |||
<< " --output-xml (print parameters in xml format to standard output and exit)\n" | |||
<< " --output-plugin-graph (write a representation of all plugins to standard output and exit)\n" | |||
<< " --validate (parse parameter file and exit)\n" |
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.
maybe make the purpose clear by saying "...and either exit or report parsing failures"?
source/main.cc
Outdated
throw aspect::QuietException(); | ||
} | ||
if (i_am_proc_0) | ||
std::cout << "Valid parameter file." << std::endl; |
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.
In isolation (without knowing the code that surrounds it), this text is hard to understand. Is the user asked to provide a valid parameter file? Maybe just say "The provided output file is valid."
306979b
to
66f216b
Compare
I changed those interface messages to make them more clear. Should be pretty much good to go now. One thing that's sort of unfortunate about this feature is that it's totally possible to write a valid parameter file that will not run. For example, if you choose 3 compositional fields, but only list two field names, this validation will pass, but your model will crash before starting. From the user's perspective, that's an invalid parameter file. The distinction between that and the more superficial validations addressed in this patch isn't at all obvious. I added a disclaimer after the successful validation message to that effect, but it might be worth thinking of ways to more thoroughly validate prm's in the future (run the simulator for a time step, but turn off all the solvers or something?). The idea here is to make sure your model won't immediately crash on a cluster, where you might not notice the failure right away. |
The problem with that is that you might not be able to create/setup the initial mesh on your workstation, resume from a snapshot, etc.. or that it will take a very long time. I think "validation" should be something that runs very quickly. |
Agreed. I don't really have a solution at the moment, but something to think about in the future. |
All of the checks we currently perform are either in the |
source/main.cc
Outdated
throw aspect::QuietException(); | ||
} | ||
if (i_am_proc_0) | ||
std::cerr << "The provided parameter file is valid.\n\n" |
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.
std::cerr
is not the correct place: that's where errors go, but you print a success message. Can you still change this?
Looks ready. |
…ation Add basic parameter file validation mode.
This idea could definitely be improved upon, but is of useful as is. This PR adds a
--validate
flag that exits after parsing the parameter file. I typically do the same thing by just starting a model and ctrl-c'ing it after the parameter file is parsed. This is very slightly more straightforward, and possible to automate in a script later on if needed.