Skip to content

Commit 1c0c2d9

Browse files
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWeb-Back into fix/refactor_kill
2 parents 1f23e55 + 9d6ce14 commit 1c0c2d9

File tree

3 files changed

+46
-35
lines changed

3 files changed

+46
-35
lines changed

mypy.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[mypy]
22
strict = True
3-
files = src/
3+
files = src/
4+
disallow_untyped_decorators = False

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ click==8.*,>=8.3.0
1212
# via flask
1313
fastjsonschema==2.*,>=2.21.1
1414
# via opengeodeweb-microservice
15-
flask[async]==3.0.3
15+
flask[async]==3.*,>=3.0.3
1616
# via
1717
# -r requirements.in
1818
# flask
@@ -36,7 +36,7 @@ itsdangerous==2.*,>=2.2.0
3636
# via flask
3737
jinja2==3.*,>=3.1.6
3838
# via flask
39-
markupsafe==3.*,>=3.0.2
39+
markupsafe==3.*,>=3.0.3
4040
# via
4141
# jinja2
4242
# werkzeug

src/opengeodeweb_back/utils_functions.py

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import zipfile
66
from collections.abc import Callable
77
from typing import Any
8+
from concurrent.futures import ThreadPoolExecutor
89

910
# Third party imports
1011
import flask
@@ -175,38 +176,47 @@ def save_all_viewables_and_return_info(
175176
additional_files=additional_files,
176177
)
177178
data_path = create_data_folder_from_id(data_entry.id)
178-
saved_native_file_path = geode_functions.save(
179-
geode_object,
180-
data,
181-
data_path,
182-
"native." + data.native_extension(),
183-
)
184-
saved_viewable_file_path = geode_functions.save_viewable(
185-
geode_object, data, data_path, "viewable"
186-
)
187-
saved_light_viewable_file_path = geode_functions.save_light_viewable(
188-
geode_object, data, data_path, "light_viewable"
189-
)
190-
with open(saved_light_viewable_file_path, "rb") as f:
191-
binary_light_viewable = f.read()
192-
data_entry.native_file_name = os.path.basename(saved_native_file_path[0])
193-
data_entry.viewable_file_name = os.path.basename(saved_viewable_file_path)
194-
data_entry.light_viewable = os.path.basename(saved_light_viewable_file_path)
195-
196-
session = get_session()
197-
if session:
198-
session.commit()
199-
200-
return {
201-
"native_file_name": data_entry.native_file_name,
202-
"viewable_file_name": data_entry.viewable_file_name,
203-
"id": data_entry.id,
204-
"object_type": geode_functions.get_object_type(geode_object),
205-
"binary_light_viewable": binary_light_viewable.decode("utf-8"),
206-
"geode_object": data_entry.geode_object,
207-
"input_files": data_entry.input_file,
208-
"additional_files": data_entry.additional_files,
209-
}
179+
with ThreadPoolExecutor() as executor:
180+
native_future = executor.submit(
181+
geode_functions.save,
182+
geode_object,
183+
data,
184+
data_path,
185+
"native." + data.native_extension(),
186+
)
187+
viewable_future = executor.submit(
188+
geode_functions.save_viewable, geode_object, data, data_path, "viewable"
189+
)
190+
light_viewable_future = executor.submit(
191+
geode_functions.save_light_viewable,
192+
geode_object,
193+
data,
194+
data_path,
195+
"light_viewable",
196+
)
197+
saved_light_viewable_file_path = light_viewable_future.result()
198+
with open(saved_light_viewable_file_path, "rb") as f:
199+
binary_light_viewable = f.read()
200+
saved_native_file_path = native_future.result()
201+
saved_viewable_file_path = viewable_future.result()
202+
data_entry.native_file_name = os.path.basename(saved_native_file_path[0])
203+
data_entry.viewable_file_name = os.path.basename(saved_viewable_file_path)
204+
data_entry.light_viewable = os.path.basename(saved_light_viewable_file_path)
205+
206+
session = get_session()
207+
if session:
208+
session.commit()
209+
210+
return {
211+
"native_file_name": data_entry.native_file_name,
212+
"viewable_file_name": data_entry.viewable_file_name,
213+
"id": data_entry.id,
214+
"object_type": geode_functions.get_object_type(geode_object),
215+
"binary_light_viewable": binary_light_viewable.decode("utf-8"),
216+
"geode_object": data_entry.geode_object,
217+
"input_files": data_entry.input_file,
218+
"additional_files": data_entry.additional_files,
219+
}
210220

211221

212222
def generate_native_viewable_and_light_viewable_from_object(

0 commit comments

Comments
 (0)