From b2838786a0ed5024308c80888d8d9c15147db07e Mon Sep 17 00:00:00 2001 From: Paul Haesler Date: Tue, 9 Apr 2024 10:59:22 +1000 Subject: [PATCH] Refine default behaviour of config engine to support easier migration from 1.8 --- datacube/cfg/api.py | 4 +++- docs/about/whats_new.rst | 3 ++- tests/test_cfg.py | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/datacube/cfg/api.py b/datacube/cfg/api.py index 8179b36dd..33c9bdbfe 100644 --- a/datacube/cfg/api.py +++ b/datacube/cfg/api.py @@ -220,7 +220,9 @@ def __getitem__(self, item: str | None) -> "ODCEnvironment": "this fallback behaviour is deprecated and may change in a future release.") item = "datacube" else: - raise ConfigException("No environment specified and no default environment could be identified.") + # No explicitly defined (known) environments - assume default and hope there's config + # available in environment variables. + item = "default" if item not in self.known_environments: self.known_environments[item] = ODCEnvironment(self, item, {}, True) return self.known_environments[item] diff --git a/docs/about/whats_new.rst b/docs/about/whats_new.rst index afd67980d..8373f9388 100644 --- a/docs/about/whats_new.rst +++ b/docs/about/whats_new.rst @@ -8,7 +8,8 @@ What's New v1.9.next ========= -- Standardize resampling input supported to `odc.geo.warp.Resampling`. +- Standardize resampling input supported to `odc.geo.warp.Resampling` (:pull:`1571`) +- Refine default behaviour for config engine to support easier migration from 1.8 (:pull:`1573`) v1.9.0-rc3 (27th March 2024) diff --git a/tests/test_cfg.py b/tests/test_cfg.py index 7e3cba107..181eda938 100644 --- a/tests/test_cfg.py +++ b/tests/test_cfg.py @@ -542,5 +542,4 @@ def test_default_environment(simple_config, monkeypatch): 'weirdname': {"index_driver": "memory"}, 'stupidenv': {"index_driver": "null"}, }) - with pytest.raises(ConfigException): - cfg[None]._name + assert cfg[None]._name == "default"