Skip to content

Commit

Permalink
Issue #10: list supporting backends in process metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Oct 5, 2021
1 parent 958dfb8 commit 99fda75
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/openeo_aggregator/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def _get_process_registry(self) -> ProcessRegistry:

process_registry = ProcessRegistry()
for pid, spec in combined_processes.items():
# TODO: #10 proper schema of this backend listing?
spec["backends"] = [bid for bid, procs in processes_per_backend.items() if pid in procs]
process_registry.add_spec(spec=spec)

return process_registry
Expand Down
36 changes: 30 additions & 6 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,21 @@ def test_get_process_registry(self, multi_backend_connection, backend1, backend2
processing = AggregatorProcessing(backends=multi_backend_connection, catalog=catalog)
registry = processing.get_process_registry(api_version="1.0.0")
assert sorted(registry.get_specs(), key=lambda p: p["id"]) == [
{"id": "add", "parameters": [{"name": "x"}, {"name": "y"}]},
{"id": "mean", "parameters": [{"name": "data"}]},
{"id": "multiply", "parameters": [{"name": "x"}, {"name": "y"}]},
{
"id": "add",
"parameters": [{"name": "x"}, {"name": "y"}],
"backends": ["b1"],
},
{
"id": "mean",
"parameters": [{"name": "data"}],
"backends": ["b1", "b2"],
},
{
"id": "multiply",
"parameters": [{"name": "x"}, {"name": "y"}],
"backends": ["b2"],
},
]

def test_get_process_registry_parameter_differences(
Expand All @@ -330,7 +342,19 @@ def test_get_process_registry_parameter_differences(
processing = AggregatorProcessing(backends=multi_backend_connection, catalog=catalog)
registry = processing.get_process_registry(api_version="1.0.0")
assert sorted(registry.get_specs(), key=lambda p: p["id"]) == [
{"id": "add", "parameters": [{"name": "x"}, {"name": "y"}]},
{"id": "mean", "parameters": [{"name": "array"}]},
{"id": "multiply", "parameters": [{"name": "x"}, {"name": "y"}]},
{
"id": "add",
"parameters": [{"name": "x"}, {"name": "y"}],
"backends": ["b1"],
},
{
"id": "mean",
"parameters": [{"name": "array"}],
"backends": ["b1", "b2"],
},
{
"id": "multiply",
"parameters": [{"name": "x"}, {"name": "y"}],
"backends": ["b2"],
},
]
18 changes: 15 additions & 3 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,21 @@ def test_processes_basic(self, api100, requests_mock, backend1, backend2):
res = api100.get("/processes").assert_status_code(200).json
assert res == {
"processes": [
{"id": "multiply", "parameters": [{"name": "x"}, {"name": "y"}]},
{"id": "mean", "parameters": [{"name": "data"}]},
{"id": "add", "parameters": [{"name": "x"}, {"name": "y"}]},
{
"id": "multiply",
"parameters": [{"name": "x"}, {"name": "y"}],
"backends": ["b2"],
},
{
"id": "mean",
"parameters": [{"name": "data"}],
"backends": ["b1", "b2"],
},
{
"id": "add",
"parameters": [{"name": "x"}, {"name": "y"}],
"backends": ["b1"],
},
],
"links": [],
}
Expand Down

0 comments on commit 99fda75

Please sign in to comment.