Skip to content
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

Revise Formulation_Manager.hpp #488

Closed
wants to merge 2 commits into from

Conversation

stcui007
Copy link
Contributor

Revise Formulation_Manager.hpp so that it can parse forcing params with pattern in explicit catchment configs

Additions

data/test_bmi_multi_realization_config_w_netcdf.json
data/test_bmi_multi_realization_config_w_noah_pet_cfe.json
data/test_realization_config.json

Removals

Changes

include/realizations/catchment/Formulation_Manager.hpp

Testing

Unit test
Run ngen in serial mode with various realization configure files
Run ngen in parallel mode with various realization configure files

Screenshots

Notes

Todos

Checklist

  • [x ] PR has an informative and human-readable title
  • [x ] Changes are limited to a single goal (no scope creep)
  • [x ] Code can be automatically merged (no conflicts)
  • [x ] Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist (automated report can be put here)

Target Environment support

  • [x ] Linux

std::string errMsg;
size_t attemptCount = 0;
std::string err_num = check_opendir(path, errMsg);
if (err_num == "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

This block seems redundant, since this kind of check/retry has already been done in check_opendir, any error that falls through from that has already timed out or is non-recoverable, so I think the check/retry loop here can be removed.

@mattw-nws
Copy link
Contributor

This approach may be okay (with some tweaks... e.g. we probably don't need a regex to find {{id}} as .find() will do fine), but it seems like there is still a lot of duplication...

It seems both paths start with a JSONProperty and produce a forcing_params object... which is almost exactly what the existing get_global_forcing_params function does--but that function always operates on this->global_forcing. I think, it may be a better approach to modify this function:

forcing_params get_global_forcing_params(std::string identifier, simulation_time_params &simulation_time_config) {
    std::string path = this->global_forcing.at("path").as_string();
    // ... etc.

to be:

forcing_params get_forcing_params(geojson::PropertyMap &forcing_prop_map, std::string identifier, simulation_time_params &simulation_time_config) {
    std::string path = forcing_prop_map.at("path").as_string();
    // ... etc.

And whenever there is a call to:

forcing_params forcing_config = this->get_global_forcing_params(identifier, simulation_time_config);

make it:

forcing_params forcing_config = this->get_forcing_params(this->global_forcing, identifier, simulation_time_config);

Then, in consruct_formulation_from_tree, you could replicate what is done up at line 59 and following:

                    for (auto &forcing_parameter : (*possible_global_config).get_child("forcing")) {
                        this->global_forcing.emplace(
                            forcing_parameter.first,
                            geojson::JSONProperty(forcing_parameter.first, forcing_parameter.second)
                        );
                      }

To turn the possible_forcing into a local_forcing (not global_forcing) geojson::PropertyMap which can be passed to the same function. Then it can be passed to the same function like this:

forcing_params forcing_config = this->get_forcing_params(local_forcing, identifier, simulation_time_config);

Can you try this approach? It might be worth doing a new branch (from upstream:master ... making sure commit 444bd00 isn't included, which I think will break merging). I think this may be a much smaller/cleaner change.

@stcui007
Copy link
Contributor Author

stcui007 commented Jan 11, 2023 via email

@stcui007
Copy link
Contributor Author

stcui007 commented Jan 11, 2023 via email

@stcui007
Copy link
Contributor Author

stcui007 commented Jan 11, 2023 via email

Copy link
Member

@hellkite500 hellkite500 left a comment

Choose a reason for hiding this comment

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

Would definitely favor #489

@mattw-nws
Copy link
Contributor

Cleaning up, looks like this was accomplished in #489 instead, closing.

@mattw-nws mattw-nws closed this Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants