diff --git a/.gitignore b/.gitignore index d8ac486..fc22f35 100644 --- a/.gitignore +++ b/.gitignore @@ -191,4 +191,7 @@ cython_debug/ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data # refer to https://docs.cursor.com/context/ignore-files .cursorignore -.cursorindexingignore \ No newline at end of file +.cursorindexingignore + + +.vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json index c5e6474..3acec9e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,6 @@ ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, - "python-envs.pythonProjects": [] + "python-envs.defaultEnvManager": "ms-python.python:conda", + "python-envs.defaultPackageManager": "ms-python.python:conda" } \ No newline at end of file diff --git a/app/platforms/implementations/openeo.py b/app/platforms/implementations/openeo.py index 8957b6e..f03bcc6 100644 --- a/app/platforms/implementations/openeo.py +++ b/app/platforms/implementations/openeo.py @@ -286,12 +286,18 @@ def _get_type_from_schemas(self, schemas: List[dict]) -> ParamTypeEnum: subtype = schema.get("subtype") if type == "array" and subtype == "temporal-interval": return ParamTypeEnum.DATE_INTERVAL + elif type == "array" and schema.get("items", {}).get("type") == "string": + return ParamTypeEnum.ARRAY_STRING elif subtype == "bounding-box": return ParamTypeEnum.BOUNDING_BOX + elif subtype == "geojson": + return ParamTypeEnum.POLYGON elif type == "boolean": return ParamTypeEnum.BOOLEAN elif type == "string": return ParamTypeEnum.STRING + elif type == "integer" or type == "number": + return ParamTypeEnum.INTEGER # If no matching schema found, raise an error raise ValueError(f"Unsupported parameter schemas: {schemas}") diff --git a/app/routers/tiles.py b/app/routers/tiles.py index 57fa3b3..623a8ab 100644 --- a/app/routers/tiles.py +++ b/app/routers/tiles.py @@ -107,8 +107,8 @@ def split_in_tiles( raise de except Exception as e: logger.error( - f"An error occurred while calculating tiles for {payload.grid}: {e}" + f"An error occurred while calculating tiles for {payload.grid.value}: {e}" ) raise InternalException( - message=f"An error occurred while calculating tiles for {payload.grid}" + message=f"An error occurred while calculating tiles for {payload.grid.value}" ) diff --git a/app/schemas/parameters.py b/app/schemas/parameters.py index 04e6f46..af9cd73 100644 --- a/app/schemas/parameters.py +++ b/app/schemas/parameters.py @@ -9,8 +9,11 @@ class ParamTypeEnum(str, Enum): DATE_INTERVAL = "date-interval" BOUNDING_BOX = "bounding-box" + POLYGON = "polygon" BOOLEAN = "boolean" + INTEGER = "integer" STRING = "string" + ARRAY_STRING = "array-string" class ParamRequest(BaseModel): diff --git a/tests/platforms/test_openeo_platform.py b/tests/platforms/test_openeo_platform.py index 512af98..e65d96f 100644 --- a/tests/platforms/test_openeo_platform.py +++ b/tests/platforms/test_openeo_platform.py @@ -523,6 +523,11 @@ async def test_get_parameters_success(mock_udp_request, platform): "description": "Test for a boolean flag parameter", "schema": {"type": "boolean"}, }, + { + "name": "polygon_test", + "description": "Test for a polygon parameter", + "schema": {"type": "object", "subtype": "geojson"}, + }, { "name": "bbox_test", "description": "Test for a bbox parameter", @@ -540,6 +545,21 @@ async def test_get_parameters_success(mock_udp_request, platform): "description": "Test for a string parameter", "schema": {"type": "string"}, }, + { + "name": "int_test", + "description": "Test for a integer parameter", + "schema": {"type": "integer"}, + }, + { + "name": "array_string_test", + "description": "Test for an array of strings parameter", + "schema": {"type": "array", "items": {"type": "string"}}, + }, + { + "name": "number_test", + "description": "Test for a number parameter", + "schema": {"type": "number"}, + }, ] mock_udp_request.return_value.json.return_value = { "id": "process123", @@ -563,22 +583,46 @@ async def test_get_parameters_success(mock_udp_request, platform): Parameter( name=udp_params[1]["name"], description=udp_params[1]["description"], - type=ParamTypeEnum.BOUNDING_BOX, + type=ParamTypeEnum.POLYGON, optional=False, ), Parameter( name=udp_params[2]["name"], description=udp_params[2]["description"], - type=ParamTypeEnum.DATE_INTERVAL, - optional=True, - default=udp_params[2]["default"], + type=ParamTypeEnum.BOUNDING_BOX, + optional=False, ), Parameter( name=udp_params[3]["name"], description=udp_params[3]["description"], + type=ParamTypeEnum.DATE_INTERVAL, + optional=True, + default=udp_params[3]["default"], + ), + Parameter( + name=udp_params[4]["name"], + description=udp_params[4]["description"], type=ParamTypeEnum.STRING, optional=False, ), + Parameter( + name=udp_params[5]["name"], + description=udp_params[5]["description"], + type=ParamTypeEnum.INTEGER, + optional=False, + ), + Parameter( + name=udp_params[6]["name"], + description=udp_params[6]["description"], + type=ParamTypeEnum.ARRAY_STRING, + optional=False, + ), + Parameter( + name=udp_params[7]["name"], + description=udp_params[7]["description"], + type=ParamTypeEnum.INTEGER, + optional=False, + ), ] assert result == parameters diff --git a/tests/routers/test_upscale_tasks.py b/tests/routers/test_upscale_tasks.py index 7c5d01a..024306b 100644 --- a/tests/routers/test_upscale_tasks.py +++ b/tests/routers/test_upscale_tasks.py @@ -22,7 +22,7 @@ def test_upscaling_task_create_201( r = client.post("/upscale_tasks", json=fake_upscaling_task_request.model_dump()) assert r.status_code == status.HTTP_201_CREATED assert r.json() == fake_upscaling_task_summary.model_dump() - assert mock_create_processing_jobs.called_once() + mock_create_processing_jobs.assert_called_once() @patch("app.routers.upscale_tasks.create_upscaling_task")