opendatacube / datacube-core

Open Data Cube analyses continental scale Earth Observation data through time
http://www.opendatacube.org
Apache License 2.0
493 stars 175 forks source link

Empty `~/.datacube.conf` causes errors #1603

Closed Kirill888 closed 1 week ago

Kirill888 commented 1 week ago

Expected behaviour

mv ~/.datacube.conf datacube.conf.bk
touch ~/.datacube.conf

datacube system check

Actual behaviour

datacube system check fails with traceback.

in the notebook, traceback is more clear, self.raw_config is None but is being iterated over.

File ~/.envs/emit/lib/python3.10/site-packages/datacube/cfg/api.py:121, in ODCConfig.__init__(self, paths, raw_dict, text)
    118     self.raw_config = parse_text(cast(str, self.raw_text))
    120 self._aliases: dict[str, str] = {}
--> 121 self.known_environments: dict[str, ODCEnvironment] = {
    122     section: ODCEnvironment(self, section, self.raw_config[section], self.allow_envvar_overrides)
    123     for section in self.raw_config
    124 }
    125 self.canonical_names: dict[str, list[str]] = {}
    126 for alias, canonical in self._aliases.items():

TypeError: 'NoneType' object is not iterable

Steps to reproduce the behaviour

that's on develop-1.9 branch, just create .datacube.conf file without any data in it.

SpacemanPaul commented 1 week ago

Ah, yes. A blank config should parse as an empty dict {} - good catch.