Skip to content

Commit 56f6f70

Browse files
authored
Merge pull request #3488 from vvorobjov/nest-server-mpi-serialization
Update the data serialization in hl_api_server.py
2 parents 817a0d9 + edd0a3f commit 56f6f70

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pynest/nest/lib/hl_api_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,8 @@ def serialize_data(data):
12861286

12871287
if isinstance(data, (numpy.ndarray, NodeCollection)):
12881288
return data.tolist()
1289+
if isinstance(data, (numpy.integer)):
1290+
return int(data)
12891291
elif isinstance(data, SynapseCollection):
12901292
# Get full information from SynapseCollection
12911293
return serialize_data(data.get())

pynest/nest/server/hl_api_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def do_call(call_name, args=[], kwargs={}):
261261
log(call_name, f"local call, args={args}, kwargs={kwargs}")
262262
master_response = call(*args, **kwargs)
263263

264-
response = [master_response]
264+
response = [nest.serialize_data(master_response)]
265265
if mpi_comm is not None:
266266
log(call_name, "waiting for response gather")
267267
response = mpi_comm.gather(response[0], root=0)
@@ -277,7 +277,7 @@ def route_exec():
277277
if EXEC_CALL_ENABLED:
278278
args, kwargs = get_arguments(request)
279279
response = do_call("exec", args, kwargs)
280-
return jsonify(response)
280+
return jsonify(nest.serialize_data(response))
281281
else:
282282
flask.abort(
283283
403,
@@ -307,7 +307,7 @@ def route_api_call(call):
307307
args, kwargs = get_arguments(request)
308308
log("route_api_call", f"call={call}, args={args}, kwargs={kwargs}")
309309
response = api_client(call, args, kwargs)
310-
return jsonify(response)
310+
return jsonify(nest.serialize_data(response))
311311

312312

313313
# ----------------------

0 commit comments

Comments
 (0)