Skip to content

Conversation

yhmtsai
Copy link
Member

@yhmtsai yhmtsai commented Feb 18, 2025

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 the get function like usual config and will check any disallowed key in the end.

@yhmtsai yhmtsai added the 1:ST:need-feedback The PR is somewhat ready but feedback on a blocking topic is required before a proper review. label Feb 18, 2025
@yhmtsai yhmtsai requested a review from a team February 18, 2025 16:01
@yhmtsai yhmtsai self-assigned this Feb 18, 2025
@ginkgo-bot ginkgo-bot added reg:testing This is related to testing. mod:core This is related to the core module. type:solver This is related to the solvers labels Feb 18, 2025
@yhmtsai yhmtsai added 1:ST:ready-for-review This PR is ready for review and removed 1:ST:need-feedback The PR is somewhat ready but feedback on a blocking topic is required before a proper review. labels Feb 20, 2025
@yhmtsai yhmtsai requested a review from fritzgoebel February 20, 2025 15:40
@yhmtsai yhmtsai force-pushed the check_config_key branch 3 times, most recently from 6e141fe to db95be4 Compare March 4, 2025 15:41
@MarcelKoch MarcelKoch added this to the Ginkgo 1.10.0 milestone Mar 13, 2025
@MarcelKoch
Copy link
Member

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.
The pnode will also keep track of what is the set of allowed keys, since the parser function will test for all valid keys.

@upsj
Copy link
Member

upsj commented Mar 13, 2025

Implementation example:
Replace

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.

@yhmtsai
Copy link
Member Author

yhmtsai commented Mar 18, 2025

It merge the allowed keys preparation with trying getting nodes now

@yhmtsai yhmtsai force-pushed the check_config_key branch 2 times, most recently from 526654a to 2538b02 Compare May 26, 2025 13:32
Copy link
Member

@upsj upsj left a 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

@MarcelKoch MarcelKoch removed this from the Ginkgo 1.10.0 milestone Jun 8, 2025
@yhmtsai yhmtsai force-pushed the check_config_key branch from 2538b02 to a70913b Compare June 10, 2025 23:49
@yhmtsai yhmtsai requested a review from upsj June 10, 2025 23:49
Copy link
Member

@upsj upsj left a 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);
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@yhmtsai yhmtsai added the 1:ST:ready-to-merge This PR is ready to merge. label Jun 11, 2025
@yhmtsai yhmtsai force-pushed the check_config_key branch from 5ddf5da to 11de363 Compare June 11, 2025 11:45
@yhmtsai yhmtsai force-pushed the check_config_key branch from 11de363 to 1facd28 Compare June 11, 2025 20:24
@yhmtsai yhmtsai removed the 1:ST:ready-for-review This PR is ready for review label Jun 24, 2025
@yhmtsai yhmtsai force-pushed the check_config_key branch from 1facd28 to 2307d9f Compare June 24, 2025 09:08
Copy link

sonarqubecloud bot commented Jun 25, 2025

@yhmtsai yhmtsai merged commit de6f914 into develop Jun 25, 2025
15 of 16 checks passed
@yhmtsai yhmtsai deleted the check_config_key branch June 25, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1:ST:ready-to-merge This PR is ready to merge. mod:core This is related to the core module. reg:testing This is related to testing. type:solver This is related to the solvers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants