Skip to main content

A simple workflow for executing scripts in parallel with varying argument values

Project description

batchrun

A simple workflow for launching, tracking, and resuming jobs with varying argument values and parameter sweeps.

Quickstart

Launch multiple jobs

Given a runfile containing a list of shell commands:

sleep 1; echo "First!"
sleep 1; echo "Second!"
sleep 1; echo "Third!"

we can launch them line by line as follows:

batchrun launch runfile --n_jobs 2

Batchrun will run the commands in parallel with n_jobs workers and keep track of the jobs. By default, it will write the logs of each command to runs/runfile/logs/<hash of command>, and keep the metadata in runs/runfile/metadata.json. The metadata file contains the mapping from the commands to their hashes, and status information about the jobs.

Resuming where we left and adding new jobs

In the case of shutdown, batchrun will by default resume the jobs which have not finished. Similarly, if we add more jobs to the runlist, batchrun will only run the new ones. The way batchrun tells if a job is new or not is by the command itself. If the command has changed in any way, e.g., the order of arguments is different, batchrun will assume it's a new job.

Create a parameter sweep

Given a specification of a parameter value grid gridspec.yml:

program: python3 my_script.py
parameters:
  alpha:
    values:
      - 1
      - 2
      - 5
  beta:
    values: [0.1, 0.25, 0.5]
  gamma:
    value: 100

we can generate a list of commands corresponding to all possible parameter value combinations:

python3 my_script.py --alpha=1 --beta=0.1 --gamma=100
python3 my_script.py --alpha=1 --beta=0.25 --gamma=100
python3 my_script.py --alpha=1 --beta=0.5 --gamma=100
python3 my_script.py --alpha=2 --beta=0.1 --gamma=100
...

by running the following command:

batchrun sweep gridspec.yml

The runfile containing the commands by default will be written to gridspec.runfile. You can then launch the sweep using the batchrun launch gridspec.runfile as detailed before.

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

batchrun-0.0.14.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

batchrun-0.0.14-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file batchrun-0.0.14.tar.gz.

File metadata

  • Download URL: batchrun-0.0.14.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-35-generic

File hashes

Hashes for batchrun-0.0.14.tar.gz
Algorithm Hash digest
SHA256 810bbe58a70c1de536e5006fa0cc5768f00a18e6c1002dbeecc9b49ce378dd36
MD5 2d6ecfffee66d3033b0e35eac7c4f0b0
BLAKE2b-256 24842063d550eb98aa24acb298a3631d643db72562bd7dad7d970cf212bec2a9

See more details on using hashes here.

File details

Details for the file batchrun-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: batchrun-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-35-generic

File hashes

Hashes for batchrun-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 956814796686949bc2b8470e600555cdf254341bb0f0191517ae91de2eee27c0
MD5 222fde4f79546607356cea8790868b56
BLAKE2b-256 c6fc2e6df1b458042396b8fe16d56f49eafbe5489d57c9b55df9e586c54ab1dc

See more details on using hashes here.

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