USDA-ARS-NWRC / inicheck

Automated handling, checking, and outputting of complicated .ini configuration files.
Other
1 stars 4 forks source link

Config item passed with float with decimal in an integer field errors out #49

Open micahjohnson150 opened 4 years ago

micahjohnson150 commented 4 years ago

Description

Working with timesteps in Swiflow and found that a float passed to an integer item in the config file did not throw an inicheck error but rather an exception. This defeat the purpose of inicheck as we want to know all the errors that exist with a config file.

What I Did

config file

################################################################################
# Model Parameters
################################################################################

[model]
timestep_hours:                0.1

Master config entry:

[model]

timestep_hours:
default = 24,
type = int,
description = Timestep to march through time in integer hours

Fails with:

swiflow config.ini

and even with inicheck

inicheck -m swiflow -f config.ini

Traceback is

Traceback (most recent call last):
  File "/home/micahjohnson/projects/venv/swienv/bin/inicheck", line 8, in <module>
    sys.exit(main())
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/cli.py", line 65, in main
    changelog_file=args.changelog)
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/cli.py", line 108, in inicheck_main
    modules=modules, cli=True)
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/tools.py", line 252, in get_user_config
    ucfg = cast_all_variables(ucfg, mcfg)
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/tools.py", line 179, in cast_all_variables
    values = b.cast()
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/checkers.py", line 411, in cast
    result.append(self.type_func(v))
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/checkers.py", line 591, in convert_to_int
    raise ValueError("Expecting integer and received float with "
ValueError: Expecting integer and received float with  non-zero decimal