OpenGeodeWeb-Back 5.8.7rc1__py3-none-any.whl → 5.9.0rc2__py3-none-any.whl

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.
@@ -4,6 +4,8 @@ import os
4
4
  # Third party imports
5
5
  import opengeode_geosciences as og_gs
6
6
  import opengeode as og
7
+ import werkzeug
8
+ import flask
7
9
 
8
10
  # Local application imports
9
11
  from .geode_objects import geode_objects_dict
@@ -26,8 +28,8 @@ def output_factory(geode_object: str):
26
28
  return geode_object_value(geode_object)["output_factory"]
27
29
 
28
30
 
29
- def missing_files(geode_object: str, file_absolute_path: str):
30
- return geode_object_value(geode_object)["missing_files"](file_absolute_path)
31
+ def additional_files(geode_object: str, file_absolute_path: str):
32
+ return geode_object_value(geode_object)["additional_files"](file_absolute_path)
31
33
 
32
34
 
33
35
  def is_loadable(geode_object: str, file_absolute_path: str):
@@ -38,6 +40,26 @@ def load(geode_object: str, file_absolute_path: str):
38
40
  return geode_object_value(geode_object)["load"](file_absolute_path)
39
41
 
40
42
 
43
+ def data_file_path(data_id: str, filename: str) -> str:
44
+ data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"]
45
+ return os.path.join(
46
+ data_folder_path,
47
+ data_id,
48
+ werkzeug.utils.secure_filename(filename),
49
+ )
50
+
51
+
52
+ def load_data(geode_object: str, data_id: str, filename: str):
53
+ file_absolute_path = data_file_path(data_id, filename)
54
+ return load(geode_object, file_absolute_path)
55
+
56
+
57
+ def upload_file_path(filename):
58
+ upload_folder = flask.current_app.config["UPLOAD_FOLDER"]
59
+ secure_filename = werkzeug.utils.secure_filename(filename)
60
+ return os.path.abspath(os.path.join(upload_folder, secure_filename))
61
+
62
+
41
63
  def is_saveable(geode_object: str, data, filename: str):
42
64
  return geode_object_value(geode_object)["is_saveable"](data, filename)
43
65
 
@@ -25,7 +25,7 @@ def geode_objects_dict():
25
25
  "class": og.BRep,
26
26
  "input_factory": og.BRepInputFactory,
27
27
  "output_factory": og.BRepOutputFactory,
28
- "missing_files": og.check_brep_missing_files,
28
+ "additional_files": og.brep_additional_files,
29
29
  "is_loadable": og.is_brep_loadable,
30
30
  "load": og.load_brep,
31
31
  "is_saveable": og.is_brep_saveable,
@@ -48,7 +48,7 @@ def geode_objects_dict():
48
48
  "class": og_gs.CrossSection,
49
49
  "input_factory": og_gs.CrossSectionInputFactory,
50
50
  "output_factory": og_gs.CrossSectionOutputFactory,
51
- "missing_files": og_gs.check_cross_section_missing_files,
51
+ "additional_files": og_gs.cross_section_additional_files,
52
52
  "is_loadable": og_gs.is_cross_section_loadable,
53
53
  "load": og_gs.load_cross_section,
54
54
  "is_saveable": og_gs.is_cross_section_saveable,
@@ -70,7 +70,7 @@ def geode_objects_dict():
70
70
  "class": og.EdgedCurve2D,
71
71
  "input_factory": og.EdgedCurveInputFactory2D,
72
72
  "output_factory": og.EdgedCurveOutputFactory2D,
73
- "missing_files": og.check_edged_curve_missing_files2D,
73
+ "additional_files": og.edged_curve_additional_files2D,
74
74
  "is_loadable": og.is_edged_curve_loadable2D,
75
75
  "load": og.load_edged_curve2D,
76
76
  "is_saveable": og.is_edged_curve_saveable2D,
@@ -93,7 +93,7 @@ def geode_objects_dict():
93
93
  "class": og.EdgedCurve3D,
94
94
  "input_factory": og.EdgedCurveInputFactory3D,
95
95
  "output_factory": og.EdgedCurveOutputFactory3D,
96
- "missing_files": og.check_edged_curve_missing_files3D,
96
+ "additional_files": og.edged_curve_additional_files3D,
97
97
  "is_loadable": og.is_edged_curve_loadable3D,
98
98
  "load": og.load_edged_curve3D,
99
99
  "is_saveable": og.is_edged_curve_saveable3D,
@@ -116,7 +116,7 @@ def geode_objects_dict():
116
116
  "class": og.Graph,
117
117
  "input_factory": og.GraphInputFactory,
118
118
  "output_factory": og.GraphOutputFactory,
119
- "missing_files": og.check_graph_missing_files,
119
+ "additional_files": og.graph_additional_files,
120
120
  "is_loadable": og.is_graph_loadable,
121
121
  "load": og.load_graph,
122
122
  "is_saveable": og.is_graph_saveable,
@@ -130,7 +130,7 @@ def geode_objects_dict():
130
130
  "class": og.HybridSolid3D,
131
131
  "input_factory": og.HybridSolidInputFactory3D,
132
132
  "output_factory": og.HybridSolidOutputFactory3D,
133
- "missing_files": og.check_hybrid_solid_missing_files3D,
133
+ "additional_files": og.hybrid_solid_additional_files3D,
134
134
  "is_loadable": og.is_hybrid_solid_loadable3D,
135
135
  "load": og.load_hybrid_solid3D,
136
136
  "is_saveable": og.is_hybrid_solid_saveable3D,
@@ -154,7 +154,7 @@ def geode_objects_dict():
154
154
  "class": og_gs.ImplicitCrossSection,
155
155
  "input_factory": og_gs.ImplicitCrossSectionInputFactory,
156
156
  "output_factory": og_gs.ImplicitCrossSectionOutputFactory,
157
- "missing_files": og_gs.check_implicit_cross_section_missing_files,
157
+ "additional_files": og_gs.implicit_cross_section_additional_files,
158
158
  "is_loadable": og_gs.is_implicit_cross_section_loadable,
159
159
  "load": og_gs.load_implicit_cross_section,
160
160
  "is_saveable": og_gs.is_implicit_cross_section_saveable,
@@ -177,7 +177,7 @@ def geode_objects_dict():
177
177
  "class": og_gs.ImplicitStructuralModel,
178
178
  "input_factory": og_gs.ImplicitStructuralModelInputFactory,
179
179
  "output_factory": og_gs.ImplicitStructuralModelOutputFactory,
180
- "missing_files": og_gs.check_implicit_structural_model_missing_files,
180
+ "additional_files": og_gs.implicit_structural_model_additional_files,
181
181
  "is_loadable": og_gs.is_implicit_structural_model_loadable,
182
182
  "load": og_gs.load_implicit_structural_model,
183
183
  "is_saveable": og_gs.is_implicit_structural_model_saveable,
@@ -199,7 +199,7 @@ def geode_objects_dict():
199
199
  "class": og.LightRegularGrid2D,
200
200
  "input_factory": og.LightRegularGridInputFactory2D,
201
201
  "output_factory": og.LightRegularGridOutputFactory2D,
202
- "missing_files": og.check_light_regular_grid_missing_files2D,
202
+ "additional_files": og.light_regular_grid_additional_files2D,
203
203
  "is_loadable": og.is_light_regular_grid_loadable2D,
204
204
  "load": og.load_light_regular_grid2D,
205
205
  "is_saveable": og.is_light_regular_grid_saveable2D,
@@ -215,7 +215,7 @@ def geode_objects_dict():
215
215
  "class": og.LightRegularGrid3D,
216
216
  "input_factory": og.LightRegularGridInputFactory3D,
217
217
  "output_factory": og.LightRegularGridOutputFactory3D,
218
- "missing_files": og.check_light_regular_grid_missing_files3D,
218
+ "additional_files": og.light_regular_grid_additional_files3D,
219
219
  "is_loadable": og.is_light_regular_grid_loadable3D,
220
220
  "load": og.load_light_regular_grid3D,
221
221
  "is_saveable": og.is_light_regular_grid_saveable3D,
@@ -231,7 +231,7 @@ def geode_objects_dict():
231
231
  "class": og.PointSet2D,
232
232
  "input_factory": og.PointSetInputFactory2D,
233
233
  "output_factory": og.PointSetOutputFactory2D,
234
- "missing_files": og.check_point_set_missing_files2D,
234
+ "additional_files": og.point_set_additional_files2D,
235
235
  "is_loadable": og.is_point_set_loadable2D,
236
236
  "load": og.load_point_set2D,
237
237
  "is_saveable": og.is_point_set_saveable2D,
@@ -254,7 +254,7 @@ def geode_objects_dict():
254
254
  "class": og.PointSet3D,
255
255
  "input_factory": og.PointSetInputFactory3D,
256
256
  "output_factory": og.PointSetOutputFactory3D,
257
- "missing_files": og.check_point_set_missing_files3D,
257
+ "additional_files": og.point_set_additional_files3D,
258
258
  "is_loadable": og.is_point_set_loadable3D,
259
259
  "load": og.load_point_set3D,
260
260
  "is_saveable": og.is_point_set_saveable3D,
@@ -277,7 +277,7 @@ def geode_objects_dict():
277
277
  "class": og.PolygonalSurface2D,
278
278
  "input_factory": og.PolygonalSurfaceInputFactory2D,
279
279
  "output_factory": og.PolygonalSurfaceOutputFactory2D,
280
- "missing_files": og.check_polygonal_surface_missing_files2D,
280
+ "additional_files": og.polygonal_surface_additional_files2D,
281
281
  "is_loadable": og.is_polygonal_surface_loadable2D,
282
282
  "load": og.load_polygonal_surface2D,
283
283
  "is_saveable": og.is_polygonal_surface_saveable2D,
@@ -300,7 +300,7 @@ def geode_objects_dict():
300
300
  "class": og.PolygonalSurface3D,
301
301
  "input_factory": og.PolygonalSurfaceInputFactory3D,
302
302
  "output_factory": og.PolygonalSurfaceOutputFactory3D,
303
- "missing_files": og.check_polygonal_surface_missing_files3D,
303
+ "additional_files": og.polygonal_surface_additional_files3D,
304
304
  "is_loadable": og.is_polygonal_surface_loadable3D,
305
305
  "load": og.load_polygonal_surface3D,
306
306
  "is_saveable": og.is_polygonal_surface_saveable3D,
@@ -323,7 +323,7 @@ def geode_objects_dict():
323
323
  "class": og.PolyhedralSolid3D,
324
324
  "input_factory": og.PolyhedralSolidInputFactory3D,
325
325
  "output_factory": og.PolyhedralSolidOutputFactory3D,
326
- "missing_files": og.check_polyhedral_solid_missing_files3D,
326
+ "additional_files": og.polyhedral_solid_additional_files3D,
327
327
  "is_loadable": og.is_polyhedral_solid_loadable3D,
328
328
  "load": og.load_polyhedral_solid3D,
329
329
  "is_saveable": og.is_polyhedral_solid_saveable3D,
@@ -346,7 +346,7 @@ def geode_objects_dict():
346
346
  "class": og.RasterImage2D,
347
347
  "input_factory": og.RasterImageInputFactory2D,
348
348
  "output_factory": og.RasterImageOutputFactory2D,
349
- "missing_files": og.check_raster_image_missing_files2D,
349
+ "additional_files": og.raster_image_additional_files2D,
350
350
  "is_loadable": og.is_raster_image_loadable2D,
351
351
  "load": og.load_raster_image2D,
352
352
  "is_saveable": og.is_raster_image_saveable2D,
@@ -360,7 +360,7 @@ def geode_objects_dict():
360
360
  "class": og.RasterImage3D,
361
361
  "input_factory": og.RasterImageInputFactory3D,
362
362
  "output_factory": og.RasterImageOutputFactory3D,
363
- "missing_files": og.check_raster_image_missing_files3D,
363
+ "additional_files": og.raster_image_additional_files3D,
364
364
  "is_loadable": og.is_raster_image_loadable3D,
365
365
  "load": og.load_raster_image3D,
366
366
  "is_saveable": og.is_raster_image_saveable3D,
@@ -374,7 +374,7 @@ def geode_objects_dict():
374
374
  "class": og.RegularGrid2D,
375
375
  "input_factory": og.RegularGridInputFactory2D,
376
376
  "output_factory": og.RegularGridOutputFactory2D,
377
- "missing_files": og.check_regular_grid_missing_files2D,
377
+ "additional_files": og.regular_grid_additional_files2D,
378
378
  "is_loadable": og.is_regular_grid_loadable2D,
379
379
  "load": og.load_regular_grid2D,
380
380
  "is_saveable": og.is_regular_grid_saveable2D,
@@ -396,7 +396,7 @@ def geode_objects_dict():
396
396
  "class": og.RegularGrid3D,
397
397
  "input_factory": og.RegularGridInputFactory3D,
398
398
  "output_factory": og.RegularGridOutputFactory3D,
399
- "missing_files": og.check_regular_grid_missing_files3D,
399
+ "additional_files": og.regular_grid_additional_files3D,
400
400
  "is_loadable": og.is_regular_grid_loadable3D,
401
401
  "load": og.load_regular_grid3D,
402
402
  "is_saveable": og.is_regular_grid_saveable3D,
@@ -418,7 +418,7 @@ def geode_objects_dict():
418
418
  "class": og.Section,
419
419
  "input_factory": og.SectionInputFactory,
420
420
  "output_factory": og.SectionOutputFactory,
421
- "missing_files": og.check_section_missing_files,
421
+ "additional_files": og.section_additional_files,
422
422
  "is_loadable": og.is_section_loadable,
423
423
  "load": og.load_section,
424
424
  "is_saveable": og.is_section_saveable,
@@ -441,7 +441,7 @@ def geode_objects_dict():
441
441
  "class": og_gs.StructuralModel,
442
442
  "input_factory": og_gs.StructuralModelInputFactory,
443
443
  "output_factory": og_gs.StructuralModelOutputFactory,
444
- "missing_files": og_gs.check_structural_model_missing_files,
444
+ "additional_files": og_gs.structural_model_additional_files,
445
445
  "is_loadable": og_gs.is_structural_model_loadable,
446
446
  "load": og_gs.load_structural_model,
447
447
  "is_saveable": og_gs.is_structural_model_saveable,
@@ -463,7 +463,7 @@ def geode_objects_dict():
463
463
  "class": og.TetrahedralSolid3D,
464
464
  "input_factory": og.TetrahedralSolidInputFactory3D,
465
465
  "output_factory": og.TetrahedralSolidOutputFactory3D,
466
- "missing_files": og.check_tetrahedral_solid_missing_files3D,
466
+ "additional_files": og.tetrahedral_solid_additional_files3D,
467
467
  "is_loadable": og.is_tetrahedral_solid_loadable3D,
468
468
  "load": og.load_tetrahedral_solid3D,
469
469
  "is_saveable": og.is_tetrahedral_solid_saveable3D,
@@ -486,7 +486,7 @@ def geode_objects_dict():
486
486
  "class": og.TriangulatedSurface2D,
487
487
  "input_factory": og.TriangulatedSurfaceInputFactory2D,
488
488
  "output_factory": og.TriangulatedSurfaceOutputFactory2D,
489
- "missing_files": og.check_triangulated_surface_missing_files2D,
489
+ "additional_files": og.triangulated_surface_additional_files2D,
490
490
  "is_loadable": og.is_triangulated_surface_loadable2D,
491
491
  "load": og.load_triangulated_surface2D,
492
492
  "is_saveable": og.is_triangulated_surface_saveable2D,
@@ -509,7 +509,7 @@ def geode_objects_dict():
509
509
  "class": og.TriangulatedSurface3D,
510
510
  "input_factory": og.TriangulatedSurfaceInputFactory3D,
511
511
  "output_factory": og.TriangulatedSurfaceOutputFactory3D,
512
- "missing_files": og.check_triangulated_surface_missing_files3D,
512
+ "additional_files": og.triangulated_surface_additional_files3D,
513
513
  "is_loadable": og.is_triangulated_surface_loadable3D,
514
514
  "load": og.load_triangulated_surface3D,
515
515
  "is_saveable": og.is_triangulated_surface_saveable3D,
@@ -532,7 +532,7 @@ def geode_objects_dict():
532
532
  "class": og.VertexSet,
533
533
  "input_factory": og.VertexSetInputFactory,
534
534
  "output_factory": og.VertexSetOutputFactory,
535
- "missing_files": og.check_vertex_set_missing_files,
535
+ "additional_files": og.vertex_set_additional_files,
536
536
  "is_loadable": og.is_vertex_set_loadable,
537
537
  "load": og.load_vertex_set,
538
538
  "is_saveable": og.is_vertex_set_saveable,
@@ -97,9 +97,10 @@ def allowed_objects():
97
97
  if flask.request.method == "OPTIONS":
98
98
  return flask.make_response({}, 200)
99
99
 
100
- UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
101
100
  utils_functions.validate_request(flask.request, allowed_objects_json)
102
- file_absolute_path = os.path.join(UPLOAD_FOLDER, flask.request.json["filename"])
101
+ file_absolute_path = geode_functions.upload_file_path(
102
+ flask.request.json["filename"]
103
+ )
103
104
  allowed_objects = geode_functions.list_geode_objects(
104
105
  file_absolute_path, flask.request.json["supported_feature"]
105
106
  )
@@ -118,22 +119,29 @@ with open(
118
119
  methods=missing_files_json["methods"],
119
120
  )
120
121
  def missing_files():
121
- UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
122
122
  utils_functions.validate_request(flask.request, missing_files_json)
123
+ file_path = geode_functions.upload_file_path(flask.request.json["filename"])
123
124
 
124
- missing_files = geode_functions.missing_files(
125
+ additional_files = geode_functions.additional_files(
125
126
  flask.request.json["input_geode_object"],
126
- os.path.join(UPLOAD_FOLDER, flask.request.json["filename"]),
127
+ file_path,
127
128
  )
128
- has_missing_files = missing_files.has_missing_files()
129
129
 
130
- mandatory_files = []
131
- for mandatory_file in missing_files.mandatory_files:
132
- mandatory_files.append(os.path.basename(mandatory_file))
130
+ has_missing_files = any(
131
+ file.is_missing
132
+ for file in additional_files.mandatory_files + additional_files.optional_files
133
+ )
133
134
 
134
- additional_files = []
135
- for additional_file in missing_files.additional_files:
136
- additional_files.append(os.path.basename(additional_file))
135
+ mandatory_files = [
136
+ os.path.basename(file.filename)
137
+ for file in additional_files.mandatory_files
138
+ if file.is_missing
139
+ ]
140
+ additional_files = [
141
+ os.path.basename(file.filename)
142
+ for file in additional_files.optional_files
143
+ if file.is_missing
144
+ ]
137
145
 
138
146
  return flask.make_response(
139
147
  {
@@ -184,11 +192,9 @@ with open(
184
192
  methods=inspect_file_json["methods"],
185
193
  )
186
194
  def inspect_file():
187
- UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
188
195
  utils_functions.validate_request(flask.request, inspect_file_json)
189
196
 
190
- secure_filename = werkzeug.utils.secure_filename(flask.request.json["filename"])
191
- file_path = os.path.abspath(os.path.join(UPLOAD_FOLDER, secure_filename))
197
+ file_path = geode_functions.upload_file_path(flask.request.json["filename"])
192
198
  data = geode_functions.load(flask.request.json["input_geode_object"], file_path)
193
199
  class_inspector = geode_functions.inspect(
194
200
  flask.request.json["input_geode_object"], data
@@ -209,13 +215,13 @@ with open(
209
215
  methods=geode_objects_and_output_extensions_json["methods"],
210
216
  )
211
217
  def geode_objects_and_output_extensions():
212
- UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
213
218
  utils_functions.validate_request(
214
219
  flask.request, geode_objects_and_output_extensions_json
215
220
  )
221
+ file_path = geode_functions.upload_file_path(flask.request.json["filename"])
216
222
  data = geode_functions.load(
217
223
  flask.request.json["input_geode_object"],
218
- os.path.join(UPLOAD_FOLDER, flask.request.json["filename"]),
224
+ file_path,
219
225
  )
220
226
  geode_objects_and_output_extensions = (
221
227
  geode_functions.geode_objects_output_extensions(
@@ -241,14 +247,10 @@ with open(
241
247
  )
242
248
  def save_viewable_file():
243
249
  utils_functions.validate_request(flask.request, save_viewable_file_json)
244
- UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
245
- DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
246
- secure_filename = werkzeug.utils.secure_filename(flask.request.json["filename"])
247
- file_path = os.path.abspath(os.path.join(UPLOAD_FOLDER, secure_filename))
248
- data = geode_functions.load(flask.request.json["input_geode_object"], file_path)
249
250
  return flask.make_response(
250
- utils_functions.generate_native_viewable_and_light_viewable(
251
- flask.request.json["input_geode_object"], data, DATA_FOLDER_PATH
251
+ utils_functions.generate_native_viewable_and_light_viewable_from_file(
252
+ geode_object=flask.request.json["input_geode_object"],
253
+ input_filename=flask.request.json["filename"],
252
254
  ),
253
255
  200,
254
256
  )
@@ -261,7 +263,6 @@ with open(os.path.join(schemas, "create_point.json"), "r") as file:
261
263
  @routes.route(create_point_json["route"], methods=create_point_json["methods"])
262
264
  def create_point():
263
265
  utils_functions.validate_request(flask.request, create_point_json)
264
- DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
265
266
  title = flask.request.json["title"]
266
267
  x = flask.request.json["x"]
267
268
  y = flask.request.json["y"]
@@ -272,8 +273,8 @@ def create_point():
272
273
  builder.create_point(opengeode.Point3D([x, y, z]))
273
274
  builder.set_name(title)
274
275
  return flask.make_response(
275
- utils_functions.generate_native_viewable_and_light_viewable(
276
- "PointSet3D", PointSet3D, DATA_FOLDER_PATH
276
+ utils_functions.generate_native_viewable_and_light_viewable_from_object(
277
+ "PointSet3D", PointSet3D
277
278
  ),
278
279
  200,
279
280
  )
@@ -288,12 +289,13 @@ with open(os.path.join(schemas, "texture_coordinates.json"), "r") as file:
288
289
  methods=texture_coordinates_json["methods"],
289
290
  )
290
291
  def texture_coordinates():
291
- DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
292
292
  utils_functions.validate_request(flask.request, texture_coordinates_json)
293
- data = geode_functions.load(
293
+ data = geode_functions.load_data(
294
294
  flask.request.json["input_geode_object"],
295
- os.path.join(DATA_FOLDER_PATH, flask.request.json["filename"]),
295
+ flask.request.json["id"],
296
+ flask.request.json["filename"],
296
297
  )
298
+
297
299
  texture_coordinates = data.texture_manager().texture_names()
298
300
 
299
301
  return flask.make_response({"texture_coordinates": texture_coordinates}, 200)
@@ -311,14 +313,13 @@ with open(
311
313
  methods=vertex_attribute_names_json["methods"],
312
314
  )
313
315
  def vertex_attribute_names():
314
- DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
315
316
  utils_functions.validate_request(flask.request, vertex_attribute_names_json)
316
- file_absolute_path = os.path.join(
317
- DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
318
- )
319
- data = geode_functions.load(
320
- flask.request.json["input_geode_object"], file_absolute_path
317
+ data = geode_functions.load_data(
318
+ flask.request.json["input_geode_object"],
319
+ flask.request.json["id"],
320
+ flask.request.json["filename"],
321
321
  )
322
+
322
323
  vertex_attribute_names = data.vertex_attribute_manager().attribute_names()
323
324
 
324
325
  return flask.make_response(
@@ -341,14 +342,13 @@ with open(
341
342
  methods=polygon_attribute_names_json["methods"],
342
343
  )
343
344
  def polygon_attribute_names():
344
- DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
345
345
  utils_functions.validate_request(flask.request, polygon_attribute_names_json)
346
- file_absolute_path = os.path.join(
347
- DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
348
- )
349
- data = geode_functions.load(
350
- flask.request.json["input_geode_object"], file_absolute_path
346
+ data = geode_functions.load_data(
347
+ flask.request.json["input_geode_object"],
348
+ flask.request.json["id"],
349
+ flask.request.json["filename"],
351
350
  )
351
+
352
352
  polygon_attribute_names = data.polygon_attribute_manager().attribute_names()
353
353
 
354
354
  return flask.make_response(
@@ -371,14 +371,13 @@ with open(
371
371
  methods=polyhedron_attribute_names_json["methods"],
372
372
  )
373
373
  def polyhedron_attribute_names():
374
- DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
375
- utils_functions.validate_request(flask.request, vertex_attribute_names_json)
376
- file_absolute_path = os.path.join(
377
- DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
378
- )
379
- data = geode_functions.load(
380
- flask.request.json["input_geode_object"], file_absolute_path
374
+ utils_functions.validate_request(flask.request, polyhedron_attribute_names_json)
375
+ data = geode_functions.load_data(
376
+ flask.request.json["input_geode_object"],
377
+ flask.request.json["id"],
378
+ flask.request.json["filename"],
381
379
  )
380
+
382
381
  polyhedron_attribute_names = data.polyhedron_attribute_manager().attribute_names()
383
382
 
384
383
  return flask.make_response(
@@ -18,36 +18,27 @@ with open(os.path.join(schemas, "vtm_component_indices.json"), "r") as file:
18
18
  )
19
19
  def uuid_to_flat_index():
20
20
  utils_functions.validate_request(flask.request, vtm_component_indices_json)
21
- vtm_file_path = os.path.join(
22
- flask.current_app.config["DATA_FOLDER_PATH"], flask.request.json["id"] + ".vtm"
21
+
22
+ vtm_file_path = geode_functions.data_file_path(
23
+ flask.request.json["id"], "viewable.vtm"
23
24
  )
24
25
  tree = ET.parse(vtm_file_path)
25
26
  root = tree.find("vtkMultiBlockDataSet")
26
27
  uuid_to_flat_index = {}
27
28
  current_index = 0
28
-
29
29
  for elem in root.iter():
30
30
  if "uuid" in elem.attrib and elem.tag == "DataSet":
31
31
  uuid_to_flat_index[elem.attrib["uuid"]] = current_index
32
-
33
32
  current_index += 1
34
-
35
- return flask.make_response(
36
- {"uuid_to_flat_index": uuid_to_flat_index},
37
- 200,
38
- )
33
+ return flask.make_response({"uuid_to_flat_index": uuid_to_flat_index}, 200)
39
34
 
40
35
 
41
- def extract_model_uuids(geode_object, file_path):
42
- model = geode_functions.load(geode_object, file_path)
36
+ def extract_model_uuids(model):
43
37
  mesh_components = model.mesh_components()
44
-
45
38
  uuid_dict = {}
46
-
47
39
  for mesh_component, ids in mesh_components.items():
48
40
  component_name = mesh_component.get()
49
41
  uuid_dict[component_name] = [id.string() for id in ids]
50
-
51
42
  return uuid_dict
52
43
 
53
44
 
@@ -58,10 +49,12 @@ with open(os.path.join(schemas, "mesh_components.json"), "r") as file:
58
49
  @routes.route(mesh_components_json["route"], methods=mesh_components_json["methods"])
59
50
  def extract_uuids_endpoint():
60
51
  utils_functions.validate_request(flask.request, mesh_components_json)
61
- file_path = os.path.join(
62
- flask.current_app.config["DATA_FOLDER_PATH"], flask.request.json["filename"]
52
+
53
+ model = geode_functions.load_data(
54
+ flask.request.json["geode_object"],
55
+ flask.request.json["id"],
56
+ flask.request.json["filename"],
63
57
  )
64
- if not os.path.exists(file_path):
65
- return flask.make_response({"error": "File not found"}, 404)
66
- uuid_dict = extract_model_uuids(flask.request.json["geode_object"], file_path)
58
+
59
+ uuid_dict = extract_model_uuids(model)
67
60
  return flask.make_response({"uuid_dict": uuid_dict}, 200)
@@ -5,14 +5,21 @@
5
5
  ],
6
6
  "type": "object",
7
7
  "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "minLength": 1
11
+ },
8
12
  "filename": {
9
- "type": "string"
13
+ "type": "string",
14
+ "minLength": 1
10
15
  },
11
16
  "geode_object": {
12
- "type": "string"
17
+ "type": "string",
18
+ "minLength": 1
13
19
  }
14
20
  },
15
21
  "required": [
22
+ "id",
16
23
  "filename",
17
24
  "geode_object"
18
25
  ],
@@ -6,7 +6,8 @@
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "id": {
9
- "type": "string"
9
+ "type": "string",
10
+ "minLength": 1
10
11
  }
11
12
  },
12
13
  "required": [
@@ -12,11 +12,16 @@
12
12
  "filename": {
13
13
  "type": "string",
14
14
  "minLength": 1
15
+ },
16
+ "id": {
17
+ "type": "string",
18
+ "minLength": 1
15
19
  }
16
20
  },
17
21
  "required": [
18
22
  "input_geode_object",
19
- "filename"
23
+ "filename",
24
+ "id"
20
25
  ],
21
26
  "additionalProperties": false
22
27
  }
@@ -12,11 +12,16 @@
12
12
  "filename": {
13
13
  "type": "string",
14
14
  "minLength": 1
15
+ },
16
+ "id": {
17
+ "type": "string",
18
+ "minLength": 1
15
19
  }
16
20
  },
17
21
  "required": [
18
22
  "input_geode_object",
19
- "filename"
23
+ "filename",
24
+ "id"
20
25
  ],
21
26
  "additionalProperties": false
22
27
  }
@@ -12,10 +12,15 @@
12
12
  "filename": {
13
13
  "type": "string",
14
14
  "minLength": 1
15
+ },
16
+ "id": {
17
+ "type": "string",
18
+ "minLength": 1
15
19
  }
16
20
  },
17
21
  "required": [
18
22
  "input_geode_object",
23
+ "id",
19
24
  "filename"
20
25
  ],
21
26
  "additionalProperties": false
@@ -12,11 +12,16 @@
12
12
  "filename": {
13
13
  "type": "string",
14
14
  "minLength": 1
15
+ },
16
+ "id": {
17
+ "type": "string",
18
+ "minLength": 1
15
19
  }
16
20
  },
17
21
  "required": [
18
22
  "input_geode_object",
19
- "filename"
23
+ "filename",
24
+ "id"
20
25
  ],
21
26
  "additionalProperties": false
22
27
  }
@@ -9,6 +9,8 @@ import zipfile
9
9
  import flask
10
10
  import fastjsonschema
11
11
  import importlib.metadata as metadata
12
+ import shutil
13
+ import werkzeug
12
14
 
13
15
  # Local application imports
14
16
  from . import geode_functions
@@ -143,35 +145,83 @@ def handle_exception(e):
143
145
  return response
144
146
 
145
147
 
146
- def generate_native_viewable_and_light_viewable(
147
- geode_object, data, folder_absolute_path
148
- ):
148
+ def create_unique_data_folder() -> tuple[str, str]:
149
+ base_data_folder = flask.current_app.config["DATA_FOLDER_PATH"]
149
150
  generated_id = str(uuid.uuid4()).replace("-", "")
150
- name = data.name()
151
- object_type = geode_functions.get_object_type(geode_object)
151
+ data_path = os.path.join(base_data_folder, generated_id)
152
+ os.makedirs(data_path, exist_ok=True)
153
+ return generated_id, data_path
152
154
 
155
+
156
+ def save_all_viewables_and_return_info(
157
+ geode_object,
158
+ data, generated_id,
159
+ data_path,
160
+ additional_files=None
161
+ ):
153
162
  saved_native_file_path = geode_functions.save(
154
163
  geode_object,
155
164
  data,
156
- folder_absolute_path,
157
- generated_id + "." + data.native_extension(),
165
+ data_path,
166
+ "native." + data.native_extension(),
158
167
  )
159
168
  saved_viewable_file_path = geode_functions.save_viewable(
160
- geode_object, data, folder_absolute_path, generated_id
169
+ geode_object, data, data_path, "viewable"
161
170
  )
162
171
  saved_light_viewable_file_path = geode_functions.save_light_viewable(
163
- geode_object, data, folder_absolute_path, "light_" + generated_id
172
+ geode_object, data, data_path, "light_viewable"
164
173
  )
165
- f = open(saved_light_viewable_file_path, "rb")
166
- binary_light_viewable = f.read()
167
- f.close()
174
+ with open(saved_light_viewable_file_path, "rb") as f:
175
+ binary_light_viewable = f.read()
168
176
 
169
177
  return {
170
- "name": name,
178
+ "name": data.name(),
171
179
  "native_file_name": os.path.basename(saved_native_file_path[0]),
172
180
  "viewable_file_name": os.path.basename(saved_viewable_file_path),
173
181
  "id": generated_id,
174
- "object_type": object_type,
175
- "binary_light_viewable": str(binary_light_viewable, "utf-8"),
182
+ "object_type": geode_functions.get_object_type(geode_object),
183
+ "binary_light_viewable": binary_light_viewable.decode("utf-8"),
176
184
  "geode_object": geode_object,
185
+ "input_files": additional_files or [],
177
186
  }
187
+
188
+ def generate_native_viewable_and_light_viewable_from_object(
189
+ geode_object,
190
+ data
191
+ ):
192
+ generated_id, data_path = create_unique_data_folder()
193
+ return save_all_viewables_and_return_info(geode_object, data, generated_id, data_path)
194
+
195
+
196
+ def generate_native_viewable_and_light_viewable_from_file(
197
+ geode_object,
198
+ input_filename
199
+ ):
200
+ generated_id, data_path = create_unique_data_folder()
201
+
202
+ full_input_filename = geode_functions.upload_file_path(input_filename)
203
+ copied_full_path = os.path.join(data_path, werkzeug.utils.secure_filename(input_filename))
204
+ shutil.copy2(full_input_filename, copied_full_path)
205
+
206
+ additional_files_copied = []
207
+ additional = geode_functions.additional_files(geode_object, full_input_filename)
208
+ for additional_file in additional.mandatory_files + additional.optional_files:
209
+ if additional_file.is_missing:
210
+ continue
211
+ source_path = os.path.join(os.path.dirname(full_input_filename), additional_file.filename)
212
+ if not os.path.exists(source_path):
213
+ continue
214
+ dest_path = os.path.join(data_path, additional_file.filename)
215
+ os.makedirs(os.path.dirname(dest_path), exist_ok=True)
216
+ shutil.copy2(source_path, dest_path)
217
+ additional_files_copied.append(additional_file.filename)
218
+
219
+ data = geode_functions.load_data(geode_object, generated_id, input_filename)
220
+
221
+ return save_all_viewables_and_return_info(
222
+ geode_object,
223
+ data,
224
+ generated_id,
225
+ data_path,
226
+ additional_files=additional_files_copied,
227
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OpenGeodeWeb-Back
3
- Version: 5.8.7rc1
3
+ Version: 5.9.0rc2
4
4
  Summary: OpenGeodeWeb-Back is an open source framework that proposes handy python functions and wrappers for the OpenGeode ecosystem
5
5
  Author-email: Geode-solutions <team-web@geode-solutions.com>
6
6
  Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Back
@@ -11,32 +11,28 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: <3.13,>=3.9
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: asgiref==3.8.1
15
- Requires-Dist: attrs==25.3.0
14
+ Requires-Dist: asgiref==3.9.1
16
15
  Requires-Dist: blinker==1.9.0
17
16
  Requires-Dist: click==8.2.1
18
17
  Requires-Dist: fastjsonschema==2.21.1
19
18
  Requires-Dist: flask[async]==3.1.1
20
19
  Requires-Dist: flask-cors==6.0.1
21
- Requires-Dist: geode-background==9.2.9
22
- Requires-Dist: geode-common==33.8.8
23
- Requires-Dist: geode-conversion==6.3.3
24
- Requires-Dist: geode-explicit==6.2.3
25
- Requires-Dist: geode-implicit==3.9.4
26
- Requires-Dist: geode-numerics==6.2.2
27
- Requires-Dist: geode-simplex==9.4.2
28
- Requires-Dist: geode-viewables==3.1.4
20
+ Requires-Dist: geode-background==9.4.0
21
+ Requires-Dist: geode-common==33.9.0
22
+ Requires-Dist: geode-conversion==6.4.0
23
+ Requires-Dist: geode-explicit==6.3.0
24
+ Requires-Dist: geode-implicit==4.1.1
25
+ Requires-Dist: geode-numerics==6.3.0
26
+ Requires-Dist: geode-simplex==9.6.0
27
+ Requires-Dist: geode-viewables==3.2.0
29
28
  Requires-Dist: itsdangerous==2.2.0
30
29
  Requires-Dist: jinja2==3.1.6
31
30
  Requires-Dist: markupsafe==3.0.2
32
- Requires-Dist: opengeode-core==15.21.2
33
- Requires-Dist: opengeode-geosciences==9.0.0
34
- Requires-Dist: opengeode-geosciencesio==5.4.2
35
- Requires-Dist: opengeode-inspector==6.6.1
36
- Requires-Dist: opengeode-io==7.2.1
37
- Requires-Dist: referencing==0.36.2
38
- Requires-Dist: rpds-py==0.25.1
39
- Requires-Dist: typing-extensions==4.14.0
31
+ Requires-Dist: opengeode-core==15.24.1
32
+ Requires-Dist: opengeode-geosciences==9.2.1
33
+ Requires-Dist: opengeode-geosciencesio==5.7.1
34
+ Requires-Dist: opengeode-inspector==6.7.0
35
+ Requires-Dist: opengeode-io==7.3.1
40
36
  Requires-Dist: werkzeug==3.1.3
41
37
  Dynamic: license-file
42
38
 
@@ -1,13 +1,13 @@
1
1
  opengeodeweb_back/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  opengeodeweb_back/app_config.py,sha256=gJfYxDJOa_PYLqjqgdXacp3W3F109uujE9LGPvzHOkc,728
3
- opengeodeweb_back/geode_functions.py,sha256=EPAM6pw9QwZfoeZjOxycFTKUANw6pdeXr2q3vsnPxt8,9121
4
- opengeodeweb_back/geode_objects.py,sha256=13A9FTGugiA9ClSeYkBiCu5QGzm93nm8YJQwiWB4nNw,25995
3
+ opengeodeweb_back/geode_functions.py,sha256=2lgL0FL8G5ZdJa-S_iUNWGlegHBJEDtU67Tuj5gtJ1c,9812
4
+ opengeodeweb_back/geode_objects.py,sha256=GrC1NltKKSCr0QSgcMy2ES8SLW_RkndCdrokeBOymrA,25995
5
5
  opengeodeweb_back/test_utils.py,sha256=18AbRW9-tfKkPcmRGilTTHXI7S3armYyV7Vdy5UvUKM,794
6
- opengeodeweb_back/utils_functions.py,sha256=RXMdQlCK3bLWYYDhkwOlYCeMpSRjMCejNlqDhxo2VNI,5254
7
- opengeodeweb_back/routes/blueprint_routes.py,sha256=uqcDIXa2Q7HRShEEVFJcOB6NAxPAYO1VyBMPxtyKl_0,12334
8
- opengeodeweb_back/routes/models/blueprint_models.py,sha256=EPSlgHnxZVeXwdzJ_TBAHlK6SsjXDk3f1sPYWR5eEL4,2183
9
- opengeodeweb_back/routes/models/schemas/mesh_components.json,sha256=3hgNqkxKDv691JGgjgMoqI_WgH2m7AtEFfjsOIqAz5Y,295
10
- opengeodeweb_back/routes/models/schemas/vtm_component_indices.json,sha256=0km8gzawPj-eFodhaGzAgNZjAEOl4wLy24f_Bs3pBlw,217
6
+ opengeodeweb_back/utils_functions.py,sha256=Q3NspzZJ50AvSQALgwFen8RJwHllQOGmNrhsSk_yVJU,7129
7
+ opengeodeweb_back/routes/blueprint_routes.py,sha256=3fxMR9fs0BqnOiYhKFacGdxWm7JFLz5i5PvUqYgB5z4,11308
8
+ opengeodeweb_back/routes/models/blueprint_models.py,sha256=PAyHSKjsvVm5gGfjUyWAnODmE0BJMsIWc1AWl0F3bO0,1955
9
+ opengeodeweb_back/routes/models/schemas/mesh_components.json,sha256=3OQvI4pUCe77WGC46tEr37rEWigQ6n2nsfGUTZRY074,419
10
+ opengeodeweb_back/routes/models/schemas/vtm_component_indices.json,sha256=0XILVxhAxi0RhQFDZZoUeGcAnBMroWz3kNJS7-6_dKQ,239
11
11
  opengeodeweb_back/routes/schemas/allowed_files.json,sha256=pRsGf39LiJpl3zEGLg4IqvRtm7iUx3Wq4Tb4tSFXGV0,234
12
12
  opengeodeweb_back/routes/schemas/allowed_objects.json,sha256=oy_YYpFzgDICx-keWqNIUpQM3zzB4eE3H6mPNxH9rWc,361
13
13
  opengeodeweb_back/routes/schemas/create_point.json,sha256=XjmXLMkr4jgWYHUKSwAhsxz1oLDZi8r8J0SY-QuEvks,386
@@ -16,14 +16,14 @@ opengeodeweb_back/routes/schemas/geographic_coordinate_systems.json,sha256=lnPqe
16
16
  opengeodeweb_back/routes/schemas/inspect_file.json,sha256=WoFF2hgZCUfqSDFJRq1sLpivjCQ6TCvSHPH8pKFY6KM,348
17
17
  opengeodeweb_back/routes/schemas/missing_files.json,sha256=eOBAkiphA-2xG6e-OAy7wcJK2FeY0YFYXJlLdr8SNSc,349
18
18
  opengeodeweb_back/routes/schemas/ping.json,sha256=MhI5jtrjMsAsfIKEzdY8p1HyV9xv4O3hYfESWw6tkyE,162
19
- opengeodeweb_back/routes/schemas/polygon_attribute_names.json,sha256=u-_ypRIejrDzbSc8tcb-6j6Av026SVJGC-RFPgaay7w,359
20
- opengeodeweb_back/routes/schemas/polyhedron_attribute_names.json,sha256=ImKRR2-38Ug3jAHaVEzmNaPNMTSoDE10-ZoALsnSjyg,362
19
+ opengeodeweb_back/routes/schemas/polygon_attribute_names.json,sha256=HJ_zVLJNdVL1snoK2mSo5Rb0XOIgiPVq1VLaDTORe54,433
20
+ opengeodeweb_back/routes/schemas/polyhedron_attribute_names.json,sha256=Fw6rcYxuHaiEAc_AcVzPy5ibajcr4wW3jyb2r7T0m-c,436
21
21
  opengeodeweb_back/routes/schemas/save_viewable_file.json,sha256=pvvEdaC7bNASPMrl3bXzlcA5blgflK0EYp2hBDf74qY,424
22
- opengeodeweb_back/routes/schemas/texture_coordinates.json,sha256=m0EqxlvKojXVxK5Csucodu3rq1YMVJPwXJN_Wreb3qc,355
22
+ opengeodeweb_back/routes/schemas/texture_coordinates.json,sha256=oW84Vh34KfleK935fmMXnqJXy-vaLDd7g87O_PtSzfY,429
23
23
  opengeodeweb_back/routes/schemas/upload_file.json,sha256=LJ3U3L5ApKuQDVFIpVT_y2alq4HW_suTvZ3HUucNbhg,219
24
- opengeodeweb_back/routes/schemas/vertex_attribute_names.json,sha256=bya9KGtTmHFWjD-ur0_0UAY2yf3KkMeuNrk6E1UkjLM,358
25
- opengeodeweb_back-5.8.7rc1.dist-info/licenses/LICENSE,sha256=LoTB-aqQvzTGxoTRXNnhNV0LKiqdk2bQv6MB34l8zkI,1079
26
- opengeodeweb_back-5.8.7rc1.dist-info/METADATA,sha256=iy0fGV58FJx9vdvGe5EgjDlf9KIej1eBT6yTC5B0Zuc,3036
27
- opengeodeweb_back-5.8.7rc1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
- opengeodeweb_back-5.8.7rc1.dist-info/top_level.txt,sha256=tN1FZeLIVBrdja2-pbmhg5-tK-JILmmT9OeIBnhlUrQ,18
29
- opengeodeweb_back-5.8.7rc1.dist-info/RECORD,,
24
+ opengeodeweb_back/routes/schemas/vertex_attribute_names.json,sha256=bmXG0pzVHMUTZY_0iu6ruX7eMUVk8wr2H1o4eEtBlg0,432
25
+ opengeodeweb_back-5.9.0rc2.dist-info/licenses/LICENSE,sha256=LoTB-aqQvzTGxoTRXNnhNV0LKiqdk2bQv6MB34l8zkI,1079
26
+ opengeodeweb_back-5.9.0rc2.dist-info/METADATA,sha256=G0-jcTd93p-b_uODLt2l8jLLsZBoBr2YLUBynqhjwIg,2900
27
+ opengeodeweb_back-5.9.0rc2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
+ opengeodeweb_back-5.9.0rc2.dist-info/top_level.txt,sha256=tN1FZeLIVBrdja2-pbmhg5-tK-JILmmT9OeIBnhlUrQ,18
29
+ opengeodeweb_back-5.9.0rc2.dist-info/RECORD,,