parasweep.sweep module¶
Main sweep functionality.
-
parasweep.sweep.run_sweep(command, configs, templates, sweep, namer=<parasweep.namers.SequentialNamer object>, dispatcher=<parasweep.dispatchers.SubprocessDispatcher object>, template_engine=<parasweep.templates.PythonFormatTemplate object>, sweep_id=None, excluded_sim_ids=[], serial=False, wait=True, cleanup=False, verbose=True, overwrite=True, save_mapping=True)[source]¶ Run parameter sweeps.
Parameters: - command (str) – The command to run. Must include
{sim_id}indicating where the simulation ID is to be inserted. - configs (list) – List of paths indicating where the configuration files should be saved
after substitution of the parameters into the templates. Each must
include
{sim_id}indicating where the simulation ID is to be inserted. Must be in the same order astemplates. - templates (list) – List of paths of templates to substitute parameters into. Must be in
the same order as
configs. - sweep (sweepers.Sweep instance) – A
parasweep.sweepers.Sweepobject that specifies the type of sweep. By default, it is a Cartesian sweep. - namer (namers.Namer instance, optional) – A
parasweep.namers.Namerobject that specifies how to assign simulation IDs. By default, assigns simulation IDs sequentially. - dispatcher (dispatchers.Dispatcher instance, optional) – A
parasweep.dispatchers.Dispatcherobject that specifies how to run the jobs. By default, uses Python’ssubprocessmodule. - template_engine (templates.TemplateEngine instance, optional) – A
parasweep.templates.TemplateEngineobject that specifies the template engine to use. By default, uses Python format strings. - sweep_id (str, optional) – A name for the sweep. By default, the name is generated automatically from the date and time.
- excluded_sim_ids (list, optional) – A list of simulation IDs to exclude from the sweep.
- serial (bool, optional) – Whether to run simulations serially, i.e., to wait for each simulation to complete before executing the next one. Enabling this turns off parallelism. False by default.
- wait (bool, optional) – Whether to wait for all simulations to complete before returning. True by default.
- cleanup (bool, optional) – Whether to delete configuration files after all the simulations are
done. This will cause the command to wait on all processes before
returning (as with the
waitargument). False by default. - verbose (bool, optional) – Whether to print some information about each simulation as it is launched. True by default.
- overwrite (bool, optional) – Whether to overwrite existing files when creating configuration files.
If False, a
FileExistsErrorwill be raised when a configuration filename coincides with an existing one in the same directory. True by default. - save_mapping (bool, optional) – Whether to save a mapping between the parameters to the simulation
IDs. The type of mapping will depend on the type of sweep (set with
the
sweepargument). The filename will be of the formsim_ids_{sweep_id}, with an extension depending on the mapping type. True by default.
Examples
Many examples are provided in Examples.
- command (str) – The command to run. Must include