Skip to content

Commit ba656e0

Browse files
committed
Issue #147 openeo.cloud configs: only consider "vito" for SENTINEL2_L2A collection
1 parent 9f3b2da commit ba656e0

File tree

7 files changed

+82
-1
lines changed

7 files changed

+82
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is roughly based on [Keep a Changelog](https://keepachangelog.com/en/
66

77
<!-- start changelog -->
88

9+
## 0.36.0
10+
11+
- openeo.cloud configs: only consider "vito" for SENTINEL2_L2A collection ([#147](https://github.com/Open-EO/openeo-aggregator/issues/147))
12+
913
## 0.35.1
1014

1115
- Add `aggregator.dummy.py` to wheel ([#117](https://github.com/Open-EO/openeo-aggregator/issues/117))

conf/aggregator.dev.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
from openeo_driver.users.oidc import OidcProvider
24

35
from openeo_aggregator.config import AggregatorBackendConfig
@@ -55,6 +57,12 @@
5557
# Sentinel Hub OpenEO by Sinergise
5658
"sentinelhub": "https://openeo.sentinel-hub.com/production/",
5759
},
60+
collection_allow_list=[
61+
# Special case: only consider Terrascope for SENTINEL2_L2A
62+
{"collection_id": "SENTINEL2_L2A", "allowed_backends": ["vito"]},
63+
# Still allow all other collections
64+
re.compile("(?!SENTINEL2_L2A).*"),
65+
],
5866
zookeeper_prefix="/openeo/aggregator-dev/",
5967
partitioned_job_tracking={
6068
"zk_hosts": ZK_HOSTS,

conf/aggregator.prod.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
from openeo_driver.users.oidc import OidcProvider
24

35
from openeo_aggregator.config import AggregatorBackendConfig
@@ -47,6 +49,12 @@
4749
# Sentinel Hub OpenEO by Sinergise
4850
"sentinelhub": "https://openeo.sentinel-hub.com/production/",
4951
},
52+
collection_allow_list=[
53+
# Special case: only consider Terrascope for SENTINEL2_L2A
54+
{"collection_id": "SENTINEL2_L2A", "allowed_backends": ["vito"]},
55+
# Still allow all other collections
56+
re.compile("(?!SENTINEL2_L2A).*"),
57+
],
5058
zookeeper_prefix="/openeo/aggregator/",
5159
partitioned_job_tracking={
5260
"zk_hosts": ZK_HOSTS,

src/openeo_aggregator/about.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from typing import Optional
44

5-
__version__ = "0.35.1a1"
5+
__version__ = "0.36.0a1"
66

77

88
def log_version_info(logger: Optional[logging.Logger] = None):

src/openeo_aggregator/backend.py

+9
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ def match(self, collection_id: str, backend_id: str) -> bool:
178178
class CollectionAllowList:
179179
"""Allow list for collections, where filtering is based on collection id and (optionally) backend id."""
180180

181+
# TODO: The use case where one wants to exclude one backend from a particular collection,
182+
# while still keeping all other collections like the default behaviour
183+
# is a bit cumbersome and error-prone, e.g.:
184+
# collection_allow_list=[
185+
# {"collection_id": "SENTINEL2_L2A", "allowed_backends": ["vito"]},
186+
# re.compile("(?!SENTINEL2_L2A).*"),
187+
# ],
188+
# That last "catch-all-but-one" rule is not very intuitive and easy to get wrong.
189+
181190
def __init__(self, items: List[Union[str, re.Pattern, dict]]):
182191
"""
183192
:param items: list of allow list items, where each item can be:

src/openeo_aggregator/config.py

+6
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ class AggregatorBackendConfig(OpenEoBackendConfig):
7878
# # and additionally only consider specific backends by id (per `aggregator_backends` config)
7979
# {"collection_id": "SENTINEL2_L2A", "allowed_backends": ["b2"]},
8080
# ]
81+
# A collection+backend combo will be included if any item matches.
82+
# This means that if you want to exclude one backend from a particular collection,
83+
# while still keeping all other collections (like the default behavior),
84+
# you need to add an item that matches everything but that collection, e.g.:
85+
# {"collection_id": "SENTINEL2_L2A", "allowed_backends": ["b2"]},
86+
# re.compile("(?!SENTINEL2_L2A).*"),
8187
collection_allow_list: Optional[List[Union[str, re.Pattern, dict]]] = None
8288

8389
# Process allow list (as callable) for process ids to cover with the aggregator. Accept all by default.

tests/test_views.py

+46
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,52 @@ def test_collections_allow_list_allowed_backend(
390390
else:
391391
res.assert_error(404, "CollectionNotFound")
392392

393+
def test_collections_allow_list_deny_on_one_keep_the_rest(
394+
self,
395+
api100,
396+
requests_mock,
397+
backend1,
398+
backend2,
399+
):
400+
"""
401+
exclude one backend for a particular collection and keep the rest
402+
"""
403+
for backend, cids in {
404+
backend1: ["S1", "S2", "S3"],
405+
backend2: ["S2", "S3"],
406+
}.items():
407+
requests_mock.get(backend + "/collections", json={"collections": [{"id": cid} for cid in cids]})
408+
for cid in cids:
409+
requests_mock.get(backend + f"/collections/{cid}", json={"id": cid, "title": f"{backend} {cid}"})
410+
411+
collection_allow_list = [
412+
re.compile("(?!S3).*"),
413+
{"collection_id": "S3", "allowed_backends": ["b2"]},
414+
]
415+
416+
with config_overrides(collection_allow_list=collection_allow_list):
417+
res = api100.get("/collections").assert_status_code(200).json
418+
assert set(c["id"] for c in res["collections"]) == {"S1", "S2", "S3"}
419+
420+
assert api100.get("/collections/S1").assert_status_code(200).json == DictSubSet(
421+
{
422+
"id": "S1",
423+
"summaries": DictSubSet({"federation:backends": ["b1"]}),
424+
}
425+
)
426+
assert api100.get("/collections/S2").assert_status_code(200).json == DictSubSet(
427+
{
428+
"id": "S2",
429+
"summaries": DictSubSet({"federation:backends": ["b1", "b2"]}),
430+
}
431+
)
432+
assert api100.get("/collections/S3").assert_status_code(200).json == DictSubSet(
433+
{
434+
"id": "S3",
435+
"summaries": DictSubSet({"federation:backends": ["b2"]}),
436+
}
437+
)
438+
393439

394440
class TestAuthentication:
395441
def test_credentials_oidc_default(self, api100, backend1, backend2):

0 commit comments

Comments
 (0)