Skip to content

Commit 0a6687a

Browse files
committed
Issue #112 introduce OpenEoBackendConfig usage
still need to be merged/unified with existing AggregatorConfig related: Open-EO/openeo-python-driver#204
1 parent a359035 commit 0a6687a

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

conf/backend_config.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from openeo_driver.config import OpenEoBackendConfig
2+
from openeo_driver.server import build_backend_deploy_metadata
3+
4+
import openeo_aggregator
5+
6+
deploy_metadata = build_backend_deploy_metadata(
7+
packages=["openeo", "openeo_driver", "openeo_aggregator"],
8+
)
9+
10+
# TODO #112 Merge with `AggregatorConfig`
11+
config = OpenEoBackendConfig(
12+
id="aggregator",
13+
capabilities_title="openEO Platform",
14+
capabilities_description="openEO Platform, provided through openEO Aggregator Driver",
15+
capabilities_backend_version=openeo_aggregator.about.__version__,
16+
capabilities_deploy_metadata=deploy_metadata,
17+
)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"requests",
2929
"attrs",
3030
"openeo>=0.17.0",
31-
"openeo_driver>=0.53.1.dev",
31+
"openeo_driver>=0.57.1.dev",
3232
"flask~=2.0",
3333
"gunicorn~=20.0",
3434
"python-json-logger>=2.0.0",

src/openeo_aggregator/app.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@
77

88
import flask
99
import openeo_driver.views
10-
from openeo_driver.server import build_backend_deploy_metadata
10+
from openeo_driver.config.load import ConfigGetter
1111
from openeo_driver.util.logging import (
1212
LOGGING_CONTEXT_FLASK,
1313
get_logging_config,
1414
setup_logging,
1515
)
1616
from openeo_driver.utils import smart_bool
1717

18-
import openeo_aggregator.about
1918
from openeo_aggregator.backend import (
2019
AggregatorBackendImplementation,
2120
MultiBackendConnection,
2221
)
23-
from openeo_aggregator.config import AggregatorConfig, get_config
22+
from openeo_aggregator.config import AggregatorConfig, get_config, get_config_dir
2423

2524
_log = logging.getLogger(__name__)
2625

@@ -51,6 +50,8 @@ def create_app(config: Any = None, auto_logging_setup: bool = True) -> flask.Fla
5150
context=LOGGING_CONTEXT_FLASK,
5251
))
5352

53+
os.environ.setdefault(ConfigGetter.OPENEO_BACKEND_CONFIG, str(get_config_dir() / "backend_config.py"))
54+
5455
config: AggregatorConfig = get_config(config)
5556
_log.info(f"Using config: {config}")
5657

@@ -66,14 +67,9 @@ def create_app(config: Any = None, auto_logging_setup: bool = True) -> flask.Fla
6667
error_handling=config.flask_error_handling,
6768
)
6869

69-
deploy_metadata = build_backend_deploy_metadata(
70-
packages=["openeo", "openeo_driver", "openeo_aggregator"],
71-
)
7270
app.config.from_mapping(
73-
OPENEO_TITLE="openEO Platform",
74-
OPENEO_DESCRIPTION="openEO Platform, provided through openEO Aggregator Driver",
75-
OPENEO_BACKEND_VERSION=openeo_aggregator.about.__version__,
76-
OPENEO_BACKEND_DEPLOY_METADATA=deploy_metadata,
71+
# Config hack to make backend_implementation available from pytest fixture
72+
# TODO: is there another, less hackish way?
7773
OPENEO_BACKEND_IMPLEMENTATION=backend_implementation,
7874
)
7975

src/openeo_aggregator/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ConfigException(ValueError):
2727
pass
2828

2929

30-
# TODO #112 subclass from OpenEoBackendConfig
30+
# TODO #112 subclass from OpenEoBackendConfig (attrs based instead of dictionary based)
3131
class AggregatorConfig(dict):
3232
"""
3333
Simple dictionary based configuration for aggregator backend

tests/test_views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def test_capabilities(self, api100):
4848
"b2": {"url": "https://b2.test/v1"},
4949
}
5050

51+
def test_title_and_description(self, api100):
52+
res = api100.get("/").assert_status_code(200)
53+
capabilities = res.json
54+
assert capabilities["title"] == "openEO Platform"
55+
assert capabilities["description"] == "openEO Platform, provided through openEO Aggregator Driver"
56+
5157
def test_capabilities_validation(self, api100):
5258
"""https://github.com/Open-EO/openeo-aggregator/issues/42"""
5359
res = api100.get("/").assert_status_code(200)

0 commit comments

Comments
 (0)