Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6223aab
feat(folder_path): data_folder generated with uuid
MaxNumerique Jul 23, 2025
878be26
Apply prepare changes
MaxNumerique Jul 23, 2025
d626e4a
fix args
MaxNumerique Jul 23, 2025
7847778
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 23, 2025
8017752
Apply prepare changes
MaxNumerique Jul 23, 2025
e6e3755
light_viewable removed
MaxNumerique Jul 23, 2025
9d7ea19
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 23, 2025
cf9589a
Generate a unique project UUID and create a dedicated upload director…
MaxNumerique Jul 23, 2025
5605db7
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 24, 2025
c1d3a9b
Validate folder path in test_generate_native_viewable_and_light_viewa…
MaxNumerique Jul 24, 2025
cd7d83f
folder_path halfway there. light_viewable missing still
MaxNumerique Jul 24, 2025
d504bc8
feat(folder_path): upload files ino upload folder into project folder…
MaxNumerique Jul 25, 2025
12bff86
id to mesh_components schema
MaxNumerique Jul 25, 2025
9027f76
revert changes to test function
MaxNumerique Jul 25, 2025
7451bf7
test modified to fit with new folder_path (refacto needed)
MaxNumerique Jul 25, 2025
7061126
Apply prepare changes
MaxNumerique Jul 28, 2025
a734e8a
id added to texture_coordinates, vertex_attribute_names, polygon_attr…
MaxNumerique Jul 29, 2025
061ecf4
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 29, 2025
5d13ad8
Apply prepare changes
MaxNumerique Jul 29, 2025
500906d
models_routes & test_models_routes adjusted to fit data/id/ path
MaxNumerique Jul 29, 2025
0e7d610
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 29, 2025
01469ec
Apply prepare changes
MaxNumerique Jul 29, 2025
a0022d8
geode_functions for refacto
MaxNumerique Jul 29, 2025
6544070
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 29, 2025
b312038
Apply prepare changes
MaxNumerique Jul 29, 2025
5ebb91d
test
MaxNumerique Jul 29, 2025
4c19434
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 29, 2025
1ccfa9b
Apply prepare changes
MaxNumerique Jul 29, 2025
eddbc9c
test
MaxNumerique Jul 29, 2025
b0c91a2
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 29, 2025
6085729
Apply prepare changes
MaxNumerique Jul 29, 2025
e8596a3
test
MaxNumerique Jul 29, 2025
1c3305c
Apply prepare changes
MaxNumerique Jul 29, 2025
01fa755
test
MaxNumerique Jul 29, 2025
a3c4016
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 29, 2025
d37e32a
Apply prepare changes
MaxNumerique Jul 29, 2025
4d9f503
test
MaxNumerique Jul 29, 2025
094b85e
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions…
MaxNumerique Jul 29, 2025
5612c04
Apply prepare changes
MaxNumerique Jul 29, 2025
5a81dd2
Refactored blueprints_routes and blueprint_models for improved organi…
MaxNumerique Jul 30, 2025
86d0a0c
Apply prepare changes
MaxNumerique Jul 30, 2025
5195202
add shared var for both pytest.fixture
MaxNumerique Jul 30, 2025
605b59e
removed try/catch
MaxNumerique Jul 30, 2025
e74b50f
Apply prepare changes
MaxNumerique Jul 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/opengeodeweb_back/geode_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Third party imports
import opengeode_geosciences as og_gs
import opengeode as og
import werkzeug
import flask

# Local application imports
from .geode_objects import geode_objects_dict
Expand Down Expand Up @@ -38,6 +40,26 @@ def load(geode_object: str, file_absolute_path: str):
return geode_object_value(geode_object)["load"](file_absolute_path)


def data_file_path(data_id: str, filename: str) -> str:
data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"]
return os.path.join(
data_folder_path,
data_id,
werkzeug.utils.secure_filename(filename),
)


def load_data(geode_object: str, data_id: str, filename: str):
file_absolute_path = data_file_path(data_id, filename)
return load(geode_object, file_absolute_path)


def upload_file_path(filename):
upload_folder = flask.current_app.config["UPLOAD_FOLDER"]
secure_filename = werkzeug.utils.secure_filename(filename)
return os.path.abspath(os.path.join(upload_folder, secure_filename))


def is_saveable(geode_object: str, data, filename: str):
return geode_object_value(geode_object)["is_saveable"](data, filename)

Expand Down
71 changes: 32 additions & 39 deletions src/opengeodeweb_back/routes/blueprint_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ def allowed_objects():
if flask.request.method == "OPTIONS":
return flask.make_response({}, 200)

UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
utils_functions.validate_request(flask.request, allowed_objects_json)
file_absolute_path = os.path.join(UPLOAD_FOLDER, flask.request.json["filename"])
file_absolute_path = geode_functions.upload_file_path(
flask.request.json["filename"]
)
allowed_objects = geode_functions.list_geode_objects(
file_absolute_path, flask.request.json["supported_feature"]
)
Expand All @@ -118,12 +119,11 @@ def allowed_objects():
methods=missing_files_json["methods"],
)
def missing_files():
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
utils_functions.validate_request(flask.request, missing_files_json)

file_path = geode_functions.upload_file_path(flask.request.json["filename"])
missing_files = geode_functions.missing_files(
flask.request.json["input_geode_object"],
os.path.join(UPLOAD_FOLDER, flask.request.json["filename"]),
file_path,
)
has_missing_files = missing_files.has_missing_files()

Expand Down Expand Up @@ -184,11 +184,9 @@ def crs_converter_geographic_coordinate_systems():
methods=inspect_file_json["methods"],
)
def inspect_file():
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
utils_functions.validate_request(flask.request, inspect_file_json)

secure_filename = werkzeug.utils.secure_filename(flask.request.json["filename"])
file_path = os.path.abspath(os.path.join(UPLOAD_FOLDER, secure_filename))
file_path = geode_functions.upload_file_path(flask.request.json["filename"])
data = geode_functions.load(flask.request.json["input_geode_object"], file_path)
class_inspector = geode_functions.inspect(
flask.request.json["input_geode_object"], data
Expand All @@ -209,13 +207,13 @@ def inspect_file():
methods=geode_objects_and_output_extensions_json["methods"],
)
def geode_objects_and_output_extensions():
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
utils_functions.validate_request(
flask.request, geode_objects_and_output_extensions_json
)
file_path = geode_functions.upload_file_path(flask.request.json["filename"])
data = geode_functions.load(
flask.request.json["input_geode_object"],
os.path.join(UPLOAD_FOLDER, flask.request.json["filename"]),
file_path,
)
geode_objects_and_output_extensions = (
geode_functions.geode_objects_output_extensions(
Expand All @@ -241,14 +239,12 @@ def geode_objects_and_output_extensions():
)
def save_viewable_file():
utils_functions.validate_request(flask.request, save_viewable_file_json)
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
secure_filename = werkzeug.utils.secure_filename(flask.request.json["filename"])
file_path = os.path.abspath(os.path.join(UPLOAD_FOLDER, secure_filename))

file_path = geode_functions.upload_file_path(flask.request.json["filename"])
data = geode_functions.load(flask.request.json["input_geode_object"], file_path)
return flask.make_response(
utils_functions.generate_native_viewable_and_light_viewable(
flask.request.json["input_geode_object"], data, DATA_FOLDER_PATH
flask.request.json["input_geode_object"], data
),
200,
)
Expand All @@ -261,7 +257,6 @@ def save_viewable_file():
@routes.route(create_point_json["route"], methods=create_point_json["methods"])
def create_point():
utils_functions.validate_request(flask.request, create_point_json)
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
title = flask.request.json["title"]
x = flask.request.json["x"]
y = flask.request.json["y"]
Expand All @@ -273,7 +268,7 @@ def create_point():
builder.set_name(title)
return flask.make_response(
utils_functions.generate_native_viewable_and_light_viewable(
"PointSet3D", PointSet3D, DATA_FOLDER_PATH
"PointSet3D", PointSet3D
),
200,
)
Expand All @@ -288,12 +283,13 @@ def create_point():
methods=texture_coordinates_json["methods"],
)
def texture_coordinates():
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
utils_functions.validate_request(flask.request, texture_coordinates_json)
data = geode_functions.load(
data = geode_functions.load_data(
flask.request.json["input_geode_object"],
os.path.join(DATA_FOLDER_PATH, flask.request.json["filename"]),
flask.request.json["id"],
flask.request.json["filename"],
)

texture_coordinates = data.texture_manager().texture_names()

return flask.make_response({"texture_coordinates": texture_coordinates}, 200)
Expand All @@ -311,14 +307,13 @@ def texture_coordinates():
methods=vertex_attribute_names_json["methods"],
)
def vertex_attribute_names():
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
file_absolute_path = os.path.join(
DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
)
data = geode_functions.load(
flask.request.json["input_geode_object"], file_absolute_path
data = geode_functions.load_data(
flask.request.json["input_geode_object"],
flask.request.json["id"],
flask.request.json["filename"],
)

vertex_attribute_names = data.vertex_attribute_manager().attribute_names()

return flask.make_response(
Expand All @@ -341,14 +336,13 @@ def vertex_attribute_names():
methods=polygon_attribute_names_json["methods"],
)
def polygon_attribute_names():
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
utils_functions.validate_request(flask.request, polygon_attribute_names_json)
file_absolute_path = os.path.join(
DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
)
data = geode_functions.load(
flask.request.json["input_geode_object"], file_absolute_path
data = geode_functions.load_data(
flask.request.json["input_geode_object"],
flask.request.json["id"],
flask.request.json["filename"],
)

polygon_attribute_names = data.polygon_attribute_manager().attribute_names()

return flask.make_response(
Expand All @@ -371,14 +365,13 @@ def polygon_attribute_names():
methods=polyhedron_attribute_names_json["methods"],
)
def polyhedron_attribute_names():
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
file_absolute_path = os.path.join(
DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
)
data = geode_functions.load(
flask.request.json["input_geode_object"], file_absolute_path
utils_functions.validate_request(flask.request, polyhedron_attribute_names_json)
data = geode_functions.load_data(
flask.request.json["input_geode_object"],
flask.request.json["id"],
flask.request.json["filename"],
)

polyhedron_attribute_names = data.polyhedron_attribute_manager().attribute_names()

return flask.make_response(
Expand Down
31 changes: 12 additions & 19 deletions src/opengeodeweb_back/routes/models/blueprint_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,27 @@
)
def uuid_to_flat_index():
utils_functions.validate_request(flask.request, vtm_component_indices_json)
vtm_file_path = os.path.join(
flask.current_app.config["DATA_FOLDER_PATH"], flask.request.json["id"] + ".vtm"

vtm_file_path = geode_functions.data_file_path(
flask.request.json["id"], "viewable.vtm"
)
tree = ET.parse(vtm_file_path)
root = tree.find("vtkMultiBlockDataSet")
uuid_to_flat_index = {}
current_index = 0

for elem in root.iter():
if "uuid" in elem.attrib and elem.tag == "DataSet":
uuid_to_flat_index[elem.attrib["uuid"]] = current_index

current_index += 1

return flask.make_response(
{"uuid_to_flat_index": uuid_to_flat_index},
200,
)
return flask.make_response({"uuid_to_flat_index": uuid_to_flat_index}, 200)


def extract_model_uuids(geode_object, file_path):
model = geode_functions.load(geode_object, file_path)
def extract_model_uuids(model):
mesh_components = model.mesh_components()

uuid_dict = {}

for mesh_component, ids in mesh_components.items():
component_name = mesh_component.get()
uuid_dict[component_name] = [id.string() for id in ids]

return uuid_dict


Expand All @@ -58,10 +49,12 @@ def extract_model_uuids(geode_object, file_path):
@routes.route(mesh_components_json["route"], methods=mesh_components_json["methods"])
def extract_uuids_endpoint():
utils_functions.validate_request(flask.request, mesh_components_json)
file_path = os.path.join(
flask.current_app.config["DATA_FOLDER_PATH"], flask.request.json["filename"]

model = geode_functions.load_data(
flask.request.json["geode_object"],
flask.request.json["id"],
flask.request.json["filename"],
)
if not os.path.exists(file_path):
return flask.make_response({"error": "File not found"}, 404)
uuid_dict = extract_model_uuids(flask.request.json["geode_object"], file_path)

uuid_dict = extract_model_uuids(model)
return flask.make_response({"uuid_dict": uuid_dict}, 200)
11 changes: 9 additions & 2 deletions src/opengeodeweb_back/routes/models/schemas/mesh_components.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"filename": {
"type": "string"
"type": "string",
"minLength": 1
},
"geode_object": {
"type": "string"
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"filename",
"geode_object"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": "object",
"properties": {
"id": {
"type": "string"
"type": "string",
"minLength": 1
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
"filename": {
"type": "string",
"minLength": 1
},
"id": {
"type": "string",
"minLength": 1
}
},
"required": [
"input_geode_object",
"filename"
"filename",
"id"
],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
"filename": {
"type": "string",
"minLength": 1
},
"id": {
"type": "string",
"minLength": 1
}
},
"required": [
"input_geode_object",
"filename"
"filename",
"id"
],
"additionalProperties": false
}
5 changes: 5 additions & 0 deletions src/opengeodeweb_back/routes/schemas/texture_coordinates.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
"filename": {
"type": "string",
"minLength": 1
},
"id": {
"type": "string",
"minLength": 1
}
},
"required": [
"input_geode_object",
"id",
"filename"
],
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
"filename": {
"type": "string",
"minLength": 1
},
"id": {
"type": "string",
"minLength": 1
}
},
"required": [
"input_geode_object",
"filename"
"filename",
"id"
],
"additionalProperties": false
}
Loading