Skip to main content

Nestly is a collection of functions designed to make running software with combinatorial choices of parameters easier.

Project description

nestly is a collection of functions designed to ease running software with combinatorial choices of parameters. It can easily do so for “cartesian products” of parameter choices, but can do much more– arbitrary “backwards-looking” dependencies can be used.

The vision here is that we take a fixed set of parameters and generate a single type of output for each defined combination, which can then be combined in some way for comparison and retrieval. We would like to set things up tidily with nested directories for output reflecting nested parameter choices.

The full documentation is available on ReadTheDocs.

Installing

https://travis-ci.org/fhcrc/nestly.svg?branch=master

The easiest way is with pip:

$ pip install nestly

Or, for the latest commit from master:

$ pip install git+git://github.com/fhcrc/nestly.git@master

Python 2.7 is required.

Introductory example

Imagine you’d like to try all possible combinations of the following:

Option

Choices

strategy

approximate, exhaustive

run_count

10, 100, 1000

input file

any file matching inputs/file*

For this we can write a little make_nest.py. The guts are:

nest = Nest()

nest.add('strategy', ('exhaustive', 'approximate'))
nest.add('run_count', [10**i for i in xrange(3)])
nest.add('input_file', glob.glob(os.path.join(input_dir, 'file*')),
        label_func=os.path.basename)

nest.build('runs')

Running make_nest.py, you get a directory tree like:

runs
├── approximate
│   ├── 10
│   │   ├── file1
│   │   │   └── control.json
│   │   ├── file2
│   │       └── control.json
│   ├── 100
│   │   ├── file1
│   │   │   └── control.json
│   │   ├── file2
│   │       └── control.json
│   └── 1000
│       ├── file1
│       │   └── control.json
│       ├── file2
│           └── control.json
└── exhaustive
    ├── 10
    │   ├── file1
    │   │   └── control.json
    │   ├── file2
    │       └── control.json
    ├── 100
    │   ├── file1
    │   │   └── control.json
    │   ├── file2
    │       └── control.json
    └── 1000
        ├── file1
        │   └── control.json
        ├── file2
            └── control.json

With the final control.json reading, for example:

{
    "input_file": "/Users/cmccoy/Development/nestly/examples/basic_nest/inputs/file3",
    "run_count": "1000",
    "strategy": "exhaustive"
}

The control files created then serve as inputs to nestrun for template substition, for example:

nestrun --save-cmd-file command.sh \
        --template='my_command -s {strategy} --count={run_count} {input_file}' \
        $(find runs -name "control.json")

This command runs my_command in all of the tip directories with the appropriate values for the parameters.

This was a “cartesian product” example. The “meal” example in the repository exhibits a setup with more complex dependencies between the nests.

Templates

nestrun takes a template and a list of control.json files with variables to substitute. By default, substitution is performed using the Python built-in str.format method. See the Python Formatter documentation for details on syntax, and examples/jsonrun/do_nestrun.sh for an example.

SCons integration

There is also a nestly.scons module to integrate nestly with the make replacement SCons.

Running the tests

Run:

python setup.py test

The mock library is required, but will be downloaded if missing.

Paper

McCoy CO, Gallagher A, Hoffman NG, Matsen FA (2013) nestly–a framework for running software with nested parameter choices and aggregating results. Bioinformatics 29: 387-388. pubmed

License

nestly source code is freely available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nestly-0.6.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nestly-0.6-py2.py3-none-any.whl (18.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file nestly-0.6.tar.gz.

File metadata

  • Download URL: nestly-0.6.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nestly-0.6.tar.gz
Algorithm Hash digest
SHA256 209adc1ea67c124a88952dc2d2286b465a0d6516c34c2a81a834f0b094bd2ff3
MD5 eabd05db0c6b6447a720ad7f0739c741
BLAKE2b-256 3562e7e636bd46cd1f0c0b8f54ff381f907c4040c26e49411c4203c0670e8f93

See more details on using hashes here.

File details

Details for the file nestly-0.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for nestly-0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2092a5d3dcb2b4bcd19be14f4004bbf0ae92c935e15a4ac254bd223b34d5a765
MD5 fbe8bd91376423c9b3f1baf93cf98f0a
BLAKE2b-256 094d36aae6ef402fe5cde9a9140490b26b1e6550fef32fb9893ae7e47931fa1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page