diff --git a/src/openeo_test_suite/lib/compliance_util.py b/src/openeo_test_suite/lib/compliance_util.py index 765dd52..f0b21e1 100644 --- a/src/openeo_test_suite/lib/compliance_util.py +++ b/src/openeo_test_suite/lib/compliance_util.py @@ -274,7 +274,7 @@ def _guess_root(): def get_examples_path(): return ( - _guess_root().parents[2] + _guess_root().parents[1] / "src" / "openeo_test_suite" / "tests" @@ -287,14 +287,14 @@ def get_spec_path(): return _guess_root() / "openapi.yaml" -def load_payloads_from_directory(directory_path: str) -> Iterator[str]: +def load_payloads_from_directory(directory_path: str) -> Iterator[dict]: for filename in pathlib.Path(directory_path).glob("*.json"): file_path = os.path.join(directory_path, filename) with open(file_path, "r") as file: try: # Load the JSON data from the file data = json.load(file) - yield json.dumps(data) + yield data except json.JSONDecodeError: _log.error(f"Error decoding JSON in file: {filename}") except Exception as e: @@ -309,7 +309,7 @@ def set_uuid_in_job(json_data): # Set the 'id' field to the generated UUID json_data["process"]["id"] = new_id # Return the modified JSON object - return new_id, json.dumps(json_data) + return new_id, json_data def delete_id_resource( @@ -336,18 +336,19 @@ def put_process_graphs(base_url: str, bearer_token: str): # TODO id and so fort try: for payload in payloads: - id = str(uuid.uuid4().hex) + id, payload = set_uuid_in_udp(payload) created_udp_ids.append(id) - requests.put( - f"{base_url}/process_graphs/{id}", + response = requests.put( + f"{base_url}process_graphs/{id}", data=payload, headers={ "Content-Type": "application/json", "Authorization": f"{bearer_token}", }, ) + print(response) except Exception as e: - print(f"Failed to create process graph: {e}") + _log.error(f"Failed to create process graph: {e}") return created_udp_ids @@ -380,7 +381,7 @@ def post_jobs(base_url: str, bearer_token: str): response = requests.post( full_endpoint_url, - data=payload, + data=json.dumps(payload), headers={ "Content-Type": "application/json", "Authorization": f"{bearer_token}", diff --git a/src/openeo_test_suite/tests/general/payload_examples/patch_jobs/patch_jobs_1.json b/src/openeo_test_suite/tests/general/payload_examples/patch_jobs/patch_jobs_1.json index 8cf67f5..37b13d5 100644 --- a/src/openeo_test_suite/tests/general/payload_examples/patch_jobs/patch_jobs_1.json +++ b/src/openeo_test_suite/tests/general/payload_examples/patch_jobs/patch_jobs_1.json @@ -1,292 +1,41 @@ { - "title": "NDVI based on Sentinel 2", - "description": "Deriving minimum NDVI measurements over pixel time series of Sentinel 2", - "process": { - "id": "ndvi", - "summary": "string", - "description": "string", - "parameters": [ - { - "schema": { - "subtype": "string", - "deprecated": false, - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com", - "type": "array", - "pattern": "/regex/", - "enum": [ - null - ], - "minimum": 0, - "maximum": 0, - "minItems": 0, - "maxItems": 0, - "items": [ - {} - ], - "property1": null, - "property2": null - }, - "name": "string", - "description": "string", - "optional": false, - "deprecated": false, - "experimental": false, - "default": null - } - ], - "returns": { - "description": "string", - "schema": { - "subtype": "string", - "deprecated": false, - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com", - "type": "array", - "pattern": "/regex/", - "enum": [ - null - ], - "minimum": 0, - "maximum": 0, - "minItems": 0, - "maxItems": 0, - "items": [ - {} - ], - "property1": null, - "property2": null - } - }, - "categories": [ - "string" - ], - "deprecated": false, - "experimental": false, - "exceptions": { - "Error Code1": { - "description": "string", - "message": "The value specified for the process argument '{argument}' in process '{process}' is invalid: {reason}", - "http": 400 - }, - "Error Code2": { - "description": "string", - "message": "The value specified for the process argument '{argument}' in process '{process}' is invalid: {reason}", - "http": 400 - } - }, - "examples": [ - { - "title": "string", - "description": "string", - "arguments": { - "property1": { - "from_parameter": null, - "from_node": null, - "process_graph": null - }, - "property2": { - "from_parameter": null, - "from_node": null, - "process_graph": null - } - }, - "returns": null - } - ], - "links": [ - { - "rel": "related", - "href": "https://openeo.example", - "type": "text/html", - "title": "openEO" - } - ], - "process_graph": { - "dc": { - "process_id": "load_collection", - "arguments": { - "id": "Sentinel-2", - "spatial_extent": { - "west": 16.1, - "east": 16.6, - "north": 48.6, - "south": 47.2 - }, - "temporal_extent": [ - "2018-01-01", - "2018-02-01" - ] - } - }, - "bands": { - "process_id": "filter_bands", - "description": "Filter and order the bands. The order is important for the following reduce operation.", - "arguments": { - "data": { - "from_node": "dc" - }, - "bands": [ - "B08", - "B04", - "B02" - ] - } - }, - "evi": { - "process_id": "reduce", - "description": "Compute the EVI. Formula: 2.5 * (NIR - RED) / (1 + NIR + 6*RED + -7.5*BLUE)", - "arguments": { - "data": { - "from_node": "bands" - }, - "dimension": "bands", - "reducer": { - "process_graph": { - "nir": { - "process_id": "array_element", - "arguments": { - "data": { - "from_parameter": "data" - }, - "index": 0 - } - }, - "red": { - "process_id": "array_element", - "arguments": { - "data": { - "from_parameter": "data" - }, - "index": 1 - } - }, - "blue": { - "process_id": "array_element", - "arguments": { - "data": { - "from_parameter": "data" - }, - "index": 2 - } - }, - "sub": { - "process_id": "subtract", - "arguments": { - "data": [ - { - "from_node": "nir" - }, - { - "from_node": "red" - } - ] - } - }, - "p1": { - "process_id": "product", - "arguments": { - "data": [ - 6, - { - "from_node": "red" - } - ] - } - }, - "p2": { - "process_id": "product", - "arguments": { - "data": [ - -7.5, - { - "from_node": "blue" - } - ] - } - }, - "sum": { - "process_id": "sum", - "arguments": { - "data": [ - 1, - { - "from_node": "nir" - }, - { - "from_node": "p1" - }, - { - "from_node": "p2" - } - ] - } - }, - "div": { - "process_id": "divide", - "arguments": { - "data": [ - { - "from_node": "sub" - }, - { - "from_node": "sum" - } - ] - } - }, - "p3": { - "process_id": "product", - "arguments": { - "data": [ - 2.5, - { - "from_node": "div" - } - ] - }, - "result": true - } - } - } - } - }, - "mintime": { - "process_id": "reduce", - "description": "Compute a minimum time composite by reducing the temporal dimension", - "arguments": { - "data": { - "from_node": "evi" - }, - "dimension": "temporal", - "reducer": { - "process_graph": { - "min": { - "process_id": "min", - "arguments": { - "data": { - "from_parameter": "data" - } - }, - "result": true - } - } - } - } - }, - "save": { - "process_id": "save_result", - "arguments": { - "data": { - "from_node": "mintime" - }, - "format": "GTiff" - }, - "result": true - } - } - }, - "plan": "free", - "budget": 100, - "log_level": "warning" -} + "title": "Custom Test Process", + "description": "Loads and Saves austrian ground motion data", + "process": { + "process_graph": { + "load1": { + "process_id": "load_collection", + "arguments": { + "bands": [ + "B01" + ], + "properties": {}, + "id": "CGLS_SSM_1KM", + "spatial_extent": { + "west": 16.186110851391813, + "east": 16.576456845030226, + "south": 48.08764096726651, + "north": 48.29291292355549 + }, + "temporal_extent": [ + "2020-01-01T00:00:00Z", + "2020-12-13T00:00:00Z" + ] + } + }, + "save2": { + "process_id": "save_result", + "arguments": { + "data": { + "from_node": "load1" + }, + "format": "NETCDF" + }, + "result": true + } + }, + "parameters": [] + }, + "plan": "free", + "budget": 100 + } diff --git a/src/openeo_test_suite/tests/general/payload_examples/post_result/post_result_1.json b/src/openeo_test_suite/tests/general/payload_examples/post_result/post_result_1.json index 40c6c24..b4580b5 100644 --- a/src/openeo_test_suite/tests/general/payload_examples/post_result/post_result_1.json +++ b/src/openeo_test_suite/tests/general/payload_examples/post_result/post_result_1.json @@ -1,292 +1,39 @@ { - "process": { - "id": "ndvi", - "summary": "string", - "description": "string", - "parameters": [ - { - "schema": { - "subtype": "string", - "deprecated": false, - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com", - "type": "array", - "pattern": "/regex/", - "enum": [ - null - ], - "minimum": 0, - "maximum": 0, - "minItems": 0, - "maxItems": 0, - "items": [ - {} - ], - "property1": null, - "property2": null - }, - "name": "string", - "description": "string", - "optional": false, - "deprecated": false, - "experimental": false, - "default": null - } - ], - "returns": { - "description": "string", - "schema": { - "subtype": "string", - "deprecated": false, - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com", - "type": "array", - "pattern": "/regex/", - "enum": [ - null - ], - "minimum": 0, - "maximum": 0, - "minItems": 0, - "maxItems": 0, - "items": [ - {} - ], - "property1": null, - "property2": null - } - }, - "categories": [ - "string" - ], - "deprecated": false, - "experimental": false, - "exceptions": { - "Error Code1": { - "description": "string", - "message": "The value specified for the process argument '{argument}' in process '{process}' is invalid: {reason}", - "http": 400 - }, - "Error Code2": { - "description": "string", - "message": "The value specified for the process argument '{argument}' in process '{process}' is invalid: {reason}", - "http": 400 - } - }, - "examples": [ - { - "title": "string", - "description": "string", - "arguments": { - "property1": { - "from_parameter": null, - "from_node": null, - "process_graph": null - }, - "property2": { - "from_parameter": null, - "from_node": null, - "process_graph": null - } - }, - "returns": null - } - ], - "links": [ - { - "rel": "related", - "href": "https://openeo.example", - "type": "text/html", - "title": "openEO" - } - ], - "process_graph": { - "dc": { - "process_id": "load_collection", - "arguments": { - "id": "Sentinel-2", - "spatial_extent": { - "west": 16.1, - "east": 16.6, - "north": 48.6, - "south": 47.2 - }, - "temporal_extent": [ - "2018-01-01", - "2018-02-01" - ] - } - }, - "bands": { - "process_id": "filter_bands", - "description": "Filter and order the bands. The order is important for the following reduce operation.", - "arguments": { - "data": { - "from_node": "dc" - }, - "bands": [ - "B08", - "B04", - "B02" - ] - } - }, - "evi": { - "process_id": "reduce", - "description": "Compute the EVI. Formula: 2.5 * (NIR - RED) / (1 + NIR + 6*RED + -7.5*BLUE)", - "arguments": { - "data": { - "from_node": "bands" - }, - "dimension": "bands", - "reducer": { - "process_graph": { - "nir": { - "process_id": "array_element", - "arguments": { - "data": { - "from_parameter": "data" - }, - "index": 0 - } - }, - "red": { - "process_id": "array_element", - "arguments": { - "data": { - "from_parameter": "data" - }, - "index": 1 - } - }, - "blue": { - "process_id": "array_element", - "arguments": { - "data": { - "from_parameter": "data" - }, - "index": 2 - } - }, - "sub": { - "process_id": "subtract", - "arguments": { - "data": [ - { - "from_node": "nir" - }, - { - "from_node": "red" - } - ] - } - }, - "p1": { - "process_id": "product", - "arguments": { - "data": [ - 6, - { - "from_node": "red" - } - ] - } - }, - "p2": { - "process_id": "product", - "arguments": { - "data": [ - -7.5, - { - "from_node": "blue" - } - ] - } - }, - "sum": { - "process_id": "sum", - "arguments": { - "data": [ - 1, - { - "from_node": "nir" - }, - { - "from_node": "p1" - }, - { - "from_node": "p2" - } - ] - } - }, - "div": { - "process_id": "divide", - "arguments": { - "data": [ - { - "from_node": "sub" - }, - { - "from_node": "sum" - } - ] - } - }, - "p3": { - "process_id": "product", - "arguments": { - "data": [ - 2.5, - { - "from_node": "div" - } - ] - }, - "result": true - } - } - } - } - }, - "mintime": { - "process_id": "reduce", - "description": "Compute a minimum time composite by reducing the temporal dimension", - "arguments": { - "data": { - "from_node": "evi" - }, - "dimension": "temporal", - "reducer": { - "process_graph": { - "min": { - "process_id": "min", - "arguments": { - "data": { - "from_parameter": "data" - } - }, - "result": true - } - } - } - } - }, - "save": { - "process_id": "save_result", - "arguments": { - "data": { - "from_node": "mintime" - }, - "format": "GTiff" - }, - "result": true - } - } - }, - "budget": 100, - "plan": "free", - "log_level": "warning", - "property1": null, - "property2": null -} + "process": { + "process_graph": { + "load1": { + "process_id": "load_collection", + "arguments": { + "bands": [ + "B01" + ], + "properties": {}, + "id": "CGLS_SSM_1KM", + "spatial_extent": { + "west": 16.186110851391813, + "east": 16.576456845030226, + "south": 48.08764096726651, + "north": 48.29291292355549 + }, + "temporal_extent": [ + "2020-01-01T00:00:00Z", + "2020-12-13T00:00:00Z" + ] + } + }, + "save2": { + "process_id": "save_result", + "arguments": { + "data": { + "from_node": "load1" + }, + "format": "NETCDF" + }, + "result": true + } + }, + "parameters": [] + }, + "plan": "free", + "budget": 100 + } diff --git a/src/openeo_test_suite/tests/general/payload_examples/put_process_graphs/put_process_graphs_1.json b/src/openeo_test_suite/tests/general/payload_examples/put_process_graphs/put_process_graphs_1.json index 56c90a3..ebcabe1 100644 --- a/src/openeo_test_suite/tests/general/payload_examples/put_process_graphs/put_process_graphs_1.json +++ b/src/openeo_test_suite/tests/general/payload_examples/put_process_graphs/put_process_graphs_1.json @@ -1,103 +1,11 @@ { - "id": "evi", - "summary": "Enhanced Vegetation Index", - "description": "Computes the Enhanced Vegetation Index (EVI). It is computed with the following formula: `2.5 * (NIR - RED) / (1 + NIR + 6*RED + -7.5*BLUE)`.", - "parameters": [ - { - "name": "red", - "description": "Value from the red band.", - "schema": { - "type": "number" - } - }, - { - "name": "blue", - "description": "Value from the blue band.", - "schema": { - "type": "number" - } - }, - { - "name": "nir", - "description": "Value from the near infrared band.", - "schema": { - "type": "number" - } - } - ], - "returns": { - "description": "Computed EVI.", - "schema": { - "type": "number" - } - }, "process_graph": { - "sub": { - "process_id": "subtract", - "arguments": { - "x": { - "from_parameter": "nir" - }, - "y": { - "from_parameter": "red" - } - } - }, - "p1": { - "process_id": "multiply", - "arguments": { - "x": 6, - "y": { - "from_parameter": "red" - } - } - }, - "p2": { - "process_id": "multiply", - "arguments": { - "x": -7.5, - "y": { - "from_parameter": "blue" - } - } - }, - "sum": { - "process_id": "sum", - "arguments": { - "data": [ - 1, - { - "from_parameter": "nir" - }, - { - "from_node": "p1" - }, - { - "from_node": "p2" - } - ] - } - }, - "div": { - "process_id": "divide", - "arguments": { - "x": { - "from_node": "sub" - }, - "y": { - "from_node": "sum" - } - } - }, - "p3": { - "process_id": "multiply", - "arguments": { - "x": 2.5, - "y": { - "from_node": "div" - } - }, + "absolute2": { + "process_id": "absolute", + "arguments": {}, "result": true } - } -} + }, + "parameters": [], + "id": "test123" +} \ No newline at end of file diff --git a/src/openeo_test_suite/tests/general/test_compliance.py b/src/openeo_test_suite/tests/general/test_compliance.py index d43e113..dc0d102 100644 --- a/src/openeo_test_suite/tests/general/test_compliance.py +++ b/src/openeo_test_suite/tests/general/test_compliance.py @@ -498,7 +498,10 @@ def test_POST_jobs(base_url: str, spec: Spec, bearer_token: str): ) fail_log += fail_log_entry - created_batch_job_ids.append(response.headers["OpenEO-Identifier"]) + if "OpenEO-Identifier" in response.headers: + created_batch_job_ids.append(response.headers["OpenEO-Identifier"]) + else: + fail_log += "No OpenEO-Identifier in response headers, job id not found" # CLEANUP conformance_util.delete_id_resource( @@ -578,6 +581,7 @@ def test_PATCH_jobs_job_id(base_url: str, spec: Spec, bearer_token: str): # TESTING for job_id, payload in zip(created_batch_job_ids, payloads): + _, payload = conformance_util.set_uuid_in_job(payload) prepared_endpoint_path = f"{endpoint_path}/{job_id}" fail_log += conformance_util.test_endpoint( base_url=base_url, @@ -753,7 +757,7 @@ def test_DELETE_jobs_job_id_results(base_url: str, spec: Spec, bearer_token: str base_url=base_url, bearer_token=bearer_token, job_ids=created_batch_job_ids, - job_statuses=["queued", "running"], + job_statuses=["running"], timeout=120, ) @@ -1284,11 +1288,11 @@ def test_empty_PUT_process_graphs_process_id( directory_path = conformance_util.get_examples_path() examples_directory = "empty_payload" - payload = next( + payload = list( conformance_util.load_payloads_from_directory( - directory_path=f"{directory_path}/{examples_directory}" + directory_path=directory_path / examples_directory ) - ) + )[0] # TESTING @@ -1307,6 +1311,13 @@ def test_empty_PUT_process_graphs_process_id( # CLEANUP + conformance_util.delete_id_resource( + base_url=base_url, + endpoint_path=endpoint_path, + bearer_token=bearer_token, + ids=[id], + ) + assert fail_log == ""