aegis_sim.recording.picklerecorder

 1import logging
 2import pathlib
 3
 4from .recorder import Recorder
 5from aegis_sim import variables
 6
 7from aegis_sim.parameterization import parametermanager
 8from aegis_sim.utilities.funcs import skip
 9
10class PickleRecorder(Recorder):
11    def __init__(self, odir: pathlib.Path):
12        self.odir = odir / "pickles"
13        self.init_odir()
14
15    def write(self, population):
16        """
17
18        # OUTPUT SPECIFICATION
19        path: /pickles/{step}
20        filetype: pickle
21        category: log
22        description: A file that records the Population class instance which can be used to seed a future simulation.
23        trait granularity: individual
24        time granularity: snapshot
25        frequency parameter: PICKLE_RATE
26        structure: Binary python file.
27        """
28
29        step = variables.steps
30        should_skip = skip("PICKLE_RATE")
31        is_first_step = step == 1
32        is_last_step = step == parametermanager.parameters.STEPS_PER_SIMULATION
33
34        if is_first_step or not should_skip or is_last_step:
35            logging.debug(f"pickle recorded at step {step}.")
36            path = self.odir / str(step)
37            population.save_pickle_to(path)
class PickleRecorder(aegis_sim.recording.recorder.Recorder):
11class PickleRecorder(Recorder):
12    def __init__(self, odir: pathlib.Path):
13        self.odir = odir / "pickles"
14        self.init_odir()
15
16    def write(self, population):
17        """
18
19        # OUTPUT SPECIFICATION
20        path: /pickles/{step}
21        filetype: pickle
22        category: log
23        description: A file that records the Population class instance which can be used to seed a future simulation.
24        trait granularity: individual
25        time granularity: snapshot
26        frequency parameter: PICKLE_RATE
27        structure: Binary python file.
28        """
29
30        step = variables.steps
31        should_skip = skip("PICKLE_RATE")
32        is_first_step = step == 1
33        is_last_step = step == parametermanager.parameters.STEPS_PER_SIMULATION
34
35        if is_first_step or not should_skip or is_last_step:
36            logging.debug(f"pickle recorded at step {step}.")
37            path = self.odir / str(step)
38            population.save_pickle_to(path)
PickleRecorder(odir: pathlib.Path)
12    def __init__(self, odir: pathlib.Path):
13        self.odir = odir / "pickles"
14        self.init_odir()
odir
def write(self, population):
16    def write(self, population):
17        """
18
19        # OUTPUT SPECIFICATION
20        path: /pickles/{step}
21        filetype: pickle
22        category: log
23        description: A file that records the Population class instance which can be used to seed a future simulation.
24        trait granularity: individual
25        time granularity: snapshot
26        frequency parameter: PICKLE_RATE
27        structure: Binary python file.
28        """
29
30        step = variables.steps
31        should_skip = skip("PICKLE_RATE")
32        is_first_step = step == 1
33        is_last_step = step == parametermanager.parameters.STEPS_PER_SIMULATION
34
35        if is_first_step or not should_skip or is_last_step:
36            logging.debug(f"pickle recorded at step {step}.")
37            path = self.odir / str(step)
38            population.save_pickle_to(path)

OUTPUT SPECIFICATION

path: /pickles/{step} filetype: pickle category: log description: A file that records the Population class instance which can be used to seed a future simulation. trait granularity: individual time granularity: snapshot frequency parameter: PICKLE_RATE structure: Binary python file.