Skip to content

Commit 0ddb914

Browse files
committed
[ENH] Getting the server running again
1 parent 3772edf commit 0ddb914

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

gempy_engine/API/server/_process_output.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ def process_output(meshes: list[DualContouringMesh], n_stack: int, solutions: So
1818
unstructured_data_meshes: UnstructuredData = _meshes_to_unstruct(meshes, logger)
1919
if PLOT_SUBSURFACE_OBJECT:
2020
_plot_subsurface_object(unstructured_data_meshes)
21-
body_meshes, header_meshes = unstructured_data_meshes.to_binary()
22-
header_json = json.dumps(header_meshes)
23-
header_json_bytes = header_json.encode('utf-8')
24-
header_json_length = len(header_json_bytes)
25-
header_json_length_bytes = header_json_length.to_bytes(4, byteorder='little')
26-
body_meshes = header_json_length_bytes + header_json_bytes + body_meshes
21+
body_meshes = unstructured_data_meshes.to_binary()
22+
# header_json = json.dumps(header_meshes)
23+
# header_json_bytes = header_json.encode('utf-8')
24+
# header_json_length = len(header_json_bytes)
25+
# header_json_length_bytes = header_json_length.to_bytes(4, byteorder='little')
26+
# body_meshes = header_json_length_bytes + header_json_bytes + body_meshes
2727

2828
# * serialize octrees
2929
unstructured_data_volume = subsurface.UnstructuredData.from_array(
@@ -35,12 +35,12 @@ def process_output(meshes: list[DualContouringMesh], n_stack: int, solutions: So
3535
) # TODO: We have to create an array with the shape of simplex array with the id of each simplex
3636
)
3737

38-
body_volume, header_volume = unstructured_data_volume.to_binary()
39-
header_json = json.dumps(header_volume)
40-
header_json_bytes = header_json.encode('utf-8')
41-
header_json_length = len(header_json_bytes)
42-
header_json_length_bytes = header_json_length.to_bytes(4, byteorder='little')
43-
body_volume = header_json_length_bytes + header_json_bytes + body_volume
38+
body_volume= unstructured_data_volume.to_binary()
39+
# header_json = json.dumps(header_volume)
40+
# header_json_bytes = header_json.encode('utf-8')
41+
# header_json_length = len(header_json_bytes)
42+
# header_json_length_bytes = header_json_length.to_bytes(4, byteorder='little')
43+
# body_volume = header_json_length_bytes + header_json_bytes + body_volume
4444

4545
# * serialize global header
4646
body = body_meshes + body_volume

gempy_engine/API/server/main_server_pro.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ def compute_gempy_model(gempy_input: GemPyInput):
8181
logger.info("Finished computing model")
8282
# logger.debug("first mesh vertices:", solutions.dc_meshes[0].vertices)
8383

84-
body = process_output(
84+
body:bytes = process_output(
8585
meshes=solutions.dc_meshes,
8686
n_stack=n_stack,
8787
solutions=solutions,
8888
logger=logger
8989
)
9090

91+
size_in_mb = len(body) / 1024 / 1024
9192
logger.info("Finished running GemPy Engine")
9293
response = fastapi.Response(content=body, media_type='application/octet-stream')
9394
return response

tests/test_server/tests_server_I.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def test_post_example_json(client):
4141
headers={"Content-Type": "application/json"}
4242
)
4343

44-
print(response.json())
44+
# Deserialize octet-stream response
4545
assert response.status_code == 200
46-
result = response.json()
47-
assert "result" in result or "scalar_field" in result
4846

4947

48+
@pytest.mark.skip(reason="Not implemented yet")
5049
def test_post_features_json(client):
50+
raise NotImplementedError
5151
"""Test POST request with 2features.json data"""
5252
data = load_request_data(FEATURES_JSON_PATH)
5353
assert data is not None, f"Failed to load data from {FEATURES_JSON_PATH}"

0 commit comments

Comments
 (0)