nestly is a collection of functions designed to make running software with combinatorial choices of parameters easier.
Core functions for building nests.
Bases: object
Nests are used to build nested parameter selections, culminating in a directory structure representing choices made, and a JSON dictionary with all selections.
Build parameter combinations with Nest.add(), then create a nested directory structure with Nest.build().
Parameters: |
|
---|
Add a level to the nest
Parameters: |
|
---|
Generate the names of all control files under base_dir
Apply map_fn to the directories defined by control_iter
For each control file in control_iter, map_fn is called with the directory and control file contents as arguments.
Example:
>>> list(nest_map(['run1/control.json', 'run2/control.json'],
... lambda d, c: c['run_id']))
[1, 2]
Parameters: |
|
---|---|
Returns: | A generator of the results of applying map_fn to elements in control_iter |
SCons integration for nestly.
Bases: object
A Nest wrapper to add SCons integration.
This class wraps a Nest in order to provide methods which are useful for using nestly with SCons.
A Nest passed to SConsWrap must have been created with include_outdir=True, which is the default.
Add an aggregate target to this nest.
The first argument is a nullary factory function which will be called immediately for each of the current control dictionaries and stored in each dictionary with the given name like in add_target. After finalize_aggregate or finalize_all_aggregates are called, the decorated function will then be called in the same way as add_target, except with an additional argument: the value which was returned by the factory function.
Since nests added after the aggregate can access the factory function’s value, it can be mutated to provide additional values for use when the decorated function is called.
Add an SCons target to this nest.
The function decorated will be immediately called with each of the output directories and current control dictionaries. Each result will be added to the respective control dictionary for later nests to access.
Call the finalizers for one particular aggregate.
Finalizing an aggregate this way means that it will not be finalized by any future calls to finalize_all_aggregates.
Call the finalizers for all defined aggregates.
If any aggregates have been specifically finalized by finalize_aggregate, they will not be finalized again. This function itself calls finalize_aggregate; if finalize_all_aggregates is called twice, aggregates will not be finalized twice.
Aggregates will be finalized in the same order in which they were defined.