diff --git a/CHANGELOG.md b/CHANGELOG.md index 489132d..3ace9a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is roughly based on [Keep a Changelog](https://keepachangelog.com/en/ +## 0.37.1 + +- Better error message when requested collections are spread across separate backends ([#153](https://github.com/Open-EO/openeo-aggregator/issues/153)) + ## 0.37.0 - move example configs inside package source tree ([#117](https://github.com/Open-EO/openeo-aggregator/issues/117)) diff --git a/src/openeo_aggregator/about.py b/src/openeo_aggregator/about.py index d7a9f53..b71dbe1 100644 --- a/src/openeo_aggregator/about.py +++ b/src/openeo_aggregator/about.py @@ -2,7 +2,7 @@ import sys from typing import Optional -__version__ = "0.37.0a1" +__version__ = "0.37.1a1" def log_version_info(logger: Optional[logging.Logger] = None): diff --git a/src/openeo_aggregator/backend.py b/src/openeo_aggregator/backend.py index 0aa2903..75a812a 100644 --- a/src/openeo_aggregator/backend.py +++ b/src/openeo_aggregator/backend.py @@ -321,9 +321,16 @@ def get_backend_candidates_for_collections(self, collections: Iterable[str]) -> if intersection: backend_candidates = list(intersection) else: + # No single backend that provides each of requested collections + # Report collections that are only available on certain backends union = functools.reduce(lambda a, b: set(a).union(b), backend_combos) + only_on = [ + f"{cid!r} only on {list(backends)}" + for cid, backends in collection_backends_map.items() + if union.difference(backends) + ] raise BackendLookupFailureException( - message=f"Collections across multiple backends ({union}): {collections}." + message=f"Requested collections are not available on a single backend, but spread across separate ones: {', '.join(only_on)}." ) _log.info(f"Backend candidates {backend_candidates} for collections {collections}") diff --git a/tests/test_backend.py b/tests/test_backend.py index fcbeaef..078d66d 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -1077,7 +1077,10 @@ def test_get_best_backend_for_collections_basic(self, catalog, backend1, backend assert catalog.get_backend_candidates_for_collections(["S3", "S4"]) == ["b1"] assert catalog.get_backend_candidates_for_collections(["S4", "S5"]) == ["b2"] - with pytest.raises(OpenEOApiException, match="Collections across multiple backends"): + with pytest.raises( + OpenEOApiException, + match=r"Requested collections are not available on a single backend, but spread across separate ones: 'S3' only on \['b1'\], 'S5' only on \['b2'\]\.", + ): catalog.get_backend_candidates_for_collections(["S3", "S4", "S5"]) def test_get_collection_metadata_basic(self, catalog, backend1, backend2, requests_mock):