OpenGeodeWeb-Back 5.10.4rc1__py3-none-any.whl → 5.10.5rc1__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.

Potentially problematic release.


This version of OpenGeodeWeb-Back might be problematic. Click here for more details.

opengeodeweb_back/app.py CHANGED
@@ -14,7 +14,7 @@ from werkzeug.exceptions import HTTPException
14
14
  from opengeodeweb_back import utils_functions, app_config
15
15
  from opengeodeweb_back.routes import blueprint_routes
16
16
  from opengeodeweb_back.routes.models import blueprint_models
17
- from opengeodeweb_microservice.database.connection import init_database
17
+ from opengeodeweb_microservice.database import connection
18
18
 
19
19
 
20
20
  """ Global config """
@@ -39,6 +39,16 @@ SECONDS_BETWEEN_SHUTDOWNS: float = float(
39
39
  )
40
40
 
41
41
 
42
+ @app.before_request
43
+ def before_request() -> None:
44
+ utils_functions.before_request(flask.current_app)
45
+
46
+
47
+ @app.teardown_request
48
+ def teardown_request(exception: BaseException | None) -> None:
49
+ utils_functions.teardown_request(flask.current_app, exception)
50
+
51
+
42
52
  app.register_blueprint(
43
53
  blueprint_routes.routes,
44
54
  url_prefix="/opengeodeweb_back",
@@ -146,7 +156,7 @@ def run_server() -> None:
146
156
  app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}"
147
157
  app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
148
158
 
149
- init_database(db_path)
159
+ connection.init_database(db_path)
150
160
  print(f"Database initialized at: {db_path}", flush=True)
151
161
 
152
162
  app.run(debug=args.debug, host=args.host, port=args.port, ssl_context=SSL)
@@ -16,20 +16,6 @@ from .models import blueprint_models
16
16
  routes = flask.Blueprint("routes", __name__, url_prefix="/opengeodeweb_back")
17
17
 
18
18
 
19
- @routes.before_request
20
- def before_request():
21
- if "ping" not in flask.request.path:
22
- utils_functions.increment_request_counter(flask.current_app)
23
-
24
-
25
- @routes.teardown_request
26
- def teardown_request(exception):
27
-
28
- if "ping" not in flask.request.path:
29
- utils_functions.decrement_request_counter(flask.current_app)
30
- utils_functions.update_last_request_time(flask.current_app)
31
-
32
-
33
19
  routes.register_blueprint(
34
20
  blueprint_models.routes,
35
21
  url_prefix=blueprint_models.routes.url_prefix,
@@ -4,7 +4,6 @@ import threading
4
4
  import time
5
5
  import zipfile
6
6
  from collections.abc import Callable
7
- from typing import Any
8
7
  from concurrent.futures import ThreadPoolExecutor
9
8
 
10
9
  # Third party imports
@@ -41,13 +40,28 @@ def update_last_request_time(current_app: flask.Flask) -> None:
41
40
  current_app.config.update(LAST_REQUEST_TIME=LAST_REQUEST_TIME)
42
41
 
43
42
 
43
+ def terminate_session(exception: BaseException | None) -> None:
44
+ session = flask.g.pop("session", None)
45
+ if session is None:
46
+ return
47
+ if exception is None:
48
+ session.commit()
49
+ else:
50
+ session.rollback()
51
+ session.close()
52
+
53
+
44
54
  def before_request(current_app: flask.Flask) -> None:
45
55
  increment_request_counter(current_app)
56
+ flask.g.session = get_session()
46
57
 
47
58
 
48
- def teardown_request(current_app: flask.Flask) -> None:
59
+ def teardown_request(
60
+ current_app: flask.Flask, exception: BaseException | None = None
61
+ ) -> None:
49
62
  decrement_request_counter(current_app)
50
63
  update_last_request_time(current_app)
64
+ terminate_session(exception)
51
65
 
52
66
 
53
67
  def kill_task(current_app: flask.Flask) -> None:
@@ -97,7 +111,7 @@ def validate_request(request: flask.Request, schema: dict[str, str]) -> None:
97
111
 
98
112
 
99
113
  def set_interval(
100
- function: Callable[[Any], None], seconds: float, args: Any
114
+ function: Callable[[flask.Flask], None], seconds: float, args: flask.Flask
101
115
  ) -> threading.Timer:
102
116
  def function_wrapper() -> None:
103
117
  set_interval(function, seconds, args)
@@ -114,7 +128,7 @@ def extension_from_filename(filename: str) -> str:
114
128
 
115
129
 
116
130
  def send_file(
117
- upload_folder: str, saved_files: str, new_file_name: str
131
+ upload_folder: str, saved_files: list[str], new_file_name: str
118
132
  ) -> flask.Response:
119
133
  if len(saved_files) == 1:
120
134
  mimetype = "application/octet-binary"
@@ -162,19 +176,10 @@ def create_data_folder_from_id(data_id: str) -> str:
162
176
 
163
177
  def save_all_viewables_and_return_info(
164
178
  geode_object: str,
165
- data: Any,
166
- input_file: str | None = None,
167
- additional_files: list[str] | None = None,
168
- ) -> dict[str, Any]:
169
- if additional_files is None:
170
- additional_files = []
171
-
172
- data_entry = Data.create(
173
- geode_object=geode_object,
174
- input_file=input_file,
175
- additional_files=additional_files,
176
- )
177
- data_path = create_data_folder_from_id(data_entry.id)
179
+ data: object,
180
+ data_entry: Data,
181
+ data_path: str,
182
+ ) -> dict[str, str | list[str]]:
178
183
  with ThreadPoolExecutor() as executor:
179
184
  native_future = executor.submit(
180
185
  geode_functions.save,
@@ -202,10 +207,6 @@ def save_all_viewables_and_return_info(
202
207
  data_entry.viewable_file_name = os.path.basename(saved_viewable_file_path)
203
208
  data_entry.light_viewable = os.path.basename(saved_light_viewable_file_path)
204
209
 
205
- session = get_session()
206
- if session:
207
- session.commit()
208
-
209
210
  return {
210
211
  "native_file_name": data_entry.native_file_name,
211
212
  "viewable_file_name": data_entry.viewable_file_name,
@@ -219,23 +220,29 @@ def save_all_viewables_and_return_info(
219
220
 
220
221
 
221
222
  def generate_native_viewable_and_light_viewable_from_object(
222
- geode_object: str, data: Any
223
- ) -> dict[str, Any]:
224
- return save_all_viewables_and_return_info(geode_object, data, input_file="")
223
+ geode_object: str, data: object
224
+ ) -> dict[str, str | list[str]]:
225
+ data_entry = Data.create(
226
+ geode_object=geode_object,
227
+ viewer_object=geode_functions.get_object_type(geode_object),
228
+ input_file="",
229
+ additional_files=[],
230
+ )
231
+ data_path = create_data_folder_from_id(data_entry.id)
232
+ return save_all_viewables_and_return_info(geode_object, data, data_entry, data_path)
225
233
 
226
234
 
227
235
  def generate_native_viewable_and_light_viewable_from_file(
228
236
  geode_object: str, input_filename: str
229
- ) -> dict[str, Any]:
230
-
231
- session = get_session()
232
- temp_data_entry = Data.create(
237
+ ) -> dict[str, str | list[str]]:
238
+ data_entry = Data.create(
233
239
  geode_object=geode_object,
240
+ viewer_object=geode_functions.get_object_type(geode_object),
234
241
  input_file=input_filename,
235
242
  additional_files=[],
236
243
  )
237
244
 
238
- data_path = create_data_folder_from_id(temp_data_entry.id)
245
+ data_path = create_data_folder_from_id(data_entry.id)
239
246
 
240
247
  full_input_filename = geode_functions.upload_file_path(input_filename)
241
248
  copied_full_path = os.path.join(
@@ -260,14 +267,10 @@ def generate_native_viewable_and_light_viewable_from_file(
260
267
 
261
268
  data = geode_functions.load(geode_object, copied_full_path)
262
269
 
263
- if session:
264
- session.delete(temp_data_entry)
265
- session.flush()
266
- session.commit()
267
-
270
+ data_entry.additional_files = additional_files_copied
268
271
  return save_all_viewables_and_return_info(
269
272
  geode_object,
270
273
  data,
271
- input_file=input_filename,
272
- additional_files=additional_files_copied,
274
+ data_entry,
275
+ data_path,
273
276
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OpenGeodeWeb-Back
3
- Version: 5.10.4rc1
3
+ Version: 5.10.5rc1
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
@@ -27,7 +27,7 @@ Requires-Dist: opengeode-geosciencesio==5.8.0
27
27
  Requires-Dist: opengeode-inspector==6.8.1
28
28
  Requires-Dist: opengeode-io==7.4.0
29
29
  Requires-Dist: werkzeug==3.1.2
30
- Requires-Dist: opengeodeweb-microservice==1.*,>=1.0.4
30
+ Requires-Dist: opengeodeweb-microservice==1.*,>=1.0.5rc1
31
31
  Dynamic: license-file
32
32
 
33
33
  <h1 align="center">OpenGeodeWeb-Back<sup><i>by Geode-solutions</i></sup></h1>
@@ -1,12 +1,12 @@
1
1
  opengeodeweb_back/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- opengeodeweb_back/app.py,sha256=7sacDhOn73S4SBACvwvHonS5pOeu4ttuxrg32FRHlPQ,4509
2
+ opengeodeweb_back/app.py,sha256=_ws9UCqbR-_Hd4kE-Xh7FaGSulVRd7Au3KbOM3GUQ8I,4766
3
3
  opengeodeweb_back/app_config.py,sha256=z-omTiGj3-y0BZ1IchAM6EoTdC7vAX6B4OymEnuM0T4,843
4
4
  opengeodeweb_back/geode_functions.py,sha256=NzELy9s6AETDnm7tyA_uM2N89zrfeLdblRhzYrBONmw,10804
5
5
  opengeodeweb_back/geode_objects.py,sha256=_NclGPa024kCwUHdORkFuXYtiZBmQpgq6sO3LRkBhe8,27776
6
6
  opengeodeweb_back/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
7
7
  opengeodeweb_back/test_utils.py,sha256=18AbRW9-tfKkPcmRGilTTHXI7S3armYyV7Vdy5UvUKM,794
8
- opengeodeweb_back/utils_functions.py,sha256=1rpvfJF2qUinjUffSo2A2t6cQ2Dd-dbTLf_RzLFIkWg,9110
9
- opengeodeweb_back/routes/blueprint_routes.py,sha256=19W90mI3-jL80prgOU3aq8mBp3TM5-TO1rg244eZg2k,11394
8
+ opengeodeweb_back/utils_functions.py,sha256=tHU6VjyW-QwohDihdcoVSiD2TdGLeB0EtBjCorvVb8I,9327
9
+ opengeodeweb_back/routes/blueprint_routes.py,sha256=eTEKwKt9qc6cH1MDQ3lwmcnzLLxU_W8cYwu8HcUbXxo,10998
10
10
  opengeodeweb_back/routes/models/blueprint_models.py,sha256=Jo9pUDeu1nO3_IbBiuHGk57cc4_fhwxjM0EKNyv1FT0,1874
11
11
  opengeodeweb_back/routes/models/schemas/mesh_components.json,sha256=JmQUvpy7HpGS6FlThZLx1YjHqiInRTqUZ_Ft5MfOzEE,239
12
12
  opengeodeweb_back/routes/models/schemas/vtm_component_indices.json,sha256=0XILVxhAxi0RhQFDZZoUeGcAnBMroWz3kNJS7-6_dKQ,239
@@ -25,9 +25,9 @@ opengeodeweb_back/routes/schemas/save_viewable_file.json,sha256=pvvEdaC7bNASPMrl
25
25
  opengeodeweb_back/routes/schemas/texture_coordinates.json,sha256=2uQueIl1jOmxFG_gIi_vJETR4IurrwuSf8GAnzphk9g,237
26
26
  opengeodeweb_back/routes/schemas/upload_file.json,sha256=LJ3U3L5ApKuQDVFIpVT_y2alq4HW_suTvZ3HUucNbhg,219
27
27
  opengeodeweb_back/routes/schemas/vertex_attribute_names.json,sha256=ECIflohiqPZNsflAdkfEzksL4we0JvZhIxUd84Ubctg,240
28
- opengeodeweb_back-5.10.4rc1.dist-info/licenses/LICENSE,sha256=LoTB-aqQvzTGxoTRXNnhNV0LKiqdk2bQv6MB34l8zkI,1079
29
- opengeodeweb_back-5.10.4rc1.dist-info/METADATA,sha256=Xqwl-aMPwSAKyaRsiRMWpE-QFTcMBLcfuf08VRp1lyg,2665
30
- opengeodeweb_back-5.10.4rc1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- opengeodeweb_back-5.10.4rc1.dist-info/entry_points.txt,sha256=3W_t5GFc9ROHSIZ55IGvYU3DLHUFQmYOM4Bm9u3Z0cE,71
32
- opengeodeweb_back-5.10.4rc1.dist-info/top_level.txt,sha256=tN1FZeLIVBrdja2-pbmhg5-tK-JILmmT9OeIBnhlUrQ,18
33
- opengeodeweb_back-5.10.4rc1.dist-info/RECORD,,
28
+ opengeodeweb_back-5.10.5rc1.dist-info/licenses/LICENSE,sha256=LoTB-aqQvzTGxoTRXNnhNV0LKiqdk2bQv6MB34l8zkI,1079
29
+ opengeodeweb_back-5.10.5rc1.dist-info/METADATA,sha256=6LnIyanx13uNBllBS48qFz4J41ZJ7nAOZDnPu9nIyKs,2668
30
+ opengeodeweb_back-5.10.5rc1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
+ opengeodeweb_back-5.10.5rc1.dist-info/entry_points.txt,sha256=3W_t5GFc9ROHSIZ55IGvYU3DLHUFQmYOM4Bm9u3Z0cE,71
32
+ opengeodeweb_back-5.10.5rc1.dist-info/top_level.txt,sha256=tN1FZeLIVBrdja2-pbmhg5-tK-JILmmT9OeIBnhlUrQ,18
33
+ opengeodeweb_back-5.10.5rc1.dist-info/RECORD,,