Checkpoint saver
combine_checkpoints_for_ranks(hdf5_file_root)
After running a parallel simulation with checkpoints, the checkpoint data will be scattered accross, with each process saving a checkpoint_date.0.hdf5 file. This function can be used to unify all data in one single checkpoint, so that we can load it later with any arbitray number of cores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf5_file_root
|
str
|
the str root of the pasts like "checkpoint_2020-01-01". The checkpoint files |
required |
will be expected to have names like "checkpoint_2020-01-01.{rank}.hdf5 where rank = 0, 1, 2, etc.
Source code in june/hdf5_savers/checkpoint_saver.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
generate_simulator_from_checkpoint(world, checkpoint_path, interaction, chunk_size=50000, epidemiology=None, tracker=None, policies=None, leisure=None, travel=None, events=None, config_filename=default_config_filename, record=None, reset_infections=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
world
|
World
|
|
required |
checkpoint_path
|
str
|
|
required |
interaction
|
Interaction
|
|
required |
chunk_size
|
Optional[int]
|
(Default value = 50000) |
50000
|
epidemiology
|
Optional[Epidemiology]
|
(Default value = None) |
None
|
tracker
|
Optional[Tracker]
|
(Default value = None) |
None
|
policies
|
Optional[Policies]
|
(Default value = None) |
None
|
leisure
|
Optional[Leisure]
|
(Default value = None) |
None
|
travel
|
Optional[Travel]
|
(Default value = None) |
None
|
events
|
Optional[Events]
|
(Default value = None) |
None
|
config_filename
|
str
|
(Default value = default_config_filename) |
default_config_filename
|
record
|
Record
|
(Default value = None) |
None
|
reset_infections
|
(Default value = False) |
False
|
Source code in june/hdf5_savers/checkpoint_saver.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
load_checkpoint_from_hdf5(hdf5_file_path, chunk_size=50000, load_date=True)
Loads checkpoint data from hdf5.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf5_file_path
|
str
|
hdf5 path to load from |
required |
chunk_size
|
number of hdf5 chunks to use while loading (Default value = 50000) |
50000
|
|
load_date
|
(Default value = True) |
True
|
Source code in june/hdf5_savers/checkpoint_saver.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
restore_simulator_to_checkpoint(simulator, world, checkpoint_path, chunk_size=50000, reset_infections=False)
Initialises the simulator from a saved checkpoint. The arguments are the same as the standard .from_file() initialisation but with the additional path to where the checkpoint pickle file is located. The checkpoint saves information about the infection status of all the people in the world as well as the timings. Note, nonetheless, that all the past infections / deaths will have the checkpoint date as date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulator
|
An instance of the Simulator class |
required | |
world
|
World
|
|
required |
checkpoint_path
|
str
|
path to the hdf5 file containing the checkpoint data |
required |
chunk_size
|
Optional[int]
|
chunk load size of the hdf5 (Default value = 50000) |
50000
|
reset_infections
|
(Default value = False) |
False
|
Source code in june/hdf5_savers/checkpoint_saver.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
save_checkpoint_to_hdf5(population, date, hdf5_file_path, chunk_size=50000)
Saves a checkpoint at the given date by saving the infection information of the world.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
population
|
Population
|
world's population |
required |
date
|
str
|
date of the checkpoint |
required |
hdf5_file_path
|
str
|
path where to save the hdf5 checkpoint |
required |
chunk_size
|
int
|
hdf5 chunk_size to write data (Default value = 50000) |
50000
|
Source code in june/hdf5_savers/checkpoint_saver.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|