Package topo :: Package command :: Module basic :: Class run_batch
[hide private]
[frames] | no frames]

Class run_batch

source code


Run a Topographica simulation in batch mode.

Features:

A typical use of this function is for remote execution of a large number of simulations with different parameters, often on remote machines (such as clusters).

The script_file parameter defines the .ty script we want to run in batch mode. The output_directory defines the root directory in which a unique individual directory will be created for this particular run. The optional analysis_fn can be any python function to be called at each of the simulation iterations defined in the analysis times list. The analysis_fn should perform whatever analysis of the simulation you want to perform, such as plotting or calculating some statistics. The analysis_fn should avoid using any GUI functions (i.e., should not import anything from topo.tkgui), and it should save all of its results into files.

As a special case, a number can be passed for the times list, in which case it is used to scale a default list of times up to 10000; e.g. times=2 will select a default list of times up to 20000. Alternatively, an explicit list of times can be supplied.

Any other optional parameters supplied will be set in the main namespace before any scripts are run. They will also be used to construct a unique topo.sim.name for the file, and they will be encoded into the simulation directory name, to make it clear how each simulation differs from the others.

If requested by setting snapshot=True, saves a snapshot at the end of the simulation.

If available and requested by setting vc_info=True, prints the revision number and any outstanding diffs from the version control system.

Note that this function alters param.normalize_path.prefix so that all output goes into the same location. The original value of param.normalize_path.prefix is deliberately not restored at the end of the function so that the output of any subsequent commands will go into the same place.

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
_truncate(self, p, s)
If s is greater than the max_name_length parameter, truncate it (and indicate that it has been truncated).
source code
 
__call__(self, script_file, **params_to_override) source code

Inherited from param.parameterized.ParameterizedFunction: __reduce__, __str__, script_repr

Inherited from param.parameterized.Parameterized: __getstate__, __init__, __repr__, __setstate__, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, set_default, set_dynamic_time_fn, set_param, state_pop, state_push, verbose, warning

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from param.parameterized.ParameterizedFunction: instance

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Static Methods [hide private]

Inherited from param.parameterized.ParameterizedFunction: __new__

Class Variables [hide private]
  output_directory = param.String("Output")
  analysis_fn = param.Callable(default_analysis_function)
  times = param.Parameter(1.0)
  snapshot = param.Boolean(True)
  vc_info = param.Boolean(True)
  dirname_prefix = param.String(default= "", doc= ...
Optional prefix for the directory name (allowing e.g.
  max_name_length = param.Number(default= 200, doc= ...
The experiment's directory name will be truncated at this number of characters (since most filesystems have a limit).
  name_time_format = param.String(default= "%Y%m%d%H%M", doc= ...
String format for the time included in the output directory and file names.
  save_global_params = param.Boolean(default= True, doc= ...
Whether to save the script's global_parameters to a pickle in the output_directory after the script has been loaded (for e.g.
  dirname_params_filter = param.Callable(param_formatter.instanc...
Function to control how the parameter names will appear in the output_directory's name.
  name = <param.parameterized.String object at 0x9a4e764>
String identifier for this object.

Inherited from param.parameterized.Parameterized: print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__call__(self, script_file, **params_to_override)
(Call operator)

source code 
Overrides: param.parameterized.ParameterizedFunction.__call__

Class Variable Details [hide private]

dirname_prefix

Optional prefix for the directory name (allowing e.g. easy grouping).
Value:
param.String(default= "", doc= """
        Optional prefix for the directory name (allowing e.g. easy
        grouping).""")

max_name_length

The experiment's directory name will be truncated at this number of characters (since most filesystems have a limit).
Value:
param.Number(default= 200, doc= """
        The experiment's directory name will be truncated at this
        number of characters (since most filesystems have a
        limit).""")

name_time_format

String format for the time included in the output directory and file names. See the Python time module library documentation for codes.

E.g. Adding '%S' to the default would include seconds.

Value:
param.String(default= "%Y%m%d%H%M", doc= """
        String format for the time included in the output directory
        and file names.  See the Python time module library
        documentation for codes.
        
        E.g. Adding '%S' to the default would include seconds.""")

save_global_params

Whether to save the script's global_parameters to a pickle in the output_directory after the script has been loaded (for e.g. future inspection of the experiment).
Value:
param.Boolean(default= True, doc= """
        Whether to save the script's global_parameters to a pickle in
        the output_directory after the script has been loaded (for
        e.g. future inspection of the experiment).""")

dirname_params_filter

Function to control how the parameter names will appear in the output_directory's name.
Value:
param.Callable(param_formatter.instance(), doc= """
        Function to control how the parameter names will appear in the
        output_directory's name.""")