Skip to content

Commit

Permalink
v3.6.6 - Return result path from run_simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin De Schepper committed Feb 8, 2021
1 parent 74add0d commit 2a10ff9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 3.6

## 3.6.6

* The return values of simulations are now the path to their result file.

## 3.6.5

* Fixed a bug with the NEURON adapter transmitter map causing loss of spike transmission.
Expand Down
2 changes: 1 addition & 1 deletion bsb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "3.6.5"
__version__ = "3.6.6"

from .reporting import set_verbosity, report, warn
4 changes: 2 additions & 2 deletions bsb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,14 @@ def run_simulation(self, simulation_name, quit=False):
listener = ReportListener(self, report_file)
simulation.add_progress_listener(listener)
simulation.simulate(simulator)
simulation.collect_output()
result_path = simulation.collect_output()
time_sim = time.time() - t
report("Simulation runtime: {}".format(time_sim), level=2)
if quit and hasattr(simulator, "quit"):
simulator.quit()
time_sim = time.time() - t
report("Simulation runtime: {}".format(time_sim), level=2)
return simulation
return result_path

def get_simulation(self, simulation_name):
"""
Expand Down
7 changes: 5 additions & 2 deletions bsb/simulators/nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,10 @@ def collect_output(self):
print(str(e))
rank = 0

timestamp = str(time.time()).split(".")[0] + str(_randint())
result_path = "results_" + self.name + "_" + timestamp + ".hdf5"
if rank == 0:
timestamp = str(time.time()).split(".")[0] + str(_randint())
with h5py.File("results_" + self.name + "_" + timestamp + ".hdf5", "a") as f:
with h5py.File(result_path, "a") as f:
for path, data, meta in self.result.safe_collect():
try:
path = "/".join(path)
Expand All @@ -542,6 +543,8 @@ def collect_output(self):
path, "{} {}".format(data.dtype, data.shape)
)
)
mpi4py.MPI.COMM_WORLD.bcast(result_path, root=0)
return result_path

def validate(self):
for cell_model in self.cell_models.values():
Expand Down
6 changes: 3 additions & 3 deletions bsb/simulators/neuron/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,12 @@ def collect_output(self):

timestamp = str(time.time()).split(".")[0] + str(random.random()).split(".")[1]
timestamp = self.pc.broadcast(timestamp)
result_path = "results_" + self.name + "_" + timestamp + ".hdf5"
for node in range(self.scaffold.MPI.COMM_WORLD.size):
self.pc.barrier()
if node == self.pc_id:
report("Node", self.pc_id, "is writing", level=2, all_nodes=True)
with h5py.File(
"results_" + self.name + "_" + timestamp + ".hdf5", "a"
) as f:
with h5py.File(result_path, "a") as f:
for path, data, meta in self.result.safe_collect():
try:
path = "/".join(path)
Expand All @@ -403,6 +402,7 @@ def collect_output(self):
)
)
self.pc.barrier()
return result_path

def create_transmitters(self):
# Concatenates all the `from` locations of all intersections together and creates
Expand Down

0 comments on commit 2a10ff9

Please sign in to comment.