From 91dc3b55ed73e39b46fcb1290760b50a249e03f4 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 19 Jan 2026 15:25:38 +0100 Subject: [PATCH 1/2] fix(edgeAttribute): adding edge_attribute schema, blueprint for Edged curves --- opengeodeweb_back_schemas.json | 18 +++++++++++ .../geode_objects/geode_graph.py | 3 ++ .../routes/blueprint_routes.py | 24 ++++++++++++++- .../routes/schemas/__init__.py | 1 + .../routes/schemas/edge_attribute_names.json | 17 +++++++++++ .../routes/schemas/edge_attribute_names.py | 10 +++++++ tests/test_routes.py | 30 +++++++++++++++++++ 7 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/opengeodeweb_back/routes/schemas/edge_attribute_names.json create mode 100644 src/opengeodeweb_back/routes/schemas/edge_attribute_names.py diff --git a/opengeodeweb_back_schemas.json b/opengeodeweb_back_schemas.json index 50408514..dbd4673f 100644 --- a/opengeodeweb_back_schemas.json +++ b/opengeodeweb_back_schemas.json @@ -334,6 +334,24 @@ ], "additionalProperties": false }, + "edge_attribute_names": { + "$id": "opengeodeweb_back/edge_attribute_names", + "route": "/edge_attribute_names", + "methods": [ + "POST" + ], + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "id" + ], + "additionalProperties": false + }, "cell_attribute_names": { "$id": "opengeodeweb_back/cell_attribute_names", "route": "/cell_attribute_names", diff --git a/src/opengeodeweb_back/geode_objects/geode_graph.py b/src/opengeodeweb_back/geode_objects/geode_graph.py index 7c79f1c6..15f6e67a 100644 --- a/src/opengeodeweb_back/geode_objects/geode_graph.py +++ b/src/opengeodeweb_back/geode_objects/geode_graph.py @@ -72,3 +72,6 @@ def save_light_viewable(self, filename_without_extension: str) -> str: def inspect(self) -> object: return None + + def edge_attribute_manager(self) -> og.AttributeManager: + return self.graph.edge_attribute_manager() diff --git a/src/opengeodeweb_back/routes/blueprint_routes.py b/src/opengeodeweb_back/routes/blueprint_routes.py index 9ee41869..570ef419 100644 --- a/src/opengeodeweb_back/routes/blueprint_routes.py +++ b/src/opengeodeweb_back/routes/blueprint_routes.py @@ -23,6 +23,7 @@ from opengeodeweb_back.geode_objects import geode_objects from opengeodeweb_back.geode_objects.types import geode_object_type from opengeodeweb_back.geode_objects.geode_mesh import GeodeMesh +from opengeodeweb_back.geode_objects.geode_graph import GeodeGraph from opengeodeweb_back.geode_objects.geode_grid2d import GeodeGrid2D from opengeodeweb_back.geode_objects.geode_grid3d import GeodeGrid3D from opengeodeweb_back.geode_objects.geode_surface_mesh2d import GeodeSurfaceMesh2D @@ -292,7 +293,7 @@ def cell_attribute_names() -> flask.Response: json_data = utils_functions.validate_request( flask.request, schemas_dict["cell_attribute_names"] ) - params = schemas.PolygonAttributeNames.from_dict(json_data) + params = schemas.CellAttributeNames.from_dict(json_data) geode_object = geode_functions.load_geode_object(params.id) if not isinstance(geode_object, GeodeGrid2D | GeodeGrid3D): flask.abort(400, f"{params.id} is not a GeodeGrid") @@ -349,6 +350,27 @@ def polyhedron_attribute_names() -> flask.Response: ) +@routes.route( + schemas_dict["edge_attribute_names"]["route"], + methods=schemas_dict["edge_attribute_names"]["methods"], +) +def edge_attribute_names() -> flask.Response: + json_data = utils_functions.validate_request( + flask.request, schemas_dict["edge_attribute_names"] + ) + params = schemas.EdgeAttributeNames.from_dict(json_data) + geode_object = geode_functions.load_geode_object(params.id) + if not isinstance(geode_object, GeodeGraph): + flask.abort(400, f"{params.id} does not have edges") + edge_attribute_names = geode_object.edge_attribute_manager().attribute_names() + return flask.make_response( + { + "edge_attribute_names": edge_attribute_names, + }, + 200, + ) + + @routes.route( schemas_dict["ping"]["route"], methods=schemas_dict["ping"]["methods"], diff --git a/src/opengeodeweb_back/routes/schemas/__init__.py b/src/opengeodeweb_back/routes/schemas/__init__.py index 5d37ca18..763f0a24 100644 --- a/src/opengeodeweb_back/routes/schemas/__init__.py +++ b/src/opengeodeweb_back/routes/schemas/__init__.py @@ -13,6 +13,7 @@ from .geographic_coordinate_systems import * from .geode_objects_and_output_extensions import * from .export_project import * +from .edge_attribute_names import * from .cell_attribute_names import * from .allowed_objects import * from .allowed_files import * diff --git a/src/opengeodeweb_back/routes/schemas/edge_attribute_names.json b/src/opengeodeweb_back/routes/schemas/edge_attribute_names.json new file mode 100644 index 00000000..1caac1bb --- /dev/null +++ b/src/opengeodeweb_back/routes/schemas/edge_attribute_names.json @@ -0,0 +1,17 @@ +{ + "route": "/edge_attribute_names", + "methods": [ + "POST" + ], + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "id" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/src/opengeodeweb_back/routes/schemas/edge_attribute_names.py b/src/opengeodeweb_back/routes/schemas/edge_attribute_names.py new file mode 100644 index 00000000..92c039a5 --- /dev/null +++ b/src/opengeodeweb_back/routes/schemas/edge_attribute_names.py @@ -0,0 +1,10 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class EdgeAttributeNames(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str diff --git a/tests/test_routes.py b/tests/test_routes.py index 69c42c9f..c41c8a0c 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -19,6 +19,9 @@ from opengeodeweb_back.geode_objects.geode_regular_grid2d import ( GeodeRegularGrid2D, ) +from opengeodeweb_back.geode_objects.geode_edged_curve3d import ( + GeodeEdgedCurve3D, +) base_dir = os.path.abspath(os.path.dirname(__file__)) data_dir = os.path.join(base_dir, "data") @@ -320,6 +323,33 @@ def test_polyhedron_attribute_names(client: FlaskClient, test_id: str) -> None: assert type(polyhedron_attribute_name) is str +def test_edge_attribute_names(client: FlaskClient, test_id: str) -> None: + route = f"/opengeodeweb_back/edge_attribute_names" + + with client.application.app_context(): + file = os.path.join(data_dir, "test.og_edc3d") + data = Data.create( + geode_object=GeodeEdgedCurve3D.geode_object_type(), + viewer_object=GeodeEdgedCurve3D.viewer_type(), + input_file=file, + ) + data.native_file = file + session = get_session() + if session: + session.commit() + + data_path = geode_functions.data_file_path(data.id, data.native_file) + os.makedirs(os.path.dirname(data_path), exist_ok=True) + assert os.path.exists(data_path), f"File not found at {data_path}" + response = client.post(route, json={"id": data.id}) + print(response.get_json()) + assert response.status_code == 200 + edge_attribute_names = response.get_json()["edge_attribute_names"] + assert type(edge_attribute_names) is list + for edge_attribute_name in edge_attribute_names: + assert type(edge_attribute_name) is str + + def test_database_uri_path(client: FlaskClient) -> None: app = client.application with app.app_context(): From e764426abd3fad68db30925c61f722a5164acae7 Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Mon, 19 Jan 2026 14:29:26 +0000 Subject: [PATCH 2/2] Apply prepare changes --- requirements.txt | 1 - src/opengeodeweb_back/utils_functions.py | 3 +-- tests/test_geode_functions.py | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 5697c0a5..08d64bdf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -60,4 +60,3 @@ werkzeug==3.1.2 # flask # flask-cors -opengeodeweb-microservice==1.*,>=1.0.12 diff --git a/src/opengeodeweb_back/utils_functions.py b/src/opengeodeweb_back/utils_functions.py index 1264690d..f6c9d953 100644 --- a/src/opengeodeweb_back/utils_functions.py +++ b/src/opengeodeweb_back/utils_functions.py @@ -7,7 +7,6 @@ from concurrent.futures import ThreadPoolExecutor from typing import Any - # Third party imports import flask import fastjsonschema # type: ignore @@ -191,7 +190,7 @@ def save_all_viewables_and_return_info( data_path: str, ) -> dict[str, str | list[str]]: with ThreadPoolExecutor() as executor: - (native_files, viewable_path, light_path) = executor.map( + native_files, viewable_path, light_path = executor.map( lambda args: args[0](args[1]), [ ( diff --git a/tests/test_geode_functions.py b/tests/test_geode_functions.py index dbc8cb70..ef0d00ee 100644 --- a/tests/test_geode_functions.py +++ b/tests/test_geode_functions.py @@ -9,7 +9,6 @@ from opengeodeweb_back.geode_objects import geode_objects from opengeodeweb_back.geode_objects.types import GeodeObjectType_values - data_folder = os.path.join(os.path.dirname(__file__), "data")