-
Notifications
You must be signed in to change notification settings - Fork 99
Check config key #1792
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
Check config key #1792
Conversation
2ea21ad
to
ec6eda5
Compare
ec6eda5
to
91c9732
Compare
6e141fe
to
db95be4
Compare
Suggestion: use the pnode to keep track of which keys of a map were accessed. If not all keys were accessed, then there are some invalid keys. |
Implementation example: if (auto& obj = config.get("max_iters")) by std::set<std::string> allowed_keys;
auto get_config_value = [](const char* key) {
allowed_keys.insert(key);
return config.get(key);
};
// ...
if (auto& obj = get_config_value("max_iters")) The main goal is to specify every key name string only once, so we avoid accidental typos. |
db95be4
to
fabb554
Compare
It merge the allowed keys preparation with trying getting nodes now |
fabb554
to
2234682
Compare
526654a
to
2538b02
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.
Looks mostly good, but I would like to eliminate some potential for bugs, and simplify the diffs
2538b02
to
a70913b
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.
LGTM! I only would like to find some better names.
auto params = Schwarz::build(); | ||
|
||
if (auto& obj = config.get("generated_local_solver")) { | ||
config::config_decorator decorator(config); |
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.
decorator is not a particularly descriptive name, what if we named it config
and renamed the parameter to something like config_node
?
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 already used config for the object to hold property tree, so I would like to have the name easy to distinguish the behavior.
config_checker checker
is okay to me or config_tracker tracker
?
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.
typename config_check_decorator
and variable name config_check
?
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.
looks good to me
5ddf5da
to
11de363
Compare
11de363
to
1facd28
Compare
Co-authored-by: Tobias Ribizel <mail@ribizel.de>
1facd28
to
2307d9f
Compare
|
This PR adds the check to verify the keys in config are allowed by predefined keys set.
typo in config is quite easy in the file because we do not have auto-complete for that
It avoids typo or misusage of parameters from user such that the configuring solver is not what users expect without notice.
it use
config_check_decorator(config, additional_keys)
now, it provide theget
function like usual config and will check any disallowed key in the end.