pytroll / pytroll-collectors

Collector modules for Pytroll
GNU General Public License v3.0
3 stars 18 forks source link

segment_gatherer fails with yaml ParserError when passed ini-config file from examples directory #71

Open gerritholl opened 3 years ago

gerritholl commented 3 years ago

The examples/ directory contains some configuration files in .ini and some in .yaml. I used the trollstalker_config.ini_template to configure a trollstalker.ini, and similarly for trollstalker_logging.ini. This is handled well by trollstalker -c trollstalker.ini. I then used segment_gatherer.ini_template as a template to configure my segment_gatherer.ini, but when I then ran segment_gatherer -c segment_gatherer.ini it failed with an exception — apparently segment_gatherer wants yaml files now.

To reproduce

Expected result

Since I based this off an example in current git master, I expected it to work with current git master.

Actual result

Traceback (most recent call last):
  File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/bin/segment_gatherer.py", line 95, in <module>
    main()
  File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/bin/segment_gatherer.py", line 57, in main
    config = read_yaml(args.config)
  File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pytroll_collectors/helper_functions.py", line 209, in read_yaml
    data = yaml.load(fid, Loader=yaml.SafeLoader)
  File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/yaml/composer.py", line 39, in get_single_node
    if not self.check_event(StreamEndEvent):
  File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/yaml/parser.py", line 171, in parse_document_start
    raise ParserError(None, None,
yaml.parser.ParserError: expected '<document start>', but found '<scalar>'
  in "segment_gatherer.ini", line 2, column 1

Desired solution

The examples/ directory should only contain configuration file formats that are current. Any older formats should be converted to the equivalent in the current formats and then the old files should be deleted.

Further context

It appears that zipcollector_config also contains both ini and yaml examples.

pnuu commented 3 years ago

When using .ini configs also -C <section-name> needs to be given.

gerritholl commented 3 years ago

I see, yes, that works. It wasn't clear to me that this was a mandatory option.