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

Inconsistency in expected config structure between troute-config and troute-network #719

Open
robertbartel opened this issue Jan 5, 2024 · 3 comments
Assignees

Comments

@robertbartel
Copy link

The troute-network package (and possibly other places) expects compute_parameters.data_assimilation_parameters.reservoir_da to have subkeys reservoir_persistence_usace and reservoir_persistence_usgs. However, troute-config defines this property as an Optional[ReservoirDA]. As a result, if reservoir_persistence_usace and reservoir_persistence_usgs are present, we see this error:

terminate called after throwing an instance of 'pybind11::error_already_set'
  what():  ValidationError: 2 validation errors for Config
compute_parameters -> data_assimilation_parameters -> reservoir_da -> reservoir_persistence_usace
  extra fields not permitted (type=value_error.extra)
compute_parameters -> data_assimilation_parameters -> reservoir_da -> reservoir_persistence_usgs
  extra fields not permitted (type=value_error.extra)

During troubleshooting, it was suggested by @aaraney that, within the DataAssimilationParameters model, the reservoir_da attribute may need to be of type Optional[ReservoirPersistenceDA] rather than Optional[ReservoirDA].

Note that if we comment out reservoir_persistence_usace and reservoir_persistence_usgs from the config, then this error happens:

terminate called after throwing an instance of 'pybind11::error_already_set'
  what():  AttributeError: 'NoneType' object has no attribute 'get'

At:
  /usr/local/lib64/python3.9/site-packages/troute/HYFeaturesNetwork.py(32): read_geopkg
  /usr/local/lib64/python3.9/site-packages/troute/HYFeaturesNetwork.py(154): read_geo_file
  /usr/local/lib64/python3.9/site-packages/troute/HYFeaturesNetwork.py(253): __init__
  /usr/local/lib/python3.9/site-packages/nwm_routing/__main__.py(80): main_v04

Here are lines 31 and 32 of src/troute-network/troute/HYFeaturesNetwork.py:

    streamflow_nudging = data_assimilation_parameters.get('streamflow_da',{}).get('streamflow_nudging',False)
    usgs_da = data_assimilation_parameters.get('reservoir_da',{}).get('reservoir_persistence_usgs',False)
@robertbartel
Copy link
Author

A note that I did attempt to change the reservoir_da property type from Optional[ReservoirDA] to Optional[ReservoirPersistenceDA], as @aaraney suggested and as was mentioned in the description, but that led to a different error during testing:

terminate called after throwing an instance of 'pybind11::error_already_set'
  what():  AttributeError: 'ReservoirPersistenceDA' object has no attribute 'reservoir_rfc_da'

At:
  /usr/local/lib/python3.9/site-packages/troute/config/config.py(118): check_rfc_parameters
  /usr/local/lib/python3.9/site-packages/nwm_routing/input.py(44): _input_handler_v04
  /usr/local/lib/python3.9/site-packages/nwm_routing/__main__.py(54): main_v04

@shorvath-noaa shorvath-noaa self-assigned this Jan 11, 2024
@shorvath-noaa
Copy link
Contributor

@robertbartel It looks like, for the original error listed here, you're missing a level in the config file. They way troute-config is setup, it should be compute_parameters -> data_assimilation_parameters -> reservoir_da -> reservoir_persistence_da -> reservoir_persistence_usace

@shorvath-noaa
Copy link
Contributor

The two config files in /t-route/test/LowerColorado_TX_v4/ are the most recent examples that work with V4. You should be able to use these as guidelines for running the latest version of t-route.

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

No branches or pull requests

2 participants