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

setup_gauges in wflow.py throws error when gauges_fn = None #198

Closed
pauwiersma opened this issue Aug 18, 2023 · 1 comment · Fixed by #227
Closed

setup_gauges in wflow.py throws error when gauges_fn = None #198

pauwiersma opened this issue Aug 18, 2023 · 1 comment · Fixed by #227
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@pauwiersma
Copy link

According to the documentation the default value of gauges_fn is None (line 1079), but os.path.isfile() throws an error if it is fed with a None (line 1119):

2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.gauges_fn: None
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.index_col: None
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.snap_to_river: False
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.mask: None
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.snap_uparea: False
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.max_dist: 10000.0
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.wdw: 3
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.rel_error: 0.05
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.derive_subcatch: False
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.basename: None
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.toml_output: csv
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.gauge_toml_header: ['Q', 'P']
2023-08-18 13:54:01,154 - build - model_api - INFO - setup_gauges.gauge_toml_param: ['lateral.river.q_av', 'vertical.precipitation']
2023-08-18 13:54:01,154 - build - main - ERROR - stat: path should be string, bytes, os.PathLike or integer, not NoneType
Traceback (most recent call last):
File "/home/pwiersma/miniconda3/envs/hydromt-wflow/lib/python3.10/site-packages/hydromt/cli/main.py", line 207, in build
mod.build(region, opt=opt)
File "/home/pwiersma/miniconda3/envs/hydromt-wflow/lib/python3.10/site-packages/hydromt/models/model_api.py", line 220, in build
self._run_log_method(method, **kwargs)
File "/home/pwiersma/miniconda3/envs/hydromt-wflow/lib/python3.10/site-packages/hydromt/models/model_api.py", line 163, in _run_log_method
return func(*args, **kwargs)
File "/home/pwiersma/miniconda3/envs/hydromt-wflow/lib/python3.10/site-packages/hydromt_wflow/wflow.py", line 1119, in setup_gauges
elif isfile(gauges_fn):
File "/home/pwiersma/miniconda3/envs/hydromt-wflow/lib/python3.10/genericpath.py", line 30, in isfile
st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

@JoostBuitink
Copy link
Collaborator

Good spot! The docstring of that function is outdated. We decided to no longer support the None argument in the setup_gauges method. If you don't want to add gauges to your model, we thought it is better to just remove the [setup_gauges] block from the ini file. We will update the docstring of this function to reflect this new behavior. Thanks for spotting this issue!

@JoostBuitink JoostBuitink added the documentation Improvements or additions to documentation label Aug 18, 2023
@hboisgon hboisgon self-assigned this Dec 14, 2023
hboisgon added a commit that referenced this issue Dec 14, 2023
@hboisgon hboisgon mentioned this issue Dec 14, 2023
4 tasks
@JoostBuitink JoostBuitink added this to the 2024 - high priority milestone Jan 24, 2024
dalmijn added a commit that referenced this issue Feb 13, 2024
* Update setup_gauges docs #198

* fix pet_method error #201

* improve setup methods docstrings #225

* update changelog

* Indentation error

* Remove optional for 'temp_pet_fn' in docstring

---------

Co-authored-by: Brendan <brencodeert@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants