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.Sweep
object that specifies the type of sweep. By default, it is a Cartesian sweep. - namer (namers.Namer instance, optional) – A
parasweep.namers.Namer
object that specifies how to assign simulation IDs. By default, assigns simulation IDs sequentially. - dispatcher (dispatchers.Dispatcher instance, optional) – A
parasweep.dispatchers.Dispatcher
object that specifies how to run the jobs. By default, uses Python’ssubprocess
module. - template_engine (templates.TemplateEngine instance, optional) – A
parasweep.templates.TemplateEngine
object 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
wait
argument). 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
FileExistsError
will 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
sweep
argument). 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