Skip to content

Commit

Permalink
Added fallback filename if unable to write simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjorthmedh committed Sep 23, 2024
1 parent f3e426a commit d248744
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"network_file": "networks/neuromodulation_bath_current/network-synapses.hdf5",
"output_file": "networks/neuromodulation_bath_current/simulation/output_neuromodulation_ON.hdf5",
"log_file": "networks/neuromodulation_bath_current/log/network-simulation-ON.txt",
"time": 1.5,
"time": 2.5,
"record_all_soma": true,
"record_rxd_species_all": [0, 1],
"record_density_mechanism": {
Expand Down Expand Up @@ -30,8 +30,8 @@
"rxd_enable_extracellular": false,
"bath_application": {
"DA": {
"time": [0, 0.499, 0.5, 0.99, 1.0, 10],
"concentration": [20e-6, 20e-6, 60e-6, 60e-6, 100e-6, 100e-6],
"time": [0, 0.499, 0.5, 0.99, 1.0, 1.5, 1.51, 10],
"concentration": [20e-9, 20e-9, 60e-6, 60e-6, 100e-6, 100e-6, 0, 0],
"interpolate": true
}
},
Expand Down
19 changes: 18 additions & 1 deletion snudda/simulate/save_network_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,24 @@ def write_header(self):
os.mkdir(os.path.dirname(self.output_file))

print(f"Writing network output to {self.output_file}")
out_file = h5py.File(self.output_file, "w")

try:
out_file = h5py.File(self.output_file, "w")
except Exception as e:

print(e)
print(f"Trying to recover, and save to different file name.")

ctr = 1
temp_name = f"{self.output_file}-{ctr}"

while os.path.isfile(temp_name):
print(f"File exists: {temp_name}")
ctr += 1
temp_name = f"{self.output_file}-{ctr}"

print(f"\n!!! Unable to create {self.output_file} (file locked?), using {temp_name} instead\n\n")
out_file = h5py.File(temp_name, "w")

meta_data = out_file.create_group("meta_data")

Expand Down

0 comments on commit d248744

Please sign in to comment.