-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
88 additions
and
49 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
algorithm_catalog/worldcereal.json → algorithm_catalog/worldcereal_inference.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
# TODO: Flatten apex_algorithm_qa_tools to a single module and push as much functionality to https://github.com/ESA-APEx/esa-apex-toolbox-python | ||
|
||
|
||
__version__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from pathlib import Path | ||
from typing import Iterator | ||
|
||
# TODO: Flatten apex_algorithm_qa_tools to a single module and push as much functionality to https://github.com/ESA-APEx/esa-apex-toolbox-python | ||
|
||
|
||
_log = logging.getLogger(__name__) | ||
|
||
|
||
def get_project_root() -> Path: | ||
"""Try to find project root for common project use cases.""" | ||
|
||
def candidates() -> Iterator[Path]: | ||
# TODO: support a environment variable to override the project root detection? | ||
# Running from project root? | ||
yield Path.cwd() | ||
|
||
# Running from qa/tools, qa/benchmarks, qa/unittests? | ||
yield Path.cwd().parent.parent | ||
|
||
# Search from current file | ||
yield Path(__file__).parent.parent.parent.parent | ||
|
||
for candidate in candidates(): | ||
if candidate.is_dir() and all( | ||
(candidate / p).is_dir() | ||
for p in ["algorithm_catalog", "algorithm_invocations", "qa/tools"] | ||
): | ||
_log.info(f"Detected project root {candidate!r}") | ||
return candidate | ||
|
||
raise RuntimeError("Could not determine algorithm invocations root directory.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
|
||
import pytest | ||
from apex_algorithm_qa_tools.common import get_project_root | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"path", list((get_project_root() / "algorithm_catalog").glob("**/*.json")) | ||
) | ||
def test_lint_algorithm_catalog_json_file(path): | ||
data = json.loads(path.read_text()) | ||
|
||
assert data["id"] == path.stem | ||
assert data["type"] == "Feature" | ||
assert ( | ||
"http://www.opengis.net/spec/ogcapi-records-1/1.0/req/record-core" | ||
in data["conformsTo"] | ||
) | ||
|
||
assert data["properties"]["type"] == "apex_algorithm" | ||
|
||
assert "udp" in {k["rel"] for k in data["links"]} | ||
# TODO more checks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from apex_algorithm_qa_tools.common import get_project_root | ||
|
||
|
||
def test_get_project_root(): | ||
assert get_project_root().is_dir() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import json | ||
|
||
import pytest | ||
from apex_algorithm_qa_tools.common import get_project_root | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"path", list((get_project_root() / "openeo_udp").glob("**/*.json")) | ||
) | ||
def test_lint_openeo_udp_json_file(path): | ||
data = json.loads(path.read_text()) | ||
|
||
assert data["id"] == path.stem | ||
assert "description" in data | ||
assert "parameters" in data | ||
assert "process_graph" in data | ||
# TODO more checks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters