Closed nnelissen closed 4 years ago
@nnelissen
Just to help me replicate this can you let me know:
python microsim/microsim_model.py
here?I think this might be an expected behaviour of os.mkdir
unless you pass it some additional arguments, so might require a little refactoring for these multiple runs to prevent overwriting.
This is microsim/microsim_model.py from master but changed nr iterations and nr repetitions in default.yml to 4 for each:
scenario_name: test0 # A name describing the scenario. Output data will be stored in a subdirectory with this name.
microsim: # Parameters for the microsimulation (python) part iterations: 4 # Number of model iterations. 0 means just run the initialisation. data-dir: devon_data # Root directory to load data from output: true # Whether to generate output or not debug: false # Whether to run some more expensive checks repetitions: 4 # How many times to run the model lockdown-from-file: true #Read lockdown mobility data from a file?
disease: x: 1 # This is where the parameter for the disease model (the R part) can go
@Sparrow0hawk As predicted, it has just run without errors if you set repetitions to 1.
@nnelissen OK i'll look at developing a fix.
When we do runs with multiple repeitions we'd expect a new data folder for each repetition?
If I implement something that did:
os.mkdir(results_subdir + "_" + repetition_value)
Would that be acceptable?
We also run into the question of what we'd want to happen if data already exists in outputs/
directory, do we want it to overwrite? Or should we be creating another directory level (maybe for the date of the run) in outputs/
so it never overwrites data?
@Sparrow0hawk I'm not sure anymore - I haven't seen this version recently. I thought iterations was days in the model (which all get saved into same pickle file in 1 directory) and repetitions is reruns of the model (to find an average that is less dependent on outliers etc, 1 directory per rerun). If that's correct, your idea would fix it: create a new directory for each rerun/repetition. Personally I would want to overwrite, but I vaguely remember Nick checking if the directory exists and if so, going for the next number up so it doesn't overwrite
@nnelissen OK, in which case i'll look at developing a fix but we can wait till @nickmalleson is back to talk through more
Scenario names for directories are now specified in defaults.yml. If the directory already exists, it gets incremental numbers (as used for runs previously). The yml file is copied into the directory so it's easy to check which parameters were used.
@Sparrow0hawk When running more than 1 set (I think parameter repetitions), seems to want to re-use existing directory from previous repetition? Full error below:
Iteration 3 took 118.96s Model finished running (iterations: 4) multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/multiprocessing/pool.py", line 47, in starmapstar return list(itertools.starmap(args[0], args[1])) File "microsim/microsim_model.py", line 1658, in _run_multicore return m.run(iter) File "microsim/microsim_model.py", line 1497, in run self._init_output() File "microsim/microsim_model.py", line 1129, in _init_output self.output_dir = Microsim._find_new_directory(os.path.join(self.DATA_DIR, "output")) File "microsim/microsim_model.py", line 299, in _find_new_directory raise e File "microsim/microsim_model.py", line 296, in _find_new_directory os.mkdir(results_subdir) FileExistsError: [Errno 17] File exists: '/home/natalie/Documents/RAMP-UA/devon_data/output/2' """
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "microsim/microsim_model.py", line 1662, in
run_script()
File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/site-packages/click/core.py", line 829, in call
return self.main(args, kwargs)
File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, ctx.params)
File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(args, *kwargs)
File "microsim/microsim_model.py", line 1650, in run_script
pool.starmap(_run_multicore, zip(models, iters))
File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/multiprocessing/pool.py", line 276, in starmap
return self._map_async(func, iterable, starmapstar, chunksize).get()
File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/multiprocessing/pool.py", line 657, in get
raise self._value
File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(args, **kwds))
File "/home/natalie/anaconda3/envs/ramp-ua/lib/python3.7/multiprocessing/pool.py", line 47, in starmapstar
return list(itertools.starmap(args[0], args[1]))
File "microsim/microsim_model.py", line 1658, in _run_multicore
return m.run(iter)
File "microsim/microsim_model.py", line 1497, in run
self._init_output()
File "microsim/microsim_model.py", line 1129, in _init_output
self.output_dir = Microsim._find_new_directory(os.path.join(self.DATA_DIR, "output"))
File "microsim/microsim_model.py", line 299, in _find_new_directory
raise e
File "microsim/microsim_model.py", line 296, in _find_new_directory
os.mkdir(results_subdir)
FileExistsError: [Errno 17] File exists: '/home/natalie/Documents/RAMP-UA/devon_data/output/2'