class LoadLaunchArgs:
"""
A class to represent and manage the argument settings for an experiment setup in MultiMalModPy.
This class allows for initialization of various experiment parameters with default values, which can be
overridden by user-provided values during object instantiation. It also provides methods to update the
arguments after instantiation and to represent the current argument settings as a string.
Attributes:
directory (str or None): Directory where data is stored or to be saved.
suite (str): The name of the suite, default is a string with the current date.
expname (str): The name of the experiment, default is a string with the current time.
emodstep (str or None): The EMOD step name.
serializedid (str): A serialized identifier for the experiment.
models (list of str): A list of models to be used in the experiment, default includes 'OpenMalaria' and 'malariasimulation'.
user (str): The username of the person running the experiment, fetched from the environment.
csv (str or None): CSV file for input data, if applicable.
rownum (int or None): Row number in the CSV, if applicable.
run_mode (str or None): The mode in which to run the simulation.
emod_calib_params (bool): Whether to enable EMOD calibration parameters, default is False.
overwrite (bool): Whether to overwrite existing files, default is False.
mpv (bool): Whether to use MPV (most probable value), default is True.
target_output_name (str): The type of output expected, default is 'prevalence_2to10'.
Methods:
__init__(**kwargs): Initializes the Args object with default values, which can be overridden by user-provided values.
update(**kwargs): Updates the Args object with new values after initialization.
__repr__(): Returns a string representation of the current argument settings.
Args:
kwargs (dict): Optional keyword arguments to override default argument values during initialization.
"""
def __init__(self, **kwargs):
"""
Initialize the Args object with default values.
User-provided values can override these defaults.
"""
from datetime import datetime as dt
# Default values
self.directory = None
self.suite = f'test_{dt.now().strftime("%Y%m%d")}'
self.expname = f'sims_entomologymode_seasonality_intervention_{dt.now().strftime("%H_%M_%S")}'
self.emodstep = None
self.serializedid = ''
self.models = ['OpenMalaria', 'malariasimulation'] # 'EMOD'
self.user = os.environ.get('USER')
self.csv = None
self.rownum = None
self.run_mode = 'custom'
self.emod_calib_params = False
self.overwrite = False
self.mpv = True
self.test = True
self.note = ''
self.target_output_name = 'prevalence_2to10'
# Update with any user-provided values
for key, value in kwargs.items():
if hasattr(self, key):
setattr(self, key, value)
def update(self, **kwargs):
"""
Update the Args object with new values.
"""
for key, value in kwargs.items():
if hasattr(self, key):
setattr(self, key, value)
def __repr__(self):
"""
Return a string representation of the current argument settings.
"""
return (f"Args(directory={self.directory}, suite={self.suite}, expname={self.expname}, "
f"emodstep={self.emodstep}, serializedid={self.serializedid}, models={self.models}, "
f"user={self.user}, csv={self.csv}, rownum={self.rownum}, "
f"run_mode={self.run_mode}, emod_calib_params={self.emod_calib_params}, "
f"overwrite={self.overwrite}, mpv={self.mpv}, test={self.test}, note={self.note}, target_output_name={self.target_output_name})")