Skip to main content

A toolkit for doing parameter surveys

Project description

paramsurvey

Build Status Coverage Status Apache License 2.0

paramsurvey is a set of tools for creating and executing parameter surveys.

paramsurvey has a pluggable parallel backend. The supported backends at present are python's multiprocessing module, and computing cluster software ray. An mpi backend is planned.

Example

import time
import paramsurvey


def sleep_worker(pset, system_kwargs, user_kwargs, raw_stats):
    time.sleep(pset['duration'])
    return {'slept': pset['duration']}


paramsurvey.init(backend='multiprocessing')  # or 'ray', if you installed it

psets = [{'duration': 0.3}] * 5

results = paramsurvey.map(sleep_worker, psets, verbose=2)

for r in results.results:
    print(r['pset'], r['result'])

prints, in addition to some debugging output, a result from each of the 5 sleep_worker calls.

Philosophy

A parameter survey runs begins by initializing the software, specifying which backend ('multiprocessing' or 'ray').

A list of parameter sets (psets) is constructed.

The pararamsurvey.map() function executes the worker function once for each pset.

It returns a MapResults object, containing the results, performance statistics, and information about any failures.

Multiple calls to paramsurvey.map() can be made, with different lists of psets.

Worker function limitations

The worker function runs in a different address space and possibly on a different server. It shouldn't access any global variables.

For hard-to-explain Python issues, be sure to define the worker function before calling paramsurvey.init(). The worker function should not be nested inside another function. On Windows, the main program file should have a if __name == '__main__' guard similar to the examples at the top of the Python multprocessing documentation.

The MapResults object

The MapResults object has several properties:

  • results is a list of dictionaries; 'return' is the return value of the worker function, and 'pset' is the pset.
  • failed is a list of failed psets, plus an extra '_exception' key if an exception was raised in the worker
  • progress is a MapProgress object with properties containing the details of pset execution: total, started, finished, failures, exceptions
  • stats is a PerfStats object containing performance statistics

Installing

$ pip install paramsurvey
$ pip install paramsurvey[ray]

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

paramsurvey-0.2.8.tar.gz (24.2 kB view details)

Uploaded Source

File details

Details for the file paramsurvey-0.2.8.tar.gz.

File metadata

  • Download URL: paramsurvey-0.2.8.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

File hashes

Hashes for paramsurvey-0.2.8.tar.gz
Algorithm Hash digest
SHA256 3d87ecbccd04e8b9c1ffb51f9106fdde838751c0a72b6a2e9f1e29d79742c38f
MD5 dfb4aa6d0f802d2191517f82896c5957
BLAKE2b-256 4471044d95ff2252d1e9e4cc58363dcfaa57889b29ee2f19a0714260598ad3b8

See more details on using hashes here.

Provenance

Supported by

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