assertions-mate 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/.github/workflows/docs.yaml +5 -5
- assertions_mate-0.2.0/.github/workflows/package.yaml +97 -0
- assertions_mate-0.2.0/PKG-INFO +147 -0
- assertions_mate-0.2.0/README.md +114 -0
- assertions_mate-0.2.0/Taskfile.yaml +32 -0
- assertions_mate-0.2.0/docs/index.md +9 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/docs/jsonschema.ipynb +20 -50
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/docs/pygeofilter.ipynb +23 -34
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/docs/regopy.ipynb +5 -13
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/mkdocs.yaml +18 -4
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/pyproject.toml +31 -3
- assertions_mate-0.2.0/schemas/hints.yaml +86 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/src/assertions_mate/__about__.py +1 -1
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/src/assertions_mate/__init__.py +47 -54
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/src/assertions_mate/cli.py +37 -49
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/src/assertions_mate/cql2_validator.py +13 -33
- assertions_mate-0.2.0/src/assertions_mate/error_models.py +570 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/src/assertions_mate/jsonschema_validator.py +11 -22
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/src/assertions_mate/rego_validator.py +7 -30
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/tests/artifacts/request_body.yaml +14 -0
- assertions_mate-0.2.0/tests/test_cql2_validator.py +51 -0
- assertions_mate-0.2.0/tests/test_hints.py +49 -0
- assertions_mate-0.2.0/tests/test_jsonschema_validator.py +33 -0
- assertions_mate-0.1.0/.github/workflows/package.yaml +0 -74
- assertions_mate-0.1.0/PKG-INFO +0 -38
- assertions_mate-0.1.0/README.md +0 -5
- assertions_mate-0.1.0/docs/index.md +0 -5
- assertions_mate-0.1.0/schemas/hints.yaml +0 -77
- assertions_mate-0.1.0/src/assertions_mate/error_models.py +0 -569
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/.gitignore +0 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/LICENSE +0 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/NOTICE +0 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/docs/diagrams/src/class.puml +0 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/docs/diagrams/src/flow.puml +0 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/docs/diagrams/src/overall.puml +0 -0
- {assertions_mate-0.1.0 → assertions_mate-0.2.0}/docs/diagrams/src/sequence.puml +0 -0
|
@@ -33,11 +33,11 @@ jobs:
|
|
|
33
33
|
- name: Checkout master
|
|
34
34
|
uses: actions/checkout@v4
|
|
35
35
|
|
|
36
|
-
- name: Set up Python 3.
|
|
36
|
+
- name: Set up Python 3.12
|
|
37
37
|
uses: actions/setup-python@v5
|
|
38
38
|
with:
|
|
39
|
-
python-version: 3.
|
|
40
|
-
- run: pip install mkdocs-material mkdocs-mermaid2-plugin mkdocs-jupyter legacy-cgi pdocs
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
python-version: 3.12
|
|
40
|
+
- run: pip install "mkdocs<=2.0.0" mkdocs-material mkdocs-mermaid2-plugin mkdocs-jupyter legacy-cgi pdocs mkdocs-build-plantuml-plugin
|
|
41
|
+
#- run: pip install .
|
|
42
|
+
#- run: pdocs as_markdown --output_dir ./docs/api/latest --exclude_source --overwrite assertions_mate
|
|
43
43
|
- run: mkdocs gh-deploy --force
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Copyright 2026 Terradue
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
name: package
|
|
16
|
+
|
|
17
|
+
on:
|
|
18
|
+
push:
|
|
19
|
+
branches:
|
|
20
|
+
- feature
|
|
21
|
+
- feature/**
|
|
22
|
+
- develop
|
|
23
|
+
- main
|
|
24
|
+
tags:
|
|
25
|
+
- v*.*.*
|
|
26
|
+
pull_request:
|
|
27
|
+
branches:
|
|
28
|
+
- feature
|
|
29
|
+
- feature/**
|
|
30
|
+
- develop
|
|
31
|
+
- main
|
|
32
|
+
|
|
33
|
+
permissions:
|
|
34
|
+
contents: read
|
|
35
|
+
|
|
36
|
+
jobs:
|
|
37
|
+
ci:
|
|
38
|
+
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/')
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
|
|
43
|
+
- name: Set up Python
|
|
44
|
+
uses: actions/setup-python@v5
|
|
45
|
+
with:
|
|
46
|
+
python-version: '3.12'
|
|
47
|
+
cache: pip
|
|
48
|
+
|
|
49
|
+
- name: Install tooling
|
|
50
|
+
run: pip install hatch ruff
|
|
51
|
+
|
|
52
|
+
- name: Ruff Check
|
|
53
|
+
run: ruff check .
|
|
54
|
+
|
|
55
|
+
- name: Ruff Lint
|
|
56
|
+
run: ruff format --check .
|
|
57
|
+
|
|
58
|
+
- name: Run tests
|
|
59
|
+
run: hatch run test:test-q
|
|
60
|
+
|
|
61
|
+
publish:
|
|
62
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
environment: release
|
|
65
|
+
permissions:
|
|
66
|
+
id-token: write
|
|
67
|
+
contents: read
|
|
68
|
+
steps:
|
|
69
|
+
- uses: actions/checkout@v4
|
|
70
|
+
|
|
71
|
+
- name: Set up Python
|
|
72
|
+
uses: actions/setup-python@v5
|
|
73
|
+
with:
|
|
74
|
+
python-version: '3.12'
|
|
75
|
+
cache: pip
|
|
76
|
+
|
|
77
|
+
- name: Install Hatch
|
|
78
|
+
run: pip install hatch
|
|
79
|
+
|
|
80
|
+
- name: Verify tag matches project version
|
|
81
|
+
run: |
|
|
82
|
+
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
|
83
|
+
PROJECT_VERSION="$(hatch version)"
|
|
84
|
+
|
|
85
|
+
echo "Tag version: ${TAG_VERSION}"
|
|
86
|
+
echo "Project version: ${PROJECT_VERSION}"
|
|
87
|
+
|
|
88
|
+
if [ "${TAG_VERSION}" != "${PROJECT_VERSION}" ]; then
|
|
89
|
+
echo "Tag ${GITHUB_REF_NAME} does not match project version ${PROJECT_VERSION}"
|
|
90
|
+
exit 1
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
- name: Build package
|
|
94
|
+
run: hatch build
|
|
95
|
+
|
|
96
|
+
- name: Publish package distributions to PyPI
|
|
97
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: assertions-mate
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Project-URL: Documentation, https://github.com/Terradue/assertions-mate#README.md
|
|
5
|
+
Project-URL: Issues, https://github.com/Terradue/assertions-mate/issues
|
|
6
|
+
Project-URL: Source, https://github.com/Terradue/assertions-mate
|
|
7
|
+
Author-email: Terradue srl <info@terradue.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: click
|
|
22
|
+
Requires-Dist: cwl-utils
|
|
23
|
+
Requires-Dist: cwl2ogc>=0.10.0
|
|
24
|
+
Requires-Dist: jsonschema
|
|
25
|
+
Requires-Dist: loguru
|
|
26
|
+
Requires-Dist: pydantic
|
|
27
|
+
Requires-Dist: pygeofilter
|
|
28
|
+
Requires-Dist: pygeofilter[backend-native]
|
|
29
|
+
Requires-Dist: pystac-client
|
|
30
|
+
Requires-Dist: regopy==0.4.6
|
|
31
|
+
Requires-Dist: shapely
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# Assertions Mate
|
|
35
|
+
|
|
36
|
+
`assertions-mate` validates CWL workflow inputs against assertion hints embedded in the workflow definition.
|
|
37
|
+
|
|
38
|
+
It adds policy and rule checks on top of CWL typing by supporting:
|
|
39
|
+
- JSON Schema validation
|
|
40
|
+
- Rego policy validation (OPA)
|
|
41
|
+
- CQL2 expression validation
|
|
42
|
+
|
|
43
|
+
Documentation site: https://terradue.github.io/assertions-mate/
|
|
44
|
+
|
|
45
|
+
## Why Use It
|
|
46
|
+
|
|
47
|
+
When a CWL workflow needs stricter runtime checks (business rules, policy constraints, geospatial conditions), `assertions-mate` lets you define them as workflow hints and evaluate them against an input payload before execution.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
### From source (recommended for development)
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
git clone https://github.com/Terradue/assertions-mate.git
|
|
55
|
+
cd assertions-mate
|
|
56
|
+
pip install -e .
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Runtime requirements
|
|
60
|
+
|
|
61
|
+
- Python `>= 3.10`
|
|
62
|
+
- Dependencies are managed in `pyproject.toml`
|
|
63
|
+
|
|
64
|
+
## Command Line Usage
|
|
65
|
+
|
|
66
|
+
After installation, run:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
assertions-mate path/to/workflow.cwl --inputs path/to/inputs.yaml
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
What happens:
|
|
73
|
+
1. The CWL document is loaded.
|
|
74
|
+
2. Assertion hints are discovered from `workflow.hints`.
|
|
75
|
+
3. Matching validators are built and executed against the input mapping.
|
|
76
|
+
4. Validation issues are reported with pointer and detail messages.
|
|
77
|
+
|
|
78
|
+
## Supported Assertion Hints
|
|
79
|
+
|
|
80
|
+
The tool maps `eoap:` hint classes to internal validators:
|
|
81
|
+
|
|
82
|
+
- `eoap:JSONSchemaHint`
|
|
83
|
+
- `eoap:RegoPolicyHint`
|
|
84
|
+
- `eoap:Cql2FilterHint`
|
|
85
|
+
|
|
86
|
+
### Example `hints` snippet
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
hints:
|
|
90
|
+
- class: eoap:JSONSchemaHint
|
|
91
|
+
json_schema:
|
|
92
|
+
type: object
|
|
93
|
+
required: [count]
|
|
94
|
+
properties:
|
|
95
|
+
count:
|
|
96
|
+
type: integer
|
|
97
|
+
minimum: 1
|
|
98
|
+
|
|
99
|
+
- class: eoap:RegoPolicyHint
|
|
100
|
+
module: |
|
|
101
|
+
package workflow
|
|
102
|
+
deny contains "count must be <= 10" if {
|
|
103
|
+
input.count > 10
|
|
104
|
+
}
|
|
105
|
+
queries:
|
|
106
|
+
- data.workflow.deny[_]
|
|
107
|
+
|
|
108
|
+
- class: eoap:Cql2FilterHint
|
|
109
|
+
queries:
|
|
110
|
+
- id: cql-rule-1
|
|
111
|
+
cql2: "count > 0"
|
|
112
|
+
message: "count must be greater than zero"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
This project uses Hatch environments and pytest.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Run tests
|
|
121
|
+
hatch run test:test-q
|
|
122
|
+
|
|
123
|
+
# Run formatting check
|
|
124
|
+
hatch run dev:lint
|
|
125
|
+
|
|
126
|
+
# Run lint checks with fixes
|
|
127
|
+
hatch run dev:check
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
If you use Taskfile:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
task test
|
|
134
|
+
task lint
|
|
135
|
+
task check
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Project Layout
|
|
139
|
+
|
|
140
|
+
- `src/assertions_mate/` core package and CLI
|
|
141
|
+
- `tests/` unit tests
|
|
142
|
+
- `schemas/` CWL hint schema definitions
|
|
143
|
+
- `docs/` notebooks and documentation sources
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
Apache License 2.0. See `LICENSE`.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Assertions Mate
|
|
2
|
+
|
|
3
|
+
`assertions-mate` validates CWL workflow inputs against assertion hints embedded in the workflow definition.
|
|
4
|
+
|
|
5
|
+
It adds policy and rule checks on top of CWL typing by supporting:
|
|
6
|
+
- JSON Schema validation
|
|
7
|
+
- Rego policy validation (OPA)
|
|
8
|
+
- CQL2 expression validation
|
|
9
|
+
|
|
10
|
+
Documentation site: https://terradue.github.io/assertions-mate/
|
|
11
|
+
|
|
12
|
+
## Why Use It
|
|
13
|
+
|
|
14
|
+
When a CWL workflow needs stricter runtime checks (business rules, policy constraints, geospatial conditions), `assertions-mate` lets you define them as workflow hints and evaluate them against an input payload before execution.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### From source (recommended for development)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://github.com/Terradue/assertions-mate.git
|
|
22
|
+
cd assertions-mate
|
|
23
|
+
pip install -e .
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Runtime requirements
|
|
27
|
+
|
|
28
|
+
- Python `>= 3.10`
|
|
29
|
+
- Dependencies are managed in `pyproject.toml`
|
|
30
|
+
|
|
31
|
+
## Command Line Usage
|
|
32
|
+
|
|
33
|
+
After installation, run:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
assertions-mate path/to/workflow.cwl --inputs path/to/inputs.yaml
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
What happens:
|
|
40
|
+
1. The CWL document is loaded.
|
|
41
|
+
2. Assertion hints are discovered from `workflow.hints`.
|
|
42
|
+
3. Matching validators are built and executed against the input mapping.
|
|
43
|
+
4. Validation issues are reported with pointer and detail messages.
|
|
44
|
+
|
|
45
|
+
## Supported Assertion Hints
|
|
46
|
+
|
|
47
|
+
The tool maps `eoap:` hint classes to internal validators:
|
|
48
|
+
|
|
49
|
+
- `eoap:JSONSchemaHint`
|
|
50
|
+
- `eoap:RegoPolicyHint`
|
|
51
|
+
- `eoap:Cql2FilterHint`
|
|
52
|
+
|
|
53
|
+
### Example `hints` snippet
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
hints:
|
|
57
|
+
- class: eoap:JSONSchemaHint
|
|
58
|
+
json_schema:
|
|
59
|
+
type: object
|
|
60
|
+
required: [count]
|
|
61
|
+
properties:
|
|
62
|
+
count:
|
|
63
|
+
type: integer
|
|
64
|
+
minimum: 1
|
|
65
|
+
|
|
66
|
+
- class: eoap:RegoPolicyHint
|
|
67
|
+
module: |
|
|
68
|
+
package workflow
|
|
69
|
+
deny contains "count must be <= 10" if {
|
|
70
|
+
input.count > 10
|
|
71
|
+
}
|
|
72
|
+
queries:
|
|
73
|
+
- data.workflow.deny[_]
|
|
74
|
+
|
|
75
|
+
- class: eoap:Cql2FilterHint
|
|
76
|
+
queries:
|
|
77
|
+
- id: cql-rule-1
|
|
78
|
+
cql2: "count > 0"
|
|
79
|
+
message: "count must be greater than zero"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
This project uses Hatch environments and pytest.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Run tests
|
|
88
|
+
hatch run test:test-q
|
|
89
|
+
|
|
90
|
+
# Run formatting check
|
|
91
|
+
hatch run dev:lint
|
|
92
|
+
|
|
93
|
+
# Run lint checks with fixes
|
|
94
|
+
hatch run dev:check
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If you use Taskfile:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
task test
|
|
101
|
+
task lint
|
|
102
|
+
task check
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Project Layout
|
|
106
|
+
|
|
107
|
+
- `src/assertions_mate/` core package and CLI
|
|
108
|
+
- `tests/` unit tests
|
|
109
|
+
- `schemas/` CWL hint schema definitions
|
|
110
|
+
- `docs/` notebooks and documentation sources
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
Apache License 2.0. See `LICENSE`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Copyright 2026 Terradue
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
version: '3'
|
|
16
|
+
|
|
17
|
+
tasks:
|
|
18
|
+
|
|
19
|
+
test:
|
|
20
|
+
desc: Run tests
|
|
21
|
+
cmds:
|
|
22
|
+
- hatch run test:test-show-setup
|
|
23
|
+
|
|
24
|
+
check:
|
|
25
|
+
desc: Run code quality checks
|
|
26
|
+
cmds:
|
|
27
|
+
- hatch run dev:check
|
|
28
|
+
|
|
29
|
+
lint:
|
|
30
|
+
desc: Run linters
|
|
31
|
+
cmds:
|
|
32
|
+
- hatch run dev:lint
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Assertions Framework API
|
|
2
|
+
|
|
3
|
+
This is small Python APIs set that enables different CWL inputs validation layers, such as:
|
|
4
|
+
|
|
5
|
+
- [JSON Schema](https://json-schema.org/);
|
|
6
|
+
- [OPA's policy language (Rego)](https://www.openpolicyagent.org/docs)
|
|
7
|
+
- [Common Query Language (CQL2)](https://www.ogc.org/standards/cql2/).
|
|
8
|
+
|
|
9
|
+
This documentation is Work in Progress
|
|
@@ -18,47 +18,22 @@
|
|
|
18
18
|
"outputs": [],
|
|
19
19
|
"source": [
|
|
20
20
|
"schema = {\n",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
" \"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
" \"properties\": {\n",
|
|
31
|
-
" \"filesA\": {\n",
|
|
32
|
-
" \"$ref\": \"#/$defs/filesA\"\n",
|
|
21
|
+
" \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n",
|
|
22
|
+
" \"$id\": \"https://eoap.github.io/cwl2ogc/array-inputs/inputs.yaml\",\n",
|
|
23
|
+
" \"description\": \"The schema to represent a array-inputs inputs definition\",\n",
|
|
24
|
+
" \"type\": \"object\",\n",
|
|
25
|
+
" \"required\": [\"filesA\", \"filesB\", \"filesC\"],\n",
|
|
26
|
+
" \"properties\": {\n",
|
|
27
|
+
" \"filesA\": {\"$ref\": \"#/$defs/filesA\"},\n",
|
|
28
|
+
" \"filesB\": {\"$ref\": \"#/$defs/filesB\"},\n",
|
|
29
|
+
" \"filesC\": {\"$ref\": \"#/$defs/filesC\"},\n",
|
|
33
30
|
" },\n",
|
|
34
|
-
" \"
|
|
35
|
-
"
|
|
31
|
+
" \"additionalProperties\": False,\n",
|
|
32
|
+
" \"$defs\": {\n",
|
|
33
|
+
" \"filesA\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}},\n",
|
|
34
|
+
" \"filesB\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}},\n",
|
|
35
|
+
" \"filesC\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}},\n",
|
|
36
36
|
" },\n",
|
|
37
|
-
" \"filesC\": {\n",
|
|
38
|
-
" \"$ref\": \"#/$defs/filesC\"\n",
|
|
39
|
-
" }\n",
|
|
40
|
-
" },\n",
|
|
41
|
-
" \"additionalProperties\": False,\n",
|
|
42
|
-
" \"$defs\": {\n",
|
|
43
|
-
" \"filesA\": {\n",
|
|
44
|
-
" \"type\": \"array\",\n",
|
|
45
|
-
" \"items\": {\n",
|
|
46
|
-
" \"type\": \"string\"\n",
|
|
47
|
-
" }\n",
|
|
48
|
-
" },\n",
|
|
49
|
-
" \"filesB\": {\n",
|
|
50
|
-
" \"type\": \"array\",\n",
|
|
51
|
-
" \"items\": {\n",
|
|
52
|
-
" \"type\": \"string\"\n",
|
|
53
|
-
" }\n",
|
|
54
|
-
" },\n",
|
|
55
|
-
" \"filesC\": {\n",
|
|
56
|
-
" \"type\": \"array\",\n",
|
|
57
|
-
" \"items\": {\n",
|
|
58
|
-
" \"type\": \"string\"\n",
|
|
59
|
-
" }\n",
|
|
60
|
-
" }\n",
|
|
61
|
-
" }\n",
|
|
62
37
|
"}"
|
|
63
38
|
]
|
|
64
39
|
},
|
|
@@ -78,13 +53,9 @@
|
|
|
78
53
|
"outputs": [],
|
|
79
54
|
"source": [
|
|
80
55
|
"from assertions_mate.jsonschema_validator import JSONSchemaValidator\n",
|
|
81
|
-
"from assertions_mate.error_models import
|
|
82
|
-
" ErrorDetail,\n",
|
|
83
|
-
" ServerError\n",
|
|
84
|
-
")\n",
|
|
56
|
+
"from assertions_mate.error_models import ErrorDetail, ServerError\n",
|
|
85
57
|
"from jsonschema.exceptions import SchemaError\n",
|
|
86
58
|
"import json\n",
|
|
87
|
-
"import sys\n",
|
|
88
59
|
"\n",
|
|
89
60
|
"validator = None\n",
|
|
90
61
|
"try:\n",
|
|
@@ -92,8 +63,7 @@
|
|
|
92
63
|
"except SchemaError as schema_error:\n",
|
|
93
64
|
" print(\n",
|
|
94
65
|
" json.dumps(\n",
|
|
95
|
-
" ServerError(errors=[ErrorDetail(detail=schema_error.message)])
|
|
96
|
-
" indent=2\n",
|
|
66
|
+
" ServerError(errors=[ErrorDetail(detail=schema_error.message)]), indent=2\n",
|
|
97
67
|
" )\n",
|
|
98
68
|
" )"
|
|
99
69
|
]
|
|
@@ -116,11 +86,11 @@
|
|
|
116
86
|
"inputs = {\n",
|
|
117
87
|
" \"aoi\": \"-118.985,38.432,-118.183,38.938\",\n",
|
|
118
88
|
" \"filesB\": \"EPSG:4326\",\n",
|
|
119
|
-
" \"bands\": [
|
|
89
|
+
" \"bands\": [\"green\", \"nir08\"],\n",
|
|
120
90
|
" \"item\": {\n",
|
|
121
|
-
" \"class\"
|
|
122
|
-
" \"value\"
|
|
123
|
-
" }
|
|
91
|
+
" \"class\": \"https://raw.githubusercontent.com/eoap/schemas/main/url.yaml#URL\",\n",
|
|
92
|
+
" \"value\": \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC08_L2SP_042033_20231007_02_T1\",\n",
|
|
93
|
+
" },\n",
|
|
124
94
|
"}"
|
|
125
95
|
]
|
|
126
96
|
},
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"# 2) Search for two Sentinel-2 L2A items (Rome area, low clouds, example dates)\n",
|
|
38
38
|
"search = client.search(\n",
|
|
39
39
|
" collections=[\"sentinel-2-l2a\"],\n",
|
|
40
|
-
" bbox=[12.3, 41.7, 12.7, 42.0],
|
|
41
|
-
" datetime=\"2024-06-01/2024-06-30\",
|
|
40
|
+
" bbox=[12.3, 41.7, 12.7, 42.0], # Rome area\n",
|
|
41
|
+
" datetime=\"2024-06-01/2024-06-30\", # any window with data works\n",
|
|
42
42
|
" query={\"eo:cloud_cover\": {\"lt\": 30}},\n",
|
|
43
|
-
" max_items=2
|
|
43
|
+
" max_items=2,\n",
|
|
44
44
|
")\n",
|
|
45
45
|
"\n",
|
|
46
46
|
"# 3) Get PySTAC Items (already parsed objects)\n",
|
|
@@ -49,14 +49,11 @@
|
|
|
49
49
|
"print(f\"Fetched {len(items)} items\")\n",
|
|
50
50
|
"\n",
|
|
51
51
|
"request_body = {\n",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
" 'bbox': [12.3, 41.7, 12.7, 42.0]\n",
|
|
58
|
-
" },\n",
|
|
59
|
-
" 'aoi2': '12.3, 41.7, 12.7, 42.0'\n",
|
|
52
|
+
" \"inputs\": {\n",
|
|
53
|
+
" \"item_1\": items[0].to_dict(),\n",
|
|
54
|
+
" \"item_2\": items[1].to_dict(),\n",
|
|
55
|
+
" \"aoi\": {\"crs\": \"CRS84\", \"bbox\": [12.3, 41.7, 12.7, 42.0]},\n",
|
|
56
|
+
" \"aoi2\": \"12.3, 41.7, 12.7, 42.0\",\n",
|
|
60
57
|
" }\n",
|
|
61
58
|
"}"
|
|
62
59
|
]
|
|
@@ -78,12 +75,7 @@
|
|
|
78
75
|
"source": [
|
|
79
76
|
"import json\n",
|
|
80
77
|
"\n",
|
|
81
|
-
"print(
|
|
82
|
-
" json.dumps(\n",
|
|
83
|
-
" request_body,\n",
|
|
84
|
-
" indent=2\n",
|
|
85
|
-
" )\n",
|
|
86
|
-
")"
|
|
78
|
+
"print(json.dumps(request_body, indent=2))"
|
|
87
79
|
]
|
|
88
80
|
},
|
|
89
81
|
{
|
|
@@ -104,33 +96,30 @@
|
|
|
104
96
|
"metadata": {},
|
|
105
97
|
"outputs": [],
|
|
106
98
|
"source": [
|
|
107
|
-
"from assertions_mate import
|
|
108
|
-
" Cql2FilterHint,\n",
|
|
109
|
-
" Cql2Query\n",
|
|
110
|
-
")\n",
|
|
99
|
+
"from assertions_mate import Cql2FilterHint, Cql2Query\n",
|
|
111
100
|
"\n",
|
|
112
101
|
"filter = Cql2FilterHint(\n",
|
|
113
102
|
" queries=[\n",
|
|
114
103
|
" Cql2Query(\n",
|
|
115
|
-
" id
|
|
116
|
-
" cql2
|
|
117
|
-
" message
|
|
104
|
+
" id=\"Items platforms are the same\",\n",
|
|
105
|
+
" cql2=\"inputs.item_1.properties.platform = inputs.item_2.properties.platform\",\n",
|
|
106
|
+
" message=\"It is expected that all items are part of the same platform\",\n",
|
|
118
107
|
" ),\n",
|
|
119
108
|
" Cql2Query(\n",
|
|
120
|
-
" id
|
|
121
|
-
" cql2
|
|
122
|
-
" message
|
|
109
|
+
" id=\"First item intersects AOI\",\n",
|
|
110
|
+
" cql2=\"s_intersects(inputs.item_1, ensure_bbox(inputs.aoi))\",\n",
|
|
111
|
+
" message=\"First item expected to intersect the AOI\",\n",
|
|
123
112
|
" ),\n",
|
|
124
113
|
" Cql2Query(\n",
|
|
125
|
-
" id
|
|
126
|
-
" cql2
|
|
127
|
-
" message
|
|
114
|
+
" id=\"Second item intersects AOI\",\n",
|
|
115
|
+
" cql2=\"s_intersects(inputs.item_2, ensure_bbox(inputs.aoi2))\",\n",
|
|
116
|
+
" message=\"Second item expected to intersect the AOI\",\n",
|
|
128
117
|
" ),\n",
|
|
129
118
|
" Cql2Query(\n",
|
|
130
|
-
" id
|
|
131
|
-
" cql2
|
|
132
|
-
" message
|
|
133
|
-
" )
|
|
119
|
+
" id=\"Items intersects each other\",\n",
|
|
120
|
+
" cql2=\"s_intersects(inputs.item_1, ensure_spatial(inputs.item_2))\",\n",
|
|
121
|
+
" message=\"Items do not intesect each other\",\n",
|
|
122
|
+
" ),\n",
|
|
134
123
|
" ]\n",
|
|
135
124
|
")"
|
|
136
125
|
]
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"metadata": {},
|
|
18
18
|
"outputs": [],
|
|
19
19
|
"source": [
|
|
20
|
-
"module =
|
|
20
|
+
"module = \"\"\"\n",
|
|
21
21
|
"package workflow\n",
|
|
22
22
|
"\n",
|
|
23
23
|
"# --- BBOX sanity checks ---\n",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"# helper predicate for the allowed second band (disjunction via multiple rules)\n",
|
|
56
56
|
"allowed_nir(x) { x == \"nir\" }\n",
|
|
57
57
|
"allowed_nir(x) { x == \"nir08\" }\n",
|
|
58
|
-
"
|
|
58
|
+
"\"\"\"\n",
|
|
59
59
|
"\n",
|
|
60
60
|
"# List the deny queries you want to collect messages from\n",
|
|
61
61
|
"deny_queries = [\n",
|
|
@@ -114,18 +114,10 @@
|
|
|
114
114
|
"outputs": [],
|
|
115
115
|
"source": [
|
|
116
116
|
"inputs = {\n",
|
|
117
|
-
" \"aoi\": {\n",
|
|
118
|
-
" \"bbox\": [\n",
|
|
119
|
-
" -1181.985,\n",
|
|
120
|
-
" 38.432,\n",
|
|
121
|
-
" -118.183,\n",
|
|
122
|
-
" 38.938\n",
|
|
123
|
-
" ],\n",
|
|
124
|
-
" \"crs\": \"CRS84\"\n",
|
|
125
|
-
" },\n",
|
|
117
|
+
" \"aoi\": {\"bbox\": [-1181.985, 38.432, -118.183, 38.938], \"crs\": \"CRS84\"},\n",
|
|
126
118
|
" \"filesB\": \"EPSG:4326\",\n",
|
|
127
|
-
" \"bands\": [
|
|
128
|
-
" \"item\": \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC08_L2SP_042033_20231007_02_T1\"
|
|
119
|
+
" \"bands\": [\"green\", \"nir089\"],\n",
|
|
120
|
+
" \"item\": \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC08_L2SP_042033_20231007_02_T1\",\n",
|
|
129
121
|
"}"
|
|
130
122
|
]
|
|
131
123
|
},
|